Backed out changeset 7691b13459f4 (bug 744896) for B2G ICS Emulator Opt test failures on a CLOSED TREE

This commit is contained in:
Carsten "Tomcat" Book 2014-07-03 11:51:41 +02:00
parent 5166e4fdc1
commit 0e366174c0
14 changed files with 97 additions and 53 deletions

View File

@ -151,7 +151,10 @@ public:
// Called by the video decoder object, on the main thread,
// when it has read the metadata containing video dimensions,
// etc.
virtual void MetadataLoaded(const MediaInfo* aInfo,
virtual void MetadataLoaded(int aChannels,
int aRate,
bool aHasAudio,
bool aHasVideo,
const MetadataTags* aTags) MOZ_FINAL MOZ_OVERRIDE;
// Called by the video decoder object, on the main thread,

View File

@ -2876,10 +2876,13 @@ void HTMLMediaElement::ProcessMediaFragmentURI()
}
}
void HTMLMediaElement::MetadataLoaded(const MediaInfo* aInfo,
void HTMLMediaElement::MetadataLoaded(int aChannels,
int aRate,
bool aHasAudio,
bool aHasVideo,
const MetadataTags* aTags)
{
mHasAudio = aInfo->HasAudio();
mHasAudio = aHasAudio;
mTags = aTags;
ChangeReadyState(nsIDOMHTMLMediaElement::HAVE_METADATA);
DispatchAsyncEvent(NS_LITERAL_STRING("durationchange"));
@ -2892,7 +2895,7 @@ void HTMLMediaElement::MetadataLoaded(const MediaInfo* aInfo,
// If this element had a video track, but consists only of an audio track now,
// delete the VideoFrameContainer. This happens when the src is changed to an
// audio only file.
if (!aInfo->HasVideo() && mVideoFrameContainer) {
if (!aHasVideo && mVideoFrameContainer) {
// call ForgetElement() such that callbacks from |mVideoFrameContainer|
// won't reach us anymore.
mVideoFrameContainer->ForgetElement();

View File

@ -8,7 +8,6 @@
#define AbstractMediaDecoder_h_
#include "mozilla/Attributes.h"
#include "MediaInfo.h"
#include "nsISupports.h"
#include "nsDataHashtable.h"
#include "nsThreadUtils.h"
@ -90,8 +89,8 @@ public:
// Return true if the transport layer supports seeking.
virtual bool IsMediaSeekable() = 0;
virtual void MetadataLoaded(MediaInfo* aInfo, MetadataTags* aTags) = 0;
virtual void QueueMetadata(int64_t aTime, MediaInfo* aInfo, MetadataTags* aTags) = 0;
virtual void MetadataLoaded(int aChannels, int aRate, bool aHasAudio, bool aHasVideo, MetadataTags* aTags) = 0;
virtual void QueueMetadata(int64_t aTime, int aChannels, int aRate, bool aHasAudio, bool aHasVideo, MetadataTags* aTags) = 0;
// Set the media end time in microseconds
virtual void SetMediaEndTime(int64_t aTime) = 0;
@ -137,27 +136,30 @@ public:
};
};
class MetadataEventRunner : public nsRunnable
class AudioMetadataEventRunner : public nsRunnable
{
private:
nsRefPtr<AbstractMediaDecoder> mDecoder;
public:
MetadataEventRunner(AbstractMediaDecoder* aDecoder, MediaInfo* aInfo, MetadataTags* aTags)
: mDecoder(aDecoder),
mInfo(aInfo),
mTags(aTags)
AudioMetadataEventRunner(AbstractMediaDecoder* aDecoder, int aChannels, int aRate, bool aHasAudio, bool aHasVideo, MetadataTags* aTags)
: mDecoder(aDecoder),
mChannels(aChannels),
mRate(aRate),
mHasAudio(aHasAudio),
mHasVideo(aHasVideo),
mTags(aTags)
{}
NS_IMETHOD Run() MOZ_OVERRIDE
{
mDecoder->MetadataLoaded(mInfo, mTags);
mDecoder->MetadataLoaded(mChannels, mRate, mHasAudio, mHasVideo, mTags);
return NS_OK;
}
// The ownership is transferred to MediaDecoder.
MediaInfo* mInfo;
// The ownership is transferred to its owning element.
int mChannels;
int mRate;
bool mHasAudio;
bool mHasVideo;
MetadataTags* mTags;
};

View File

@ -147,13 +147,13 @@ BufferDecoder::IsMediaSeekable()
}
void
BufferDecoder::MetadataLoaded(MediaInfo* aInfo, MetadataTags* aTags)
BufferDecoder::MetadataLoaded(int aChannels, int aRate, bool aHasAudio, bool aHasVideo, MetadataTags* aTags)
{
// ignore
}
void
BufferDecoder::QueueMetadata(int64_t aTime, MediaInfo* aInfo, MetadataTags* aTags)
BufferDecoder::QueueMetadata(int64_t aTime, int aChannels, int aRate, bool aHasAudio, bool aHasVideo, MetadataTags* aTags)
{
// ignore
}

View File

@ -60,8 +60,8 @@ public:
virtual bool IsMediaSeekable() MOZ_OVERRIDE;
virtual void MetadataLoaded(MediaInfo* aInfo, MetadataTags* aTags) MOZ_OVERRIDE;
virtual void QueueMetadata(int64_t aTime, MediaInfo* aInfo, MetadataTags* aTags) MOZ_OVERRIDE;
virtual void MetadataLoaded(int aChannels, int aRate, bool aHasAudio, bool aHasVideo, MetadataTags* aTags) MOZ_OVERRIDE;
virtual void QueueMetadata(int64_t aTime, int aChannels, int aRate, bool aHasAudio, bool aHasVideo, MetadataTags* aTags) MOZ_OVERRIDE;
virtual void SetMediaEndTime(int64_t aTime) MOZ_OVERRIDE;

View File

@ -653,12 +653,15 @@ already_AddRefed<nsIPrincipal> MediaDecoder::GetCurrentPrincipal()
}
void MediaDecoder::QueueMetadata(int64_t aPublishTime,
MediaInfo* aInfo,
int aChannels,
int aRate,
bool aHasAudio,
bool aHasVideo,
MetadataTags* aTags)
{
NS_ASSERTION(OnDecodeThread(), "Should be on decode thread.");
GetReentrantMonitor().AssertCurrentThreadIn();
mDecoderStateMachine->QueueMetadata(aPublishTime, aInfo, aTags);
mDecoderStateMachine->QueueMetadata(aPublishTime, aChannels, aRate, aHasAudio, aHasVideo, aTags);
}
bool
@ -669,7 +672,7 @@ MediaDecoder::IsDataCachedToEndOfResource()
mResource->IsDataCachedToEndOfResource(mDecoderPosition));
}
void MediaDecoder::MetadataLoaded(MediaInfo* aInfo, MetadataTags* aTags)
void MediaDecoder::MetadataLoaded(int aChannels, int aRate, bool aHasAudio, bool aHasVideo, MetadataTags* aTags)
{
MOZ_ASSERT(NS_IsMainThread());
if (mShuttingDown) {
@ -697,7 +700,7 @@ void MediaDecoder::MetadataLoaded(MediaInfo* aInfo, MetadataTags* aTags)
// Make sure the element and the frame (if any) are told about
// our new size.
Invalidate();
mOwner->MetadataLoaded(aInfo, aTags);
mOwner->MetadataLoaded(aChannels, aRate, aHasAudio, aHasVideo, aTags);
}
if (!mCalledResourceLoaded) {

View File

@ -751,7 +751,10 @@ public:
// main thread to be presented when the |currentTime| of the media is greater
// or equal to aPublishTime.
void QueueMetadata(int64_t aPublishTime,
MediaInfo* aInfo,
int aChannels,
int aRate,
bool aHasAudio,
bool aHasVideo,
MetadataTags* aTags);
/******
@ -774,7 +777,10 @@ public:
// Called when the metadata from the media file has been loaded by the
// state machine. Call on the main thread only.
virtual void MetadataLoaded(MediaInfo* aInfo,
virtual void MetadataLoaded(int aChannels,
int aRate,
bool aHasAudio,
bool aHasVideo,
MetadataTags* aTags);
// Called when the first frame has been loaded.

View File

@ -49,7 +49,10 @@ public:
// Called by the video decoder object, on the main thread,
// when it has read the metadata containing video dimensions,
// etc.
virtual void MetadataLoaded(const MediaInfo* aInfo,
virtual void MetadataLoaded(int aChannels,
int aRate,
bool aHasAudio,
bool aHasVideo,
const MetadataTags* aTags) = 0;
// Called by the video decoder object, on the main thread,

View File

@ -1983,10 +1983,13 @@ MediaDecoderStateMachine::FinishDecodeMetadata()
}
// Inform the element that we've loaded the metadata and the first frame.
nsAutoPtr<MediaInfo> info(new MediaInfo());
*info = mInfo;
nsCOMPtr<nsIRunnable> metadataLoadedEvent =
new MetadataEventRunner(mDecoder, info.forget(), mMetadataTags.forget());
new AudioMetadataEventRunner(mDecoder,
mInfo.mAudio.mChannels,
mInfo.mAudio.mRate,
HasAudio(),
HasVideo(),
mMetadataTags.forget());
NS_DispatchToMainThread(metadataLoadedEvent, NS_DISPATCH_NORMAL);
if (mState == DECODER_STATE_DECODING_METADATA) {
@ -3095,14 +3098,20 @@ bool MediaDecoderStateMachine::IsShutdown()
}
void MediaDecoderStateMachine::QueueMetadata(int64_t aPublishTime,
MediaInfo* aInfo,
int aChannels,
int aRate,
bool aHasAudio,
bool aHasVideo,
MetadataTags* aTags)
{
NS_ASSERTION(OnDecodeThread(), "Should be on decode thread.");
AssertCurrentThreadInMonitor();
TimedMetadata* metadata = new TimedMetadata;
metadata->mPublishTime = aPublishTime;
metadata->mInfo = aInfo;
metadata->mChannels = aChannels;
metadata->mRate = aRate;
metadata->mHasAudio = aHasAudio;
metadata->mHasVideo = aHasVideo;
metadata->mTags = aTags;
mMetadataManager.QueueMetadata(metadata);
}

View File

@ -323,7 +323,7 @@ public:
// shutting down. The decoder monitor must be held while calling this.
bool IsShutdown();
void QueueMetadata(int64_t aPublishTime, MediaInfo* aInfo, MetadataTags* aTags);
void QueueMetadata(int64_t aPublishTime, int aChannels, int aRate, bool aHasAudio, bool aHasVideo, MetadataTags* aTags);
// Returns true if we're currently playing. The decoder monitor must
// be held.

View File

@ -22,10 +22,14 @@ namespace mozilla {
// The metadata. The ownership is transfered to the element when dispatching to
// the main threads.
nsAutoPtr<MetadataTags> mTags;
// The media info, including the info of audio tracks and video tracks.
// The ownership is transfered to MediaDecoder when dispatching to the
// main thread.
nsAutoPtr<MediaInfo> mInfo;
// The sample rate of this media.
int mRate;
// The number of channel of this media.
int mChannels;
// True if this media has an audio track.
bool mHasAudio;
// True if this media has a video track.
bool mHasVideo;
};
// This class encapsulate the logic to give the metadata from the reader to
@ -47,9 +51,12 @@ namespace mozilla {
TimedMetadata* metadata = mMetadataQueue.getFirst();
while (metadata && aCurrentTime >= static_cast<double>(metadata->mPublishTime) / USECS_PER_S) {
nsCOMPtr<nsIRunnable> metadataUpdatedEvent =
new MetadataEventRunner(aDecoder,
metadata->mInfo.forget(),
metadata->mTags.forget());
new AudioMetadataEventRunner(aDecoder,
metadata->mChannels,
metadata->mRate,
metadata->mHasAudio,
metadata->mHasVideo,
metadata->mTags.forget());
NS_DispatchToMainThread(metadataUpdatedEvent);
delete mMetadataQueue.popFirst();
metadata = mMetadataQueue.getFirst();

View File

@ -627,6 +627,8 @@ bool OggReader::ReadOggChain()
OpusState* newOpusState = nullptr;
#endif /* MOZ_OPUS */
VorbisState* newVorbisState = nullptr;
int channels = 0;
long rate = 0;
MetadataTags* tags = nullptr;
if (HasVideo() || HasSkeleton() || !HasAudio()) {
@ -671,7 +673,6 @@ bool OggReader::ReadOggChain()
return false;
}
nsAutoPtr<MediaInfo> info(new MediaInfo());
if ((newVorbisState && ReadHeaders(newVorbisState)) &&
(mVorbisState->mInfo.rate == newVorbisState->mInfo.rate) &&
(mVorbisState->mInfo.channels == newVorbisState->mInfo.channels)) {
@ -680,8 +681,8 @@ bool OggReader::ReadOggChain()
mVorbisSerial = mVorbisState->mSerial;
LOG(PR_LOG_DEBUG, ("New vorbis ogg link, serial=%d\n", mVorbisSerial));
chained = true;
info->mAudio.mRate = mVorbisState->mInfo.rate;
info->mAudio.mChannels = mVorbisState->mInfo.channels;
rate = mVorbisState->mInfo.rate;
channels = mVorbisState->mInfo.channels;
tags = mVorbisState->GetTags();
}
@ -693,8 +694,8 @@ bool OggReader::ReadOggChain()
mOpusState = newOpusState;
mOpusSerial = mOpusState->mSerial;
chained = true;
info->mAudio.mRate = mOpusState->mRate;
info->mAudio.mChannels = mOpusState->mChannels;
rate = mOpusState->mRate;
channels = mOpusState->mChannels;
tags = mOpusState->GetTags();
}
#endif
@ -702,12 +703,13 @@ bool OggReader::ReadOggChain()
if (chained) {
SetChained(true);
{
info->mAudio.mHasAudio = HasAudio();
info->mVideo.mHasVideo = HasVideo();
int rate = info->mAudio.mRate;
ReentrantMonitorAutoEnter mon(mDecoder->GetReentrantMonitor());
mDecoder->QueueMetadata((mDecodedAudioFrames * USECS_PER_S) / rate,
info.forget(), tags);
channels,
rate,
HasAudio(),
HasVideo(),
tags);
}
return true;
}

View File

@ -55,11 +55,14 @@ void MediaOmxDecoder::SetCanOffloadAudio(bool aCanOffloadAudio)
mCanOffloadAudio = aCanOffloadAudio;
}
void MediaOmxDecoder::MetadataLoaded(MediaInfo* aInfo,
void MediaOmxDecoder::MetadataLoaded(int aChannels,
int aRate,
bool aHasAudio,
bool aHasVideo,
MetadataTags* aTags)
{
MOZ_ASSERT(NS_IsMainThread());
MediaDecoder::MetadataLoaded(aInfo, aTags);
MediaDecoder::MetadataLoaded(aChannels, aRate, aHasAudio, aHasVideo, aTags);
ReentrantMonitorAutoEnter mon(GetReentrantMonitor());
if (!mCanOffloadAudio || mFallbackToStateMachine || mOutputStreams.Length() ||

View File

@ -21,7 +21,10 @@ public:
virtual MediaDecoder* Clone();
virtual MediaDecoderStateMachine* CreateStateMachine();
virtual void MetadataLoaded(MediaInfo* aInfo,
virtual void MetadataLoaded(int aChannels,
int aRate,
bool aHasAudio,
bool aHasVideo,
MetadataTags* aTags);
virtual void ChangeState(PlayState aState);
virtual void ApplyStateToStateMachine(PlayState aState);