From a293a8fc65bd7c9c1421e5cb00d959fba526bbd5 Mon Sep 17 00:00:00 2001 From: trav90 Date: Thu, 4 Jan 2018 14:33:26 -0600 Subject: [MSE] Do not attempt to retrieve the buffered range if the mediasource is in closed state. The commits that follow may cause the active sourcebuffer list to be modified; which will trigger an assertion if the mediasource object is closed. --- dom/media/mediasource/MediaSourceDecoder.cpp | 6 ++++++ 1 file changed, 6 insertions(+) (limited to 'dom') diff --git a/dom/media/mediasource/MediaSourceDecoder.cpp b/dom/media/mediasource/MediaSourceDecoder.cpp index 98fc77990..db3cf3f44 100644 --- a/dom/media/mediasource/MediaSourceDecoder.cpp +++ b/dom/media/mediasource/MediaSourceDecoder.cpp @@ -299,6 +299,12 @@ MediaDecoderOwner::NextFrameStatus MediaSourceDecoder::NextFrameBufferedStatus() { MOZ_ASSERT(NS_IsMainThread()); + + if (!mMediaSource || + mMediaSource->ReadyState() == dom::MediaSourceReadyState::Closed) { + return MediaDecoderOwner::NEXT_FRAME_UNAVAILABLE; + } + // Next frame hasn't been decoded yet. // Use the buffered range to consider if we have the next frame available. TimeUnit currentPosition = TimeUnit::FromMicroseconds(CurrentPosition()); -- cgit v1.2.3 From 5f844308f4d1e5b56afbb1d6046095dfb4686403 Mon Sep 17 00:00:00 2001 From: trav90 Date: Thu, 4 Jan 2018 14:42:23 -0600 Subject: [MSE] Disable tail dispatching on the MediaSourceDemuxer's TaskQueue This allows us to perform synchronous operation on the main thread. --- dom/media/mediasource/MediaSourceDemuxer.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'dom') diff --git a/dom/media/mediasource/MediaSourceDemuxer.cpp b/dom/media/mediasource/MediaSourceDemuxer.cpp index ec9323db9..768308e5d 100644 --- a/dom/media/mediasource/MediaSourceDemuxer.cpp +++ b/dom/media/mediasource/MediaSourceDemuxer.cpp @@ -19,7 +19,7 @@ using media::TimeIntervals; MediaSourceDemuxer::MediaSourceDemuxer() : mTaskQueue(new MediaTaskQueue(GetMediaThreadPool(MediaThreadType::PLAYBACK), - /* aSupportsTailDispatch = */ true)) + /* aSupportsTailDispatch = */ false)) , mMonitor("MediaSourceDemuxer") { MOZ_ASSERT(NS_IsMainThread()); -- cgit v1.2.3 From 6a51b3f47e3b626027f7097a22d1c2ce4b81db0e Mon Sep 17 00:00:00 2001 From: trav90 Date: Thu, 4 Jan 2018 14:58:34 -0600 Subject: [MSE] When abort() is called, wait until the current appendBuffer completes The W3C spec indicates that while everything in MSE is asynchronous, the abort() command is to interrupt the current segment parser loop and have the reset parser loop synchronously completes the frames present in the input buffer. This causes a fundamental issue that abort() will never result in a deterministic outcome as the segment parser loop may be in different condition. We used to really attempt to abort the current operation, however there could have been a race in the order in which tasks were queued. As such, we now simply wait for the current appendBuffer to complete. This also simplifies the code greatly, as we don't need to worry about pending concurrent appendBuffer. We also will now strongly assert should a segment parser loop be running when it must have completed. --- dom/media/mediasource/SourceBuffer.cpp | 74 ++++----------- dom/media/mediasource/SourceBuffer.h | 8 +- dom/media/mediasource/SourceBufferContentManager.h | 4 - dom/media/mediasource/TrackBuffersManager.cpp | 101 ++++++++------------- dom/media/mediasource/TrackBuffersManager.h | 12 +-- 5 files changed, 62 insertions(+), 137 deletions(-) (limited to 'dom') diff --git a/dom/media/mediasource/SourceBuffer.cpp b/dom/media/mediasource/SourceBuffer.cpp index 30b98c0b4..5c063db03 100644 --- a/dom/media/mediasource/SourceBuffer.cpp +++ b/dom/media/mediasource/SourceBuffer.cpp @@ -43,27 +43,6 @@ namespace mozilla { namespace dom { -class BufferAppendRunnable : public nsRunnable { -public: - BufferAppendRunnable(SourceBuffer* aSourceBuffer, - uint32_t aUpdateID) - : mSourceBuffer(aSourceBuffer) - , mUpdateID(aUpdateID) - { - } - - NS_IMETHOD Run() override final { - - mSourceBuffer->BufferAppend(mUpdateID); - - return NS_OK; - } - -private: - nsRefPtr mSourceBuffer; - uint32_t mUpdateID; -}; - void SourceBuffer::SetMode(SourceBufferAppendMode aMode, ErrorResult& aRv) { @@ -219,10 +198,13 @@ void SourceBuffer::AbortBufferAppend() { if (mUpdating) { - mPendingAppend.DisconnectIfExists(); - // TODO: Abort stream append loop algorithms. - // cancel any pending buffer append. - mContentManager->AbortAppendData(); + if (mPendingAppend.Exists()) { + mPendingAppend.Disconnect(); + mContentManager->AbortAppendData(); + // Some data may have been added by the Segment Parser Loop. + // Check if we need to update the duration. + CheckEndTime(); + } AbortUpdating(); } } @@ -303,7 +285,6 @@ SourceBuffer::SourceBuffer(MediaSource* aMediaSource, const nsACString& aType) , mMediaSource(aMediaSource) , mUpdating(false) , mActive(false) - , mUpdateID(0) , mReportedOffset(0) , mType(aType) { @@ -380,7 +361,6 @@ SourceBuffer::StartUpdating() MOZ_ASSERT(NS_IsMainThread()); MOZ_ASSERT(!mUpdating); mUpdating = true; - mUpdateID++; QueueAsyncSimpleEvent("updatestart"); } @@ -389,12 +369,8 @@ SourceBuffer::StopUpdating() { MOZ_ASSERT(NS_IsMainThread()); if (!mUpdating) { - // The buffer append algorithm has been interrupted by abort(). - // - // If the sequence appendBuffer(), abort(), appendBuffer() occurs before - // the first StopUpdating() runnable runs, then a second StopUpdating() - // runnable will be scheduled, but still only one (the first) will queue - // events. + // The buffer append or range removal algorithm has been interrupted by + // abort(). return; } mUpdating = false; @@ -406,7 +382,6 @@ void SourceBuffer::AbortUpdating() { MOZ_ASSERT(NS_IsMainThread()); - MOZ_ASSERT(mUpdating); mUpdating = false; QueueAsyncSimpleEvent("abort"); QueueAsyncSimpleEvent("updateend"); @@ -440,23 +415,14 @@ SourceBuffer::AppendData(const uint8_t* aData, uint32_t aLength, ErrorResult& aR MOZ_ASSERT(mIsUsingFormatReader || mAttributes->GetAppendMode() == SourceBufferAppendMode::Segments, "We don't handle timestampOffset for sequence mode yet"); - nsRefPtr task = new BufferAppendRunnable(this, mUpdateID); - NS_DispatchToMainThread(task); + + BufferAppend(); } void -SourceBuffer::BufferAppend(uint32_t aUpdateID) -{ - if (!mUpdating || aUpdateID != mUpdateID) { - // The buffer append algorithm has been interrupted by abort(). - // - // If the sequence appendBuffer(), abort(), appendBuffer() occurs before - // the first StopUpdating() runnable runs, then a second StopUpdating() - // runnable will be scheduled, but still only one (the first) will queue - // events. - return; - } - +SourceBuffer::BufferAppend() +{ + MOZ_ASSERT(mUpdating); MOZ_ASSERT(mMediaSource); MOZ_ASSERT(!mPendingAppend.Exists()); @@ -469,11 +435,8 @@ SourceBuffer::BufferAppend(uint32_t aUpdateID) void SourceBuffer::AppendDataCompletedWithSuccess(bool aHasActiveTracks) { + MOZ_ASSERT(mUpdating); mPendingAppend.Complete(); - if (!mUpdating) { - // The buffer append algorithm has been interrupted by abort(). - return; - } if (aHasActiveTracks) { if (!mActive) { @@ -502,7 +465,9 @@ SourceBuffer::AppendDataCompletedWithSuccess(bool aHasActiveTracks) void SourceBuffer::AppendDataErrored(nsresult aError) { + MOZ_ASSERT(mUpdating); mPendingAppend.Complete(); + switch (aError) { case NS_ERROR_ABORT: // Nothing further to do as the trackbuffer has been shutdown. @@ -518,10 +483,7 @@ void SourceBuffer::AppendError(bool aDecoderError) { MOZ_ASSERT(NS_IsMainThread()); - if (!mUpdating) { - // The buffer append algorithm has been interrupted by abort(). - return; - } + mContentManager->ResetParserState(); mUpdating = false; diff --git a/dom/media/mediasource/SourceBuffer.h b/dom/media/mediasource/SourceBuffer.h index fe69489c2..c61c39f93 100644 --- a/dom/media/mediasource/SourceBuffer.h +++ b/dom/media/mediasource/SourceBuffer.h @@ -247,7 +247,7 @@ private: // Shared implementation of AppendBuffer overloads. void AppendData(const uint8_t* aData, uint32_t aLength, ErrorResult& aRv); - void BufferAppend(uint32_t aAppendID); + void BufferAppend(); // Implement the "Append Error Algorithm". // Will call endOfStream() with "decode" error if aDecodeError is true. @@ -276,12 +276,6 @@ private: mozilla::Atomic mActive; - // Each time mUpdating is set to true, mUpdateID will be incremented. - // This allows for a queued AppendData task to identify if it was earlier - // aborted and another AppendData queued. - uint32_t mUpdateID; - int64_t mReportedOffset; - MediaPromiseRequestHolder mPendingAppend; const nsCString mType; }; diff --git a/dom/media/mediasource/SourceBufferContentManager.h b/dom/media/mediasource/SourceBufferContentManager.h index 66a2ca483..f7ac18594 100644 --- a/dom/media/mediasource/SourceBufferContentManager.h +++ b/dom/media/mediasource/SourceBufferContentManager.h @@ -107,10 +107,6 @@ public: virtual void RestartGroupStartTimestamp() {} virtual TimeUnit GroupEndTimestamp() = 0; -#if defined(DEBUG) - virtual void Dump(const char* aPath) { } -#endif - protected: virtual ~SourceBufferContentManager() { } }; diff --git a/dom/media/mediasource/TrackBuffersManager.cpp b/dom/media/mediasource/TrackBuffersManager.cpp index e939442d3..7cefb9519 100644 --- a/dom/media/mediasource/TrackBuffersManager.cpp +++ b/dom/media/mediasource/TrackBuffersManager.cpp @@ -55,15 +55,15 @@ TrackBuffersManager::TrackBuffersManager(dom::SourceBufferAttributes* aAttribute , mType(aType) , mParser(ContainerParser::CreateForMIMEType(aType)) , mProcessedInput(0) - , mAppendRunning(false) , mTaskQueue(aParentDecoder->GetDemuxer()->GetTaskQueue()) , mSourceBufferAttributes(aAttributes) , mParentDecoder(new nsMainThreadPtrHolder(aParentDecoder, false /* strict */)) - , mAbort(false) , mEvictionThreshold(Preferences::GetUint("media.mediasource.eviction_threshold", 100 * (1 << 20))) , mEvictionOccurred(false) , mMonitor("TrackBuffersManager") + , mAppendRunning(false) + , mSegmentParserLoopRunning(false) { MOZ_ASSERT(NS_IsMainThread(), "Must be instantiated on the main thread"); } @@ -94,7 +94,6 @@ TrackBuffersManager::AppendIncomingBuffer(IncomingBuffer aData) { MOZ_ASSERT(OnTaskQueue()); mIncomingBuffers.AppendElement(aData); - mAbort = false; } nsRefPtr @@ -103,32 +102,33 @@ TrackBuffersManager::BufferAppend() MOZ_ASSERT(NS_IsMainThread()); MSE_DEBUG(""); + mAppendRunning = true; return ProxyMediaCall(GetTaskQueue(), this, __func__, &TrackBuffersManager::InitSegmentParserLoop); } -// Abort any pending AppendData. -// We don't really care about really aborting our inner loop as by spec the -// process is happening asynchronously, as such where and when we would abort is -// non-deterministic. The SourceBuffer also makes sure BufferAppend -// isn't called should the appendBuffer be immediately aborted. -// We do however want to ensure that no new task will be dispatched on our task -// queue and only let the current one finish its job. For this we set mAbort -// to true. +// The MSE spec requires that we abort the current SegmentParserLoop +// which is then followed by a call to ResetParserState. +// However due to our asynchronous design this causes inherent difficulities. +// As the spec behaviour is non deterministic anyway, we instead wait until the +// current AppendData has completed its run. void TrackBuffersManager::AbortAppendData() { MOZ_ASSERT(NS_IsMainThread()); MSE_DEBUG(""); - mAbort = true; + MonitorAutoLock mon(mMonitor); + while (mAppendRunning) { + mon.Wait(); + } } void TrackBuffersManager::ResetParserState() { MOZ_ASSERT(NS_IsMainThread()); - MOZ_ASSERT(!mAppendRunning, "AbortAppendData must have been called"); + MOZ_RELEASE_ASSERT(!mAppendRunning, "Append is running, abort must have been called"); MSE_DEBUG(""); // 1. If the append state equals PARSING_MEDIA_SEGMENT and the input buffer contains some complete coded frames, then run the coded frame processing algorithm until all of these complete coded frames have been processed. @@ -154,6 +154,7 @@ nsRefPtr TrackBuffersManager::RangeRemoval(TimeUnit aStart, TimeUnit aEnd) { MOZ_ASSERT(NS_IsMainThread()); + MOZ_RELEASE_ASSERT(!mAppendRunning, "Append is running"); MSE_DEBUG("From %.2f to %.2f", aStart.ToSeconds(), aEnd.ToSeconds()); mEnded = false; @@ -264,20 +265,6 @@ TrackBuffersManager::Detach() { MOZ_ASSERT(NS_IsMainThread()); MSE_DEBUG(""); - - // Abort pending operations if any. - AbortAppendData(); - - nsRefPtr self = this; - nsCOMPtr task = - NS_NewRunnableFunction([self] () { - // Clear our sourcebuffer - self->CodedFrameRemoval(TimeInterval(TimeUnit::FromSeconds(0), - TimeUnit::FromInfinity())); - self->mProcessingPromise.RejectIfExists(NS_ERROR_ABORT, __func__); - self->mAppendPromise.RejectIfExists(NS_ERROR_ABORT, __func__); - }); - GetTaskQueue()->Dispatch(task.forget()); } #if defined(DEBUG) @@ -310,7 +297,7 @@ void TrackBuffersManager::CompleteResetParserState() { MOZ_ASSERT(OnTaskQueue()); - MOZ_ASSERT(!mAppendRunning); + MOZ_RELEASE_ASSERT(!mSegmentParserLoopRunning); MSE_DEBUG(""); for (auto& track : GetTracksList()) { @@ -446,7 +433,7 @@ bool TrackBuffersManager::CodedFrameRemoval(TimeInterval aInterval) { MOZ_ASSERT(OnTaskQueue()); - MOZ_ASSERT(!mAppendRunning, "Logic error: Append in progress"); + MOZ_ASSERT(!mSegmentParserLoopRunning, "Logic error: Append in progress"); MSE_DEBUG("From %.2fs to %.2f", aInterval.mStart.ToSeconds(), aInterval.mEnd.ToSeconds()); @@ -548,8 +535,9 @@ nsRefPtr TrackBuffersManager::InitSegmentParserLoop() { MOZ_ASSERT(OnTaskQueue()); + MOZ_RELEASE_ASSERT(mAppendPromise.IsEmpty()); + MSE_DEBUG(""); - MOZ_ASSERT(mAppendPromise.IsEmpty() && !mAppendRunning); nsRefPtr p = mAppendPromise.Ensure(__func__); AppendIncomingBuffers(); @@ -583,6 +571,9 @@ void TrackBuffersManager::SegmentParserLoop() { MOZ_ASSERT(OnTaskQueue()); + + mSegmentParserLoopRunning = true; + while (true) { // 1. If the input buffer is empty, then jump to the need more data step below. if (!mInputBuffer || mInputBuffer->IsEmpty()) { @@ -656,7 +647,7 @@ TrackBuffersManager::SegmentParserLoop() ->Then(GetTaskQueue(), __func__, [self] (bool aNeedMoreData) { self->mProcessingRequest.Complete(); - if (aNeedMoreData || self->mAbort) { + if (aNeedMoreData) { self->NeedMoreData(); } else { self->ScheduleSegmentParserLoop(); @@ -675,10 +666,14 @@ void TrackBuffersManager::NeedMoreData() { MSE_DEBUG(""); - if (!mAbort) { - RestoreCachedVariables(); - } + RestoreCachedVariables(); mAppendRunning = false; + mSegmentParserLoopRunning = false; + { + // Wake-up any pending Abort() + MonitorAutoLock mon(mMonitor); + mon.NotifyAll(); + } mAppendPromise.ResolveIfExists(mActiveTrack, __func__); } @@ -687,6 +682,12 @@ TrackBuffersManager::RejectAppend(nsresult aRejectValue, const char* aName) { MSE_DEBUG("rv=%d", aRejectValue); mAppendRunning = false; + mSegmentParserLoopRunning = false; + { + // Wake-up any pending Abort() + MonitorAutoLock mon(mMonitor); + mon.NotifyAll(); + } mAppendPromise.RejectIfExists(aRejectValue, aName); } @@ -788,14 +789,8 @@ void TrackBuffersManager::OnDemuxerInitDone(nsresult) { MOZ_ASSERT(OnTaskQueue()); - MSE_DEBUG("mAbort:%d", static_cast(mAbort)); mDemuxerInitRequest.Complete(); - if (mAbort) { - RejectAppend(NS_ERROR_ABORT, __func__); - return; - } - MediaInfo info; uint32_t numVideos = mInputDemuxer->GetNumberTracks(TrackInfo::kVideoTrack); @@ -1034,9 +1029,8 @@ TrackBuffersManager::OnDemuxFailed(TrackType aTrack, DemuxerFailureReason aFailure) { MOZ_ASSERT(OnTaskQueue()); - MSE_DEBUG("Failed to demux %s, failure:%d mAbort:%d", - aTrack == TrackType::kVideoTrack ? "video" : "audio", - aFailure, static_cast(mAbort)); + MSE_DEBUG("Failed to demux %s, failure:%d", + aTrack == TrackType::kVideoTrack ? "video" : "audio", aFailure); switch (aFailure) { case DemuxerFailureReason::END_OF_STREAM: case DemuxerFailureReason::WAITING_FOR_DATA: @@ -1063,15 +1057,10 @@ void TrackBuffersManager::DoDemuxVideo() { MOZ_ASSERT(OnTaskQueue()); - MSE_DEBUG("mAbort:%d", static_cast(mAbort)); if (!HasVideo()) { DoDemuxAudio(); return; } - if (mAbort) { - RejectProcessing(NS_ERROR_ABORT, __func__); - return; - } mVideoTracks.mDemuxRequest.Begin(mVideoTracks.mDemuxer->GetSamples(-1) ->Then(GetTaskQueue(), __func__, this, &TrackBuffersManager::OnVideoDemuxCompleted, @@ -1092,11 +1081,6 @@ void TrackBuffersManager::DoDemuxAudio() { MOZ_ASSERT(OnTaskQueue()); - MSE_DEBUG("mAbort:%d", static_cast(mAbort)); - if (mAbort) { - RejectProcessing(NS_ERROR_ABORT, __func__); - return; - } if (!HasAudio()) { CompleteCodedFrameProcessing(); return; @@ -1121,7 +1105,6 @@ void TrackBuffersManager::CompleteCodedFrameProcessing() { MOZ_ASSERT(OnTaskQueue()); - MSE_DEBUG("mAbort:%d", static_cast(mAbort)); // 1. For each coded frame in the media segment run the following steps: // Coded Frame Processing steps 1.1 to 1.21. @@ -1189,22 +1172,12 @@ TrackBuffersManager::CompleteCodedFrameProcessing() void TrackBuffersManager::RejectProcessing(nsresult aRejectValue, const char* aName) { - if (mAbort) { - // mAppendPromise will be resolved immediately upon mProcessingPromise - // completing. - mAppendRunning = false; - } mProcessingPromise.RejectIfExists(aRejectValue, __func__); } void TrackBuffersManager::ResolveProcessing(bool aResolveValue, const char* aName) { - if (mAbort) { - // mAppendPromise will be resolved immediately upon mProcessingPromise - // completing. - mAppendRunning = false; - } mProcessingPromise.ResolveIfExists(aResolveValue, __func__); } diff --git a/dom/media/mediasource/TrackBuffersManager.h b/dom/media/mediasource/TrackBuffersManager.h index 714e81403..12555d8ae 100644 --- a/dom/media/mediasource/TrackBuffersManager.h +++ b/dom/media/mediasource/TrackBuffersManager.h @@ -293,10 +293,6 @@ private: MediaPromiseHolder mProcessingPromise; MediaPromiseHolder mAppendPromise; - // Set to true while SegmentParserLoop is running. This is used for diagnostic - // purposes only. We can't rely on mAppendPromise to be empty as it is only - // cleared in a follow up task. - bool mAppendRunning; // Trackbuffers definition. nsTArray GetTracksList(); @@ -332,8 +328,6 @@ private: nsRefPtr mSourceBufferAttributes; nsMainThreadPtrHandle mParentDecoder; - // Set to true if abort is called. - Atomic mAbort; // Set to true if mediasource state changed to ended. Atomic mEnded; @@ -343,7 +337,13 @@ private: Atomic mEvictionOccurred; // Monitor to protect following objects accessed across multiple threads. + // mMonitor is also notified if the value of mAppendRunning becomes false. mutable Monitor mMonitor; + // Set to true while SegmentParserLoop is running. + Atomic mAppendRunning; + // Set to true while SegmentParserLoop is running. + // This is for diagnostic only. Only accessed on the task queue. + bool mSegmentParserLoopRunning; // Stable audio and video track time ranges. TimeIntervals mVideoBufferedRanges; TimeIntervals mAudioBufferedRanges; -- cgit v1.2.3 From ec196f247e5a4d3290792ce70fa04043104205a0 Mon Sep 17 00:00:00 2001 From: trav90 Date: Thu, 4 Jan 2018 16:20:58 -0600 Subject: [MSE] Remove now unused code --- dom/media/mediasource/TrackBuffersManager.cpp | 36 ++++----------------------- dom/media/mediasource/TrackBuffersManager.h | 4 +-- 2 files changed, 6 insertions(+), 34 deletions(-) (limited to 'dom') diff --git a/dom/media/mediasource/TrackBuffersManager.cpp b/dom/media/mediasource/TrackBuffersManager.cpp index 7cefb9519..ea131c4cd 100644 --- a/dom/media/mediasource/TrackBuffersManager.cpp +++ b/dom/media/mediasource/TrackBuffersManager.cpp @@ -132,20 +132,12 @@ TrackBuffersManager::ResetParserState() MSE_DEBUG(""); // 1. If the append state equals PARSING_MEDIA_SEGMENT and the input buffer contains some complete coded frames, then run the coded frame processing algorithm until all of these complete coded frames have been processed. - if (mAppendState == AppendState::PARSING_MEDIA_SEGMENT) { - nsCOMPtr task = - NS_NewRunnableMethod(this, &TrackBuffersManager::FinishCodedFrameProcessing); - GetTaskQueue()->Dispatch(task.forget()); - } else { - nsCOMPtr task = - NS_NewRunnableMethod(this, &TrackBuffersManager::CompleteResetParserState); - GetTaskQueue()->Dispatch(task.forget()); - } + // SourceBuffer.abort() has ensured that all complete coded frames have been + // processed. As such, we don't need to check for the value of mAppendState. + nsCOMPtr task = + NS_NewRunnableMethod(this, &TrackBuffersManager::CompleteResetParserState); + GetTaskQueue()->Dispatch(task.forget()); - // Our ResetParserState is really asynchronous, the current task has been - // interrupted and will complete shortly (or has already completed). - // We must however present to the main thread a stable, reset state. - // So we run the following operation now in the main thread. // 7. Set append state to WAITING_FOR_SEGMENT. SetAppendState(AppendState::WAITING_FOR_SEGMENT); } @@ -275,24 +267,6 @@ TrackBuffersManager::Dump(const char* aPath) } #endif -void -TrackBuffersManager::FinishCodedFrameProcessing() -{ - MOZ_ASSERT(OnTaskQueue()); - - if (mProcessingRequest.Exists()) { - NS_WARNING("Processing request pending"); - mProcessingRequest.Disconnect(); - } - // The spec requires us to complete parsing synchronously any outstanding - // frames in the current media segment. This can't be implemented in a way - // that makes sense. - // As such we simply completely ignore the result of any pending input buffer. - // TODO: Link to W3C bug. - - CompleteResetParserState(); -} - void TrackBuffersManager::CompleteResetParserState() { diff --git a/dom/media/mediasource/TrackBuffersManager.h b/dom/media/mediasource/TrackBuffersManager.h index 12555d8ae..a476eea8a 100644 --- a/dom/media/mediasource/TrackBuffersManager.h +++ b/dom/media/mediasource/TrackBuffersManager.h @@ -120,9 +120,7 @@ private: // media segment have been processed. nsRefPtr CodedFrameProcessing(); void CompleteCodedFrameProcessing(); - // Called by ResetParserState. Complete parsing the input buffer for the - // current media segment. - void FinishCodedFrameProcessing(); + // Called by ResetParserState. void CompleteResetParserState(); nsRefPtr CodedFrameRemovalWithPromise(TimeInterval aInterval); -- cgit v1.2.3 From 5af332210907061389d41c2db03bb790e5524c03 Mon Sep 17 00:00:00 2001 From: trav90 Date: Thu, 4 Jan 2018 16:30:46 -0600 Subject: [MSE] Remove some undesired Mozilla diagnostic code --- dom/media/mediasource/TrackBuffersManager.cpp | 7 ------- dom/media/mediasource/TrackBuffersManager.h | 5 +---- 2 files changed, 1 insertion(+), 11 deletions(-) (limited to 'dom') diff --git a/dom/media/mediasource/TrackBuffersManager.cpp b/dom/media/mediasource/TrackBuffersManager.cpp index ea131c4cd..fb57a4506 100644 --- a/dom/media/mediasource/TrackBuffersManager.cpp +++ b/dom/media/mediasource/TrackBuffersManager.cpp @@ -63,7 +63,6 @@ TrackBuffersManager::TrackBuffersManager(dom::SourceBufferAttributes* aAttribute , mEvictionOccurred(false) , mMonitor("TrackBuffersManager") , mAppendRunning(false) - , mSegmentParserLoopRunning(false) { MOZ_ASSERT(NS_IsMainThread(), "Must be instantiated on the main thread"); } @@ -271,7 +270,6 @@ void TrackBuffersManager::CompleteResetParserState() { MOZ_ASSERT(OnTaskQueue()); - MOZ_RELEASE_ASSERT(!mSegmentParserLoopRunning); MSE_DEBUG(""); for (auto& track : GetTracksList()) { @@ -407,7 +405,6 @@ bool TrackBuffersManager::CodedFrameRemoval(TimeInterval aInterval) { MOZ_ASSERT(OnTaskQueue()); - MOZ_ASSERT(!mSegmentParserLoopRunning, "Logic error: Append in progress"); MSE_DEBUG("From %.2fs to %.2f", aInterval.mStart.ToSeconds(), aInterval.mEnd.ToSeconds()); @@ -546,8 +543,6 @@ TrackBuffersManager::SegmentParserLoop() { MOZ_ASSERT(OnTaskQueue()); - mSegmentParserLoopRunning = true; - while (true) { // 1. If the input buffer is empty, then jump to the need more data step below. if (!mInputBuffer || mInputBuffer->IsEmpty()) { @@ -642,7 +637,6 @@ TrackBuffersManager::NeedMoreData() MSE_DEBUG(""); RestoreCachedVariables(); mAppendRunning = false; - mSegmentParserLoopRunning = false; { // Wake-up any pending Abort() MonitorAutoLock mon(mMonitor); @@ -656,7 +650,6 @@ TrackBuffersManager::RejectAppend(nsresult aRejectValue, const char* aName) { MSE_DEBUG("rv=%d", aRejectValue); mAppendRunning = false; - mSegmentParserLoopRunning = false; { // Wake-up any pending Abort() MonitorAutoLock mon(mMonitor); diff --git a/dom/media/mediasource/TrackBuffersManager.h b/dom/media/mediasource/TrackBuffersManager.h index a476eea8a..2def2b02a 100644 --- a/dom/media/mediasource/TrackBuffersManager.h +++ b/dom/media/mediasource/TrackBuffersManager.h @@ -337,11 +337,8 @@ private: // Monitor to protect following objects accessed across multiple threads. // mMonitor is also notified if the value of mAppendRunning becomes false. mutable Monitor mMonitor; - // Set to true while SegmentParserLoop is running. + // Set to true while a BufferAppend is running or is pending. Atomic mAppendRunning; - // Set to true while SegmentParserLoop is running. - // This is for diagnostic only. Only accessed on the task queue. - bool mSegmentParserLoopRunning; // Stable audio and video track time ranges. TimeIntervals mVideoBufferedRanges; TimeIntervals mAudioBufferedRanges; -- cgit v1.2.3 From 14e7b04469304996f92e642101206c54ed930b25 Mon Sep 17 00:00:00 2001 From: trav90 Date: Fri, 5 Jan 2018 09:10:59 -0600 Subject: Fix build bustage --- dom/media/mediasource/SourceBuffer.h | 2 ++ 1 file changed, 2 insertions(+) (limited to 'dom') diff --git a/dom/media/mediasource/SourceBuffer.h b/dom/media/mediasource/SourceBuffer.h index c61c39f93..f856d72a2 100644 --- a/dom/media/mediasource/SourceBuffer.h +++ b/dom/media/mediasource/SourceBuffer.h @@ -276,6 +276,8 @@ private: mozilla::Atomic mActive; + int64_t mReportedOffset; + MediaPromiseRequestHolder mPendingAppend; const nsCString mType; }; -- cgit v1.2.3