author | Bobby Holley <bobbyholley@gmail.com> |
Mon, 08 Jun 2015 17:26:42 -0700 | |
changeset 248174 | 0e722555cc6dcb49b6b833419f9670b99207c311 |
parent 248173 | e7b684137f229a40241bb0f2ad2c834103a2166a |
child 248175 | f2f35acc27a255e85342462341f55cda36c3de65 |
push id | 28893 |
push user | kwierso@gmail.com |
push date | Fri, 12 Jun 2015 00:02:58 +0000 |
treeherder | autoland@8cf9d3e497f9 [default view] [failures only] |
perfherder | [talos] [build metrics] [platform microbench] (compared to previous push) |
reviewers | jww |
bugs | 1173001 |
milestone | 41.0a1 |
first release with | nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
|
last release without | nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
|
--- a/dom/media/MediaDecoderReader.cpp +++ b/dom/media/MediaDecoderReader.cpp @@ -216,17 +216,17 @@ public: int64_t aTimeThreshold) : mReader(aReader) , mTimeThreshold(aTimeThreshold) { } NS_METHOD Run() { - MOZ_ASSERT(mReader->GetTaskQueue()->IsCurrentThreadIn()); + MOZ_ASSERT(mReader->OnTaskQueue()); // Make sure ResetDecode hasn't been called in the mean time. if (!mReader->mBaseVideoPromise.IsEmpty()) { mReader->RequestVideoData(/* aSkip = */ true, mTimeThreshold); } return NS_OK; } @@ -241,17 +241,17 @@ class ReRequestAudioTask : public nsRunn public: explicit ReRequestAudioTask(MediaDecoderReader* aReader) : mReader(aReader) { } NS_METHOD Run() { - MOZ_ASSERT(mReader->GetTaskQueue()->IsCurrentThreadIn()); + MOZ_ASSERT(mReader->OnTaskQueue()); // Make sure ResetDecode hasn't been called in the mean time. if (!mReader->mBaseAudioPromise.IsEmpty()) { mReader->RequestAudioData(); } return NS_OK; } @@ -348,17 +348,17 @@ MediaDecoderReader::Shutdown() mBaseAudioPromise.RejectIfExists(END_OF_STREAM, __func__); mBaseVideoPromise.RejectIfExists(END_OF_STREAM, __func__); ReleaseMediaResources(); nsRefPtr<ShutdownPromise> p; // Spin down the task queue if necessary. We wait until BreakCycles to null // out mTaskQueue, since otherwise any remaining tasks could crash when they - // invoke GetTaskQueue()->IsCurrentThreadIn(). + // invoke OnTaskQueue(). if (mTaskQueue && !mTaskQueueIsBorrowed) { // If we own our task queue, shutdown ends when the task queue is done. p = mTaskQueue->BeginShutdown(); } else { // If we don't own our task queue, we resolve immediately (though // asynchronously). p = ShutdownPromise::CreateAndResolve(true, __func__); }
--- a/dom/media/MediaDecoderReader.h +++ b/dom/media/MediaDecoderReader.h @@ -104,17 +104,17 @@ public: // Destroys the decoding state. The reader cannot be made usable again. // This is different from ReleaseMediaResources() as it is irreversable, // whereas ReleaseMediaResources() is. Must be called on the decode // thread. virtual nsRefPtr<ShutdownPromise> Shutdown(); virtual bool OnTaskQueue() { - return GetTaskQueue()->IsCurrentThreadIn(); + return TaskQueue()->IsCurrentThreadIn(); } // Resets all state related to decoding, emptying all buffers etc. // Cancels all pending Request*Data() request callbacks, rejects any // outstanding seek promises, and flushes the decode pipeline. The // decoder must not call any of the callbacks for outstanding // Request*Data() calls after this is called. Calls to Request*Data() // made after this should be processed as usual. @@ -252,17 +252,17 @@ public: MediaInfo GetMediaInfo() { return mInfo; } // Indicates if the media is seekable. // ReadMetada should be called before calling this method. virtual bool IsMediaSeekable() = 0; void SetStartTime(int64_t aStartTime); - MediaTaskQueue* GetTaskQueue() { + MediaTaskQueue* TaskQueue() { return mTaskQueue; } // Returns true if the reader implements RequestAudioData() // and RequestVideoData() asynchronously, rather than using the // implementation in this class to adapt the old synchronous to // the newer async model. virtual bool IsAsync() const { return false; }
--- a/dom/media/MediaDecoderStateMachine.h +++ b/dom/media/MediaDecoderStateMachine.h @@ -841,17 +841,17 @@ public: // NotifyAll on the monitor must be called when the state is changed so // that interested threads can wake up and alter behaviour if appropriate // Accessed on state machine, audio, main, and AV thread. Watchable<State> mState; // The task queue in which we run decode tasks. This is referred to as // the "decode thread", though in practise tasks can run on a different // thread every time they're called. - MediaTaskQueue* DecodeTaskQueue() const { return mReader->GetTaskQueue(); } + MediaTaskQueue* DecodeTaskQueue() const { return mReader->TaskQueue(); } // The time that playback started from the system clock. This is used for // timing the presentation of video frames when there's no audio. // Accessed only via the state machine thread. Must be set via SetPlayStartTime. TimeStamp mPlayStartTime; // The amount of time we've spent playing already the media. The current // playback position is therefore |Now() - mPlayStartTime +
--- a/dom/media/MediaFormatReader.cpp +++ b/dom/media/MediaFormatReader.cpp @@ -276,17 +276,17 @@ MediaFormatReader::AsyncReadMetadata() metadata->mInfo = mInfo; metadata->mTags = nullptr; return MetadataPromise::CreateAndResolve(metadata, __func__); } nsRefPtr<MetadataPromise> p = mMetadataPromise.Ensure(__func__); mDemuxerInitRequest.Begin(mDemuxer->Init() - ->Then(GetTaskQueue(), __func__, this, + ->Then(TaskQueue(), __func__, this, &MediaFormatReader::OnDemuxerInitDone, &MediaFormatReader::OnDemuxerInitFailed)); return p; } void MediaFormatReader::OnDemuxerInitDone(nsresult) { @@ -583,17 +583,17 @@ MediaFormatReader::OnDemuxFailed(TrackTy } } void MediaFormatReader::DoDemuxVideo() { // TODO Use DecodeAhead value rather than 1. mVideo.mDemuxRequest.Begin(mVideo.mTrackDemuxer->GetSamples(1) - ->Then(GetTaskQueue(), __func__, this, + ->Then(TaskQueue(), __func__, this, &MediaFormatReader::OnVideoDemuxCompleted, &MediaFormatReader::OnVideoDemuxFailed)); } void MediaFormatReader::OnVideoDemuxCompleted(nsRefPtr<MediaTrackDemuxer::SamplesHolder> aSamples) { LOGV("%d video samples demuxed", aSamples->mSamples.Length()); @@ -638,17 +638,17 @@ MediaFormatReader::RequestAudioData() return p; } void MediaFormatReader::DoDemuxAudio() { // TODO Use DecodeAhead value rather than 1. mAudio.mDemuxRequest.Begin(mAudio.mTrackDemuxer->GetSamples(1) - ->Then(GetTaskQueue(), __func__, this, + ->Then(TaskQueue(), __func__, this, &MediaFormatReader::OnAudioDemuxCompleted, &MediaFormatReader::OnAudioDemuxFailed)); } void MediaFormatReader::OnAudioDemuxCompleted(nsRefPtr<MediaTrackDemuxer::SamplesHolder> aSamples) { LOGV("%d audio samples demuxed", aSamples->mSamples.Length()); @@ -743,17 +743,17 @@ MediaFormatReader::ScheduleUpdate(TrackT auto& decoder = GetDecoderData(aTrack); if (decoder.mUpdateScheduled) { return; } LOGV("SchedulingUpdate(%s)", TrackTypeToStr(aTrack)); decoder.mUpdateScheduled = true; RefPtr<nsIRunnable> task( NS_NewRunnableMethodWithArg<TrackType>(this, &MediaFormatReader::Update, aTrack)); - GetTaskQueue()->Dispatch(task.forget()); + TaskQueue()->Dispatch(task.forget()); } bool MediaFormatReader::UpdateReceivedNewData(TrackType aTrack) { MOZ_ASSERT(OnTaskQueue()); auto& decoder = GetDecoderData(aTrack); @@ -1038,44 +1038,44 @@ MediaFormatReader::Output(TrackType aTra NS_WARNING("MediaFormatReader::Output() passed a null sample"); Error(aTrack); return; } RefPtr<nsIRunnable> task = NS_NewRunnableMethodWithArgs<TrackType, MediaData*>( this, &MediaFormatReader::NotifyNewOutput, aTrack, aSample); - GetTaskQueue()->Dispatch(task.forget()); + TaskQueue()->Dispatch(task.forget()); } void MediaFormatReader::DrainComplete(TrackType aTrack) { RefPtr<nsIRunnable> task = NS_NewRunnableMethodWithArg<TrackType>( this, &MediaFormatReader::NotifyDrainComplete, aTrack); - GetTaskQueue()->Dispatch(task.forget()); + TaskQueue()->Dispatch(task.forget()); } void MediaFormatReader::InputExhausted(TrackType aTrack) { RefPtr<nsIRunnable> task = NS_NewRunnableMethodWithArg<TrackType>( this, &MediaFormatReader::NotifyInputExhausted, aTrack); - GetTaskQueue()->Dispatch(task.forget()); + TaskQueue()->Dispatch(task.forget()); } void MediaFormatReader::Error(TrackType aTrack) { RefPtr<nsIRunnable> task = NS_NewRunnableMethodWithArg<TrackType>( this, &MediaFormatReader::NotifyError, aTrack); - GetTaskQueue()->Dispatch(task.forget()); + TaskQueue()->Dispatch(task.forget()); } void MediaFormatReader::Flush(TrackType aTrack) { MOZ_ASSERT(OnTaskQueue()); LOG("Flush(%s) BEGIN", TrackTypeToStr(aTrack)); @@ -1105,17 +1105,17 @@ MediaFormatReader::SkipVideoDemuxToNextK LOG("Skipping up to %lld", aTimeThreshold.ToMicroseconds()); if (mVideo.mError) { mVideo.RejectPromise(DECODE_ERROR, __func__); return; } mSkipRequest.Begin(mVideo.mTrackDemuxer->SkipToNextRandomAccessPoint(aTimeThreshold) - ->Then(GetTaskQueue(), __func__, this, + ->Then(TaskQueue(), __func__, this, &MediaFormatReader::OnVideoSkipCompleted, &MediaFormatReader::OnVideoSkipFailed)); return; } void MediaFormatReader::OnVideoSkipCompleted(uint32_t aSkipped) { @@ -1208,17 +1208,17 @@ MediaFormatReader::OnSeekFailed(TrackTyp void MediaFormatReader::DoVideoSeek() { MOZ_ASSERT(mPendingSeekTime.isSome()); LOGV("Seeking video to %lld", mPendingSeekTime.ref().ToMicroseconds()); media::TimeUnit seekTime = mPendingSeekTime.ref(); mVideoSeekRequest.Begin(mVideo.mTrackDemuxer->Seek(seekTime) - ->Then(GetTaskQueue(), __func__, this, + ->Then(TaskQueue(), __func__, this, &MediaFormatReader::OnVideoSeekCompleted, &MediaFormatReader::OnVideoSeekFailed)); } void MediaFormatReader::OnVideoSeekCompleted(media::TimeUnit aTime) { MOZ_ASSERT(OnTaskQueue()); @@ -1237,17 +1237,17 @@ MediaFormatReader::OnVideoSeekCompleted( void MediaFormatReader::DoAudioSeek() { MOZ_ASSERT(mPendingSeekTime.isSome()); LOGV("Seeking audio to %lld", mPendingSeekTime.ref().ToMicroseconds()); media::TimeUnit seekTime = mPendingSeekTime.ref(); mAudioSeekRequest.Begin(mAudio.mTrackDemuxer->Seek(seekTime) - ->Then(GetTaskQueue(), __func__, this, + ->Then(TaskQueue(), __func__, this, &MediaFormatReader::OnAudioSeekCompleted, &MediaFormatReader::OnAudioSeekFailed)); } void MediaFormatReader::OnAudioSeekCompleted(media::TimeUnit aTime) { MOZ_ASSERT(OnTaskQueue()); @@ -1429,17 +1429,17 @@ MediaFormatReader::NotifyDataArrived(con return; } // Queue a task to notify our main demuxer. RefPtr<nsIRunnable> task = NS_NewRunnableMethodWithArgs<int32_t, uint64_t>( this, &MediaFormatReader::NotifyDemuxer, aLength, aOffset); - GetTaskQueue()->Dispatch(task.forget()); + TaskQueue()->Dispatch(task.forget()); } void MediaFormatReader::NotifyDataRemoved() { MOZ_ASSERT(NS_IsMainThread()); mDataRange = ByteInterval(); @@ -1452,12 +1452,12 @@ MediaFormatReader::NotifyDataRemoved() MOZ_ASSERT(mMainThreadDemuxer); mMainThreadDemuxer->NotifyDataRemoved(); // Queue a task to notify our main demuxer. RefPtr<nsIRunnable> task = NS_NewRunnableMethodWithArgs<int32_t, uint64_t>( this, &MediaFormatReader::NotifyDemuxer, 0, 0); - GetTaskQueue()->Dispatch(task.forget()); + TaskQueue()->Dispatch(task.forget()); } } // namespace mozilla
--- a/dom/media/fmp4/MP4Reader.cpp +++ b/dom/media/fmp4/MP4Reader.cpp @@ -167,17 +167,17 @@ MP4Reader::MP4Reader(AbstractMediaDecode MP4Reader::~MP4Reader() { MOZ_COUNT_DTOR(MP4Reader); } nsRefPtr<ShutdownPromise> MP4Reader::Shutdown() { - MOZ_ASSERT(GetTaskQueue()->IsCurrentThreadIn()); + MOZ_ASSERT(OnTaskQueue()); if (mAudio.mDecoder) { Flush(TrackInfo::kAudioTrack); mAudio.mDecoder->Shutdown(); mAudio.mDecoder = nullptr; } if (mAudio.mTaskQueue) { mAudio.mTaskQueue->BeginShutdown(); @@ -606,17 +606,17 @@ MP4Reader::ShouldSkip(bool aSkipToNextKe } return nextKeyframe < aTimeThreshold; } nsRefPtr<MediaDecoderReader::VideoDataPromise> MP4Reader::RequestVideoData(bool aSkipToNextKeyframe, int64_t aTimeThreshold) { - MOZ_ASSERT(GetTaskQueue()->IsCurrentThreadIn()); + MOZ_ASSERT(OnTaskQueue()); VLOG("skip=%d time=%lld", aSkipToNextKeyframe, aTimeThreshold); if (!EnsureDecodersSetup()) { NS_WARNING("Error constructing MP4 decoders"); return VideoDataPromise::CreateAndReject(DECODE_ERROR, __func__); } if (mShutdown) { @@ -647,17 +647,17 @@ MP4Reader::RequestVideoData(bool aSkipTo } return p; } nsRefPtr<MediaDecoderReader::AudioDataPromise> MP4Reader::RequestAudioData() { - MOZ_ASSERT(GetTaskQueue()->IsCurrentThreadIn()); + MOZ_ASSERT(OnTaskQueue()); VLOG(""); if (!EnsureDecodersSetup()) { NS_WARNING("Error constructing MP4 decoders"); return AudioDataPromise::CreateAndReject(DECODE_ERROR, __func__); } if (mShutdown) { @@ -678,17 +678,17 @@ MP4Reader::ScheduleUpdate(TrackType aTra decoder.mMonitor.AssertCurrentThreadOwns(); if (decoder.mUpdateScheduled) { return; } VLOG("SchedulingUpdate(%s)", TrackTypeToStr(aTrack)); decoder.mUpdateScheduled = true; RefPtr<nsIRunnable> task( NS_NewRunnableMethodWithArg<TrackType>(this, &MP4Reader::Update, aTrack)); - GetTaskQueue()->Dispatch(task.forget()); + TaskQueue()->Dispatch(task.forget()); } bool MP4Reader::NeedInput(DecoderData& aDecoder) { aDecoder.mMonitor.AssertCurrentThreadOwns(); // We try to keep a few more compressed samples input than decoded samples // have been output, provided the state machine has requested we send it a @@ -702,17 +702,17 @@ MP4Reader::NeedInput(DecoderData& aDecod aDecoder.mOutput.IsEmpty() && (aDecoder.mInputExhausted || aDecoder.mNumSamplesInput - aDecoder.mNumSamplesOutput < aDecoder.mDecodeAhead); } void MP4Reader::Update(TrackType aTrack) { - MOZ_ASSERT(GetTaskQueue()->IsCurrentThreadIn()); + MOZ_ASSERT(OnTaskQueue()); if (mShutdown) { return; } // Record number of frames decoded and parsed. Automatically update the // stats counters using the AutoNotifyDecoded stack-based class. AbstractMediaDecoder::AutoNotifyDecoded a(mDecoder); @@ -868,17 +868,17 @@ MP4Reader::SizeOfQueue(TrackType aTrack) auto& decoder = GetDecoderData(aTrack); MonitorAutoLock lock(decoder.mMonitor); return decoder.mOutput.Length() + (decoder.mNumSamplesInput - decoder.mNumSamplesOutput); } nsresult MP4Reader::ResetDecode() { - MOZ_ASSERT(GetTaskQueue()->IsCurrentThreadIn()); + MOZ_ASSERT(OnTaskQueue()); Flush(TrackInfo::kVideoTrack); { MonitorAutoLock mon(mDemuxerMonitor); if (mVideo.mTrackDemuxer) { mVideo.mTrackDemuxer->Seek(0); } } Flush(TrackInfo::kAudioTrack); @@ -950,17 +950,17 @@ MP4Reader::Error(TrackType aTrack) data.RejectPromise(DECODE_ERROR, __func__); } } } void MP4Reader::Flush(TrackType aTrack) { - MOZ_ASSERT(GetTaskQueue()->IsCurrentThreadIn()); + MOZ_ASSERT(OnTaskQueue()); VLOG("Flush(%s) BEGIN", TrackTypeToStr(aTrack)); DecoderData& data = GetDecoderData(aTrack); if (!data.mDecoder) { return; } // Purge the current decoder's state. // Set a flag so that we ignore all output while we call // MediaDataDecoder::Flush(). @@ -988,17 +988,17 @@ MP4Reader::Flush(TrackType aTrack) mQueuedVideoSample = nullptr; } VLOG("Flush(%s) END", TrackTypeToStr(aTrack)); } bool MP4Reader::SkipVideoDemuxToNextKeyFrame(int64_t aTimeThreshold, uint32_t& parsed) { - MOZ_ASSERT(GetTaskQueue()->IsCurrentThreadIn()); + MOZ_ASSERT(OnTaskQueue()); MOZ_ASSERT(mVideo.mDecoder); Flush(TrackInfo::kVideoTrack); // Loop until we reach the next keyframe after the threshold. while (true) { nsRefPtr<MediaRawData> compressed(PopSample(TrackInfo::kVideoTrack)); @@ -1019,17 +1019,17 @@ MP4Reader::SkipVideoDemuxToNextKeyFrame( return true; } nsRefPtr<MediaDecoderReader::SeekPromise> MP4Reader::Seek(int64_t aTime, int64_t aEndTime) { LOG("aTime=(%lld)", aTime); - MOZ_ASSERT(GetTaskQueue()->IsCurrentThreadIn()); + MOZ_ASSERT(OnTaskQueue()); MonitorAutoLock mon(mDemuxerMonitor); if (!mDemuxer->CanSeek()) { VLOG("Seek() END (Unseekable)"); return SeekPromise::CreateAndReject(NS_ERROR_FAILURE, __func__); } int64_t seekTime = aTime; mQueuedVideoSample = nullptr;
--- a/dom/media/gtest/TestMP4Reader.cpp +++ b/dom/media/gtest/TestMP4Reader.cpp @@ -51,17 +51,17 @@ public: EXPECT_EQ(NS_OK, rv); thread->Shutdown(); } private: virtual ~TestBinding() { { - nsRefPtr<MediaTaskQueue> queue = reader->GetTaskQueue(); + nsRefPtr<MediaTaskQueue> queue = reader->TaskQueue(); nsCOMPtr<nsIRunnable> task = NS_NewRunnableMethod(reader, &MP4Reader::Shutdown); // Hackily bypass the tail dispatcher so that we can AwaitShutdownAndIdle. // In production code we'd use BeginShutdown + promises. queue->Dispatch(task.forget(), AbstractThread::AssertDispatchSuccess, AbstractThread::TailDispatch); queue->AwaitShutdownAndIdle(); } decoder = nullptr;
--- a/dom/media/mediasource/MediaSourceReader.cpp +++ b/dom/media/mediasource/MediaSourceReader.cpp @@ -156,17 +156,17 @@ MediaSourceReader::RequestAudioData() } MOZ_DIAGNOSTIC_ASSERT(!mAudioSeekRequest.Exists()); SwitchSourceResult ret = SwitchAudioSource(&mLastAudioTime); switch (ret) { case SOURCE_NEW: GetAudioReader()->ResetDecode(); mAudioSeekRequest.Begin(GetAudioReader()->Seek(GetReaderAudioTime(mLastAudioTime), 0) - ->Then(GetTaskQueue(), __func__, this, + ->Then(TaskQueue(), __func__, this, &MediaSourceReader::CompleteAudioSeekAndDoRequest, &MediaSourceReader::CompleteAudioSeekAndRejectPromise)); break; case SOURCE_NONE: if (!mLastAudioTime) { // This is the first call to RequestAudioData. // Fallback to using decoder with earliest data. mAudioSourceDecoder = FirstDecoder(MediaData::AUDIO_DATA); @@ -181,17 +181,17 @@ MediaSourceReader::RequestAudioData() break; } return p; } void MediaSourceReader::DoAudioRequest() { mAudioRequest.Begin(GetAudioReader()->RequestAudioData() - ->Then(GetTaskQueue(), __func__, this, + ->Then(TaskQueue(), __func__, this, &MediaSourceReader::OnAudioDecoded, &MediaSourceReader::OnAudioNotDecoded)); } void MediaSourceReader::OnAudioDecoded(AudioData* aSample) { MOZ_DIAGNOSTIC_ASSERT(!IsSeeking()); @@ -204,17 +204,17 @@ MediaSourceReader::OnAudioDecoded(AudioD MSE_DEBUGV("[mTime=%lld mDuration=%lld mDiscontinuity=%d]", ourTime, aSample->mDuration, aSample->mDiscontinuity); if (mDropAudioBeforeThreshold) { if (ourTime < mTimeThreshold) { MSE_DEBUG("mTime=%lld < mTimeThreshold=%lld", ourTime, mTimeThreshold); mAudioRequest.Begin(GetAudioReader()->RequestAudioData() - ->Then(GetTaskQueue(), __func__, this, + ->Then(TaskQueue(), __func__, this, &MediaSourceReader::OnAudioDecoded, &MediaSourceReader::OnAudioNotDecoded)); return; } mDropAudioBeforeThreshold = false; } // Adjust the sample time into our reference. @@ -274,17 +274,17 @@ MediaSourceReader::OnAudioNotDecoded(Not AdjustEndTime(&mLastAudioTime, mAudioSourceDecoder); } SwitchSourceResult result = SwitchAudioSource(&mLastAudioTime); // See if we can find a different source that can pick up where we left off. if (result == SOURCE_NEW) { GetAudioReader()->ResetDecode(); mAudioSeekRequest.Begin(GetAudioReader()->Seek(GetReaderAudioTime(mLastAudioTime), 0) - ->Then(GetTaskQueue(), __func__, this, + ->Then(TaskQueue(), __func__, this, &MediaSourceReader::CompleteAudioSeekAndDoRequest, &MediaSourceReader::CompleteAudioSeekAndRejectPromise)); return; } // If we got a DECODE_ERROR and we have buffered data in the requested range // then it must be a genuine decoding error. // Otherwise we can assume that the data was either evicted or explicitely @@ -329,17 +329,17 @@ MediaSourceReader::RequestVideoData(bool } MOZ_DIAGNOSTIC_ASSERT(!mVideoSeekRequest.Exists()); SwitchSourceResult ret = SwitchVideoSource(&mLastVideoTime); switch (ret) { case SOURCE_NEW: GetVideoReader()->ResetDecode(); mVideoSeekRequest.Begin(GetVideoReader()->Seek(GetReaderVideoTime(mLastVideoTime), 0) - ->Then(GetTaskQueue(), __func__, this, + ->Then(TaskQueue(), __func__, this, &MediaSourceReader::CompleteVideoSeekAndDoRequest, &MediaSourceReader::CompleteVideoSeekAndRejectPromise)); break; case SOURCE_NONE: if (!mLastVideoTime) { // This is the first call to RequestVideoData. // Fallback to using decoder with earliest data. mVideoSourceDecoder = FirstDecoder(MediaData::VIDEO_DATA); @@ -356,17 +356,17 @@ MediaSourceReader::RequestVideoData(bool return p; } void MediaSourceReader::DoVideoRequest() { mVideoRequest.Begin(GetVideoReader()->RequestVideoData(mDropVideoBeforeThreshold, GetReaderVideoTime(mTimeThreshold)) - ->Then(GetTaskQueue(), __func__, this, + ->Then(TaskQueue(), __func__, this, &MediaSourceReader::OnVideoDecoded, &MediaSourceReader::OnVideoNotDecoded)); } void MediaSourceReader::OnVideoDecoded(VideoData* aSample) { MOZ_DIAGNOSTIC_ASSERT(!IsSeeking()); @@ -426,17 +426,17 @@ MediaSourceReader::OnVideoNotDecoded(Not AdjustEndTime(&mLastVideoTime, mVideoSourceDecoder); } // See if we can find a different reader that can pick up where we left off. SwitchSourceResult result = SwitchVideoSource(&mLastVideoTime); if (result == SOURCE_NEW) { GetVideoReader()->ResetDecode(); mVideoSeekRequest.Begin(GetVideoReader()->Seek(GetReaderVideoTime(mLastVideoTime), 0) - ->Then(GetTaskQueue(), __func__, this, + ->Then(TaskQueue(), __func__, this, &MediaSourceReader::CompleteVideoSeekAndDoRequest, &MediaSourceReader::CompleteVideoSeekAndRejectPromise)); return; } // If we got a DECODE_ERROR and we have buffered data in the requested range // then it must be a genuine decoding error. // Otherwise we can assume that the data was either evicted or explicitely @@ -497,17 +497,17 @@ MediaSourceReader::Shutdown() return p; } void MediaSourceReader::ContinueShutdown() { ReentrantMonitorAutoEnter mon(mDecoder->GetReentrantMonitor()); if (mTrackBuffers.Length()) { - mTrackBuffers[0]->Shutdown()->Then(GetTaskQueue(), __func__, this, + mTrackBuffers[0]->Shutdown()->Then(TaskQueue(), __func__, this, &MediaSourceReader::ContinueShutdown, &MediaSourceReader::ContinueShutdown); mShutdownTrackBuffers.AppendElement(mTrackBuffers[0]); mTrackBuffers.RemoveElementAt(0); return; } mAudioTrack = nullptr; @@ -718,17 +718,17 @@ MediaSourceReader::CreateSubDecoder(cons // its own task queue. Unfortunately though, Request{Audio,Video}Data implementations // currently assert that they're on "the decode thread", and so having // separate task queues makes MediaSource stuff unnecessarily cumbersome. We // should remove the need for these assertions (which probably involves making // all Request*Data implementations fully async), and then get rid of the // borrowing. nsRefPtr<SourceBufferDecoder> decoder = new SourceBufferDecoder(new SourceBufferResource(aType), mDecoder, aTimestampOffset); - nsRefPtr<MediaDecoderReader> reader(CreateReaderForType(aType, decoder, GetTaskQueue())); + nsRefPtr<MediaDecoderReader> reader(CreateReaderForType(aType, decoder, TaskQueue())); if (!reader) { return nullptr; } // MSE uses a start time of 0 everywhere. Set that immediately on the // subreader to make sure that it's always in a state where we can invoke // GetBuffered on it. { @@ -808,17 +808,17 @@ MediaSourceReader::TrackBuffersContainTi void MediaSourceReader::NotifyTimeRangesChanged() { ReentrantMonitorAutoEnter mon(mDecoder->GetReentrantMonitor()); if (mWaitingForSeekData) { //post a task to the decode queue to try to complete the pending seek. RefPtr<nsIRunnable> task(NS_NewRunnableMethod( this, &MediaSourceReader::AttemptSeek)); - GetTaskQueue()->Dispatch(task.forget()); + TaskQueue()->Dispatch(task.forget()); } else { MaybeNotifyHaveData(); } } nsRefPtr<MediaDecoderReader::SeekPromise> MediaSourceReader::Seek(int64_t aTime, int64_t aIgnored /* Used only for ogg which is non-MSE */) { @@ -924,17 +924,17 @@ MediaSourceReader::DoAudioSeek() if (SwitchAudioSource(&seekTime) == SOURCE_NONE) { // Data we need got evicted since the last time we checked for data // availability. Abort current seek attempt. mWaitingForSeekData = true; return; } GetAudioReader()->ResetDecode(); mAudioSeekRequest.Begin(GetAudioReader()->Seek(GetReaderAudioTime(seekTime), 0) - ->Then(GetTaskQueue(), __func__, this, + ->Then(TaskQueue(), __func__, this, &MediaSourceReader::OnAudioSeekCompleted, &MediaSourceReader::OnAudioSeekFailed)); MSE_DEBUG("reader=%p", GetAudioReader()); } void MediaSourceReader::OnAudioSeekCompleted(int64_t aTime) { @@ -996,17 +996,17 @@ MediaSourceReader::DoVideoSeek() if (SwitchVideoSource(&seekTime) == SOURCE_NONE) { // Data we need got evicted since the last time we checked for data // availability. Abort current seek attempt. mWaitingForSeekData = true; return; } GetVideoReader()->ResetDecode(); mVideoSeekRequest.Begin(GetVideoReader()->Seek(GetReaderVideoTime(seekTime), 0) - ->Then(GetTaskQueue(), __func__, this, + ->Then(TaskQueue(), __func__, this, &MediaSourceReader::OnVideoSeekCompleted, &MediaSourceReader::OnVideoSeekFailed)); MSE_DEBUG("reader=%p", GetVideoReader()); } media::TimeIntervals MediaSourceReader::GetBuffered() { @@ -1197,17 +1197,17 @@ MediaSourceReader::Ended(bool aEnded) { mDecoder->GetReentrantMonitor().AssertCurrentThreadIn(); mEnded = aEnded; if (aEnded) { // post a task to the decode queue to try to complete any pending // seek or wait RefPtr<nsIRunnable> task(NS_NewRunnableMethod( this, &MediaSourceReader::NotifyTimeRangesChanged)); - GetTaskQueue()->Dispatch(task.forget()); + TaskQueue()->Dispatch(task.forget()); } } bool MediaSourceReader::IsEnded() { ReentrantMonitorAutoEnter mon(mDecoder->GetReentrantMonitor()); return mEnded;
--- a/dom/media/mediasource/TrackBuffer.cpp +++ b/dom/media/mediasource/TrackBuffer.cpp @@ -107,29 +107,29 @@ TrackBuffer::Shutdown() mMetadataRequest.DisconnectIfExists(); MOZ_ASSERT(mShutdownPromise.IsEmpty()); nsRefPtr<ShutdownPromise> p = mShutdownPromise.Ensure(__func__); RefPtr<MediaTaskQueue> queue = mTaskQueue; mTaskQueue = nullptr; queue->BeginShutdown() - ->Then(mParentDecoder->GetReader()->GetTaskQueue(), __func__, this, + ->Then(mParentDecoder->GetReader()->TaskQueue(), __func__, this, &TrackBuffer::ContinueShutdown, &TrackBuffer::ContinueShutdown); return p; } void TrackBuffer::ContinueShutdown() { ReentrantMonitorAutoEnter mon(mParentDecoder->GetReentrantMonitor()); if (mDecoders.Length()) { mDecoders[0]->GetReader()->Shutdown() - ->Then(mParentDecoder->GetReader()->GetTaskQueue(), __func__, this, + ->Then(mParentDecoder->GetReader()->TaskQueue(), __func__, this, &TrackBuffer::ContinueShutdown, &TrackBuffer::ContinueShutdown); mShutdownDecoders.AppendElement(mDecoders[0]); mDecoders.RemoveElementAt(0); return; } MOZ_ASSERT(!mCurrentDecoder, "Detach() should have been called"); mInitializedDecoders.Clear(); @@ -269,17 +269,17 @@ TrackBuffer::AppendDataToCurrentResource } void TrackBuffer::NotifyTimeRangesChanged() { RefPtr<nsIRunnable> task = NS_NewRunnableMethod(mParentDecoder->GetReader(), &MediaSourceReader::NotifyTimeRangesChanged); - mParentDecoder->GetReader()->GetTaskQueue()->Dispatch(task.forget()); + mParentDecoder->GetReader()->TaskQueue()->Dispatch(task.forget()); } class DecoderSorter { public: bool LessThan(SourceBufferDecoder* aFirst, SourceBufferDecoder* aSecond) const { TimeIntervals first = aFirst->GetBuffered(); @@ -561,33 +561,33 @@ TrackBuffer::NewDecoder(TimeUnit aTimest ReentrantMonitorAutoEnter mon(mParentDecoder->GetReentrantMonitor()); mCurrentDecoder = decoder; mDecoders.AppendElement(decoder); mLastStartTimestamp = 0; mLastEndTimestamp.reset(); mLastTimestampOffset = aTimestampOffset; - decoder->SetTaskQueue(decoder->GetReader()->GetTaskQueue()); + decoder->SetTaskQueue(decoder->GetReader()->TaskQueue()); return decoder.forget(); } bool TrackBuffer::QueueInitializeDecoder(SourceBufferDecoder* aDecoder) { // Bug 1153295: We must ensure that the nsIRunnable hold a strong reference // to aDecoder. static_assert(mozilla::IsBaseOf<nsISupports, SourceBufferDecoder>::value, "SourceBufferDecoder must be inheriting from nsISupports"); RefPtr<nsIRunnable> task = NS_NewRunnableMethodWithArg<SourceBufferDecoder*>(this, &TrackBuffer::InitializeDecoder, aDecoder); // We need to initialize the reader on its own task queue - aDecoder->GetReader()->GetTaskQueue()->Dispatch(task.forget()); + aDecoder->GetReader()->TaskQueue()->Dispatch(task.forget()); return true; } // MetadataRecipient is a is used to pass extra values required by the // MetadataPromise's target methods class MetadataRecipient { public: NS_INLINE_DECL_THREADSAFE_REFCOUNTING(MetadataRecipient); @@ -641,17 +641,17 @@ TrackBuffer::InitializeDecoder(SourceBuf // to check for this each time we acquire the monitor. If that happens, we // need to abort immediately, because the reader has forgotten about us, and // important pieces of our state (like mTaskQueue) have also been torn down. if (mShutdown) { MSE_DEBUG("was shut down. Aborting initialization."); return; } - MOZ_ASSERT(aDecoder->GetReader()->GetTaskQueue()->IsCurrentThreadIn()); + MOZ_ASSERT(aDecoder->GetReader()->OnTaskQueue()); MediaDecoderReader* reader = aDecoder->GetReader(); MSE_DEBUG("Initializing subdecoder %p reader %p", aDecoder, reader); // HACK WARNING: // We only reach this point once we know that we have a complete init segment. @@ -676,28 +676,28 @@ TrackBuffer::InitializeDecoder(SourceBuf MSE_DEBUG("was shut down while reading metadata. Aborting initialization."); return; } if (mCurrentDecoder != aDecoder) { MSE_DEBUG("append was cancelled. Aborting initialization."); return; } - mMetadataRequest.Begin(promise->Then(reader->GetTaskQueue(), __func__, + mMetadataRequest.Begin(promise->Then(reader->TaskQueue(), __func__, recipient.get(), &MetadataRecipient::OnMetadataRead, &MetadataRecipient::OnMetadataNotRead)); } void TrackBuffer::OnMetadataRead(MetadataHolder* aMetadata, SourceBufferDecoder* aDecoder, bool aWasEnded) { - MOZ_ASSERT(aDecoder->GetReader()->GetTaskQueue()->IsCurrentThreadIn()); + MOZ_ASSERT(aDecoder->GetReader()->OnTaskQueue()); mParentDecoder->GetReentrantMonitor().AssertNotCurrentThreadIn(); ReentrantMonitorAutoEnter mon(mParentDecoder->GetReentrantMonitor()); mMetadataRequest.Complete(); if (mShutdown) { MSE_DEBUG("was shut down while reading metadata. Aborting initialization."); @@ -747,17 +747,17 @@ TrackBuffer::OnMetadataRead(MetadataHold return; } } void TrackBuffer::OnMetadataNotRead(ReadMetadataFailureReason aReason, SourceBufferDecoder* aDecoder) { - MOZ_ASSERT(aDecoder->GetReader()->GetTaskQueue()->IsCurrentThreadIn()); + MOZ_ASSERT(aDecoder->GetReader()->TaskQueue()->IsCurrentThreadIn()); mParentDecoder->GetReentrantMonitor().AssertNotCurrentThreadIn(); ReentrantMonitorAutoEnter mon(mParentDecoder->GetReentrantMonitor()); mMetadataRequest.Complete(); if (mShutdown) { MSE_DEBUG("was shut down while reading metadata. Aborting initialization."); @@ -1068,17 +1068,17 @@ TrackBuffer::RemoveDecoder(SourceBufferD { ReentrantMonitorAutoEnter mon(mParentDecoder->GetReentrantMonitor()); // There should be no other references to the decoder. Assert that // we aren't using it in the MediaSourceReader. MOZ_ASSERT(!mParentDecoder->IsActiveReader(aDecoder->GetReader())); mInitializedDecoders.RemoveElement(aDecoder); mDecoders.RemoveElement(aDecoder); } - aDecoder->GetReader()->GetTaskQueue()->Dispatch(task.forget()); + aDecoder->GetReader()->TaskQueue()->Dispatch(task.forget()); } bool TrackBuffer::RangeRemoval(TimeUnit aStart, TimeUnit aEnd) { MOZ_ASSERT(NS_IsMainThread()); ReentrantMonitorAutoEnter mon(mParentDecoder->GetReentrantMonitor());
--- a/dom/media/omx/MediaCodecReader.cpp +++ b/dom/media/omx/MediaCodecReader.cpp @@ -335,32 +335,32 @@ MediaCodecReader::DispatchVideoTask(int6 aTimeThreshold); mVideoTrack.mTaskQueue->Dispatch(task.forget()); } } nsRefPtr<MediaDecoderReader::AudioDataPromise> MediaCodecReader::RequestAudioData() { - MOZ_ASSERT(GetTaskQueue()->IsCurrentThreadIn()); + MOZ_ASSERT(OnTaskQueue()); MOZ_ASSERT(HasAudio()); MonitorAutoLock al(mAudioTrack.mTrackMonitor); if (CheckAudioResources()) { DispatchAudioTask(); } MOZ_ASSERT(mAudioTrack.mAudioPromise.IsEmpty()); return mAudioTrack.mAudioPromise.Ensure(__func__); } nsRefPtr<MediaDecoderReader::VideoDataPromise> MediaCodecReader::RequestVideoData(bool aSkipToNextKeyframe, int64_t aTimeThreshold) { - MOZ_ASSERT(GetTaskQueue()->IsCurrentThreadIn()); + MOZ_ASSERT(OnTaskQueue()); MOZ_ASSERT(HasVideo()); int64_t threshold = sInvalidTimestampUs; if (aSkipToNextKeyframe && IsValidTimestampUs(aTimeThreshold)) { threshold = aTimeThreshold; } MonitorAutoLock al(mVideoTrack.mTrackMonitor); @@ -654,17 +654,17 @@ MediaCodecReader::AsyncReadMetadata() return MediaDecoderReader::MetadataPromise::CreateAndReject( ReadMetadataFailureReason::METADATA_ERROR, __func__); } nsRefPtr<MediaDecoderReader::MetadataPromise> p = mMetadataPromise.Ensure(__func__); nsRefPtr<MediaCodecReader> self = this; mMediaResourceRequest.Begin(CreateMediaCodecs() - ->Then(GetTaskQueue(), __func__, + ->Then(TaskQueue(), __func__, [self] (bool) -> void { self->mMediaResourceRequest.Complete(); self->HandleResourceAllocated(); }, [self] (bool) -> void { self->mMediaResourceRequest.Complete(); self->mMetadataPromise.Reject(ReadMetadataFailureReason::METADATA_ERROR, __func__); }));
--- a/dom/media/omx/MediaOmxReader.cpp +++ b/dom/media/omx/MediaOmxReader.cpp @@ -247,17 +247,17 @@ MediaOmxReader::AsyncReadMetadata() mMP3FrameParser.SetLength(mDecoder->GetResource()->GetLength()); ProcessCachedData(0, true); } nsRefPtr<MediaDecoderReader::MetadataPromise> p = mMetadataPromise.Ensure(__func__); nsRefPtr<MediaOmxReader> self = this; mMediaResourceRequest.Begin(mOmxDecoder->AllocateMediaResources() - ->Then(GetTaskQueue(), __func__, + ->Then(TaskQueue(), __func__, [self] (bool) -> void { self->mMediaResourceRequest.Complete(); self->HandleResourceAllocated(); }, [self] (bool) -> void { self->mMediaResourceRequest.Complete(); self->mMetadataPromise.Reject(ReadMetadataFailureReason::METADATA_ERROR, __func__); }));
--- a/dom/media/webaudio/MediaBufferDecoder.cpp +++ b/dom/media/webaudio/MediaBufferDecoder.cpp @@ -240,24 +240,24 @@ private: SpeexResamplerState* mResampler; }; void MediaDecodeTask::Decode() { MOZ_ASSERT(!NS_IsMainThread()); - mBufferDecoder->BeginDecoding(mDecoderReader->GetTaskQueue()); + mBufferDecoder->BeginDecoding(mDecoderReader->TaskQueue()); // Tell the decoder reader that we are not going to play the data directly, // and that we should not reject files with more channels than the audio // backend support. mDecoderReader->SetIgnoreAudioOutputFormat(); - mDecoderReader->AsyncReadMetadata()->Then(mDecoderReader->GetTaskQueue(), __func__, this, + mDecoderReader->AsyncReadMetadata()->Then(mDecoderReader->TaskQueue(), __func__, this, &MediaDecodeTask::OnMetadataRead, &MediaDecodeTask::OnMetadataNotRead); } void MediaDecodeTask::OnMetadataRead(MetadataHolder* aMetadata) { mMediaInfo = aMetadata->mInfo; @@ -276,17 +276,17 @@ MediaDecodeTask::OnMetadataNotRead(ReadM mDecoderReader->Shutdown(); ReportFailureOnMainThread(WebAudioDecodeJob::InvalidContent); return; } void MediaDecodeTask::RequestSample() { - mDecoderReader->RequestAudioData()->Then(mDecoderReader->GetTaskQueue(), __func__, this, + mDecoderReader->RequestAudioData()->Then(mDecoderReader->TaskQueue(), __func__, this, &MediaDecodeTask::SampleDecoded, &MediaDecodeTask::SampleNotDecoded); } void MediaDecodeTask::SampleDecoded(AudioData* aData) { MOZ_ASSERT(!NS_IsMainThread()); @@ -499,20 +499,20 @@ AsyncDecodeWebAudio(const char* aContent if (!task->CreateReader()) { nsCOMPtr<nsIRunnable> event = new ReportResultTask(aDecodeJob, &WebAudioDecodeJob::OnFailure, WebAudioDecodeJob::UnknownError); NS_DispatchToMainThread(event); } else { // If we did this without a temporary: - // task->Reader()->GetTaskQueue()->Dispatch(task.forget()) + // task->Reader()->TaskQueue()->Dispatch(task.forget()) // we might evaluate the task.forget() before calling Reader(). Enforce // a non-crashy order-of-operations. - MediaTaskQueue* taskQueue = task->Reader()->GetTaskQueue(); + MediaTaskQueue* taskQueue = task->Reader()->TaskQueue(); taskQueue->Dispatch(task.forget()); } } WebAudioDecodeJob::WebAudioDecodeJob(const nsACString& aContentType, AudioContext* aContext, Promise* aPromise, DecodeSuccessCallback* aSuccessCallback,