Bug 1248909: [MSE] P2. Simplify diagnostic. r?gerald
Also, an assert could have been incorrectly triggered should eviction occurred on another source buffer while data was being appended on another.
MozReview-Commit-ID: 6gVHZdbL07B
--- a/dom/media/mediasource/TrackBuffersManager.cpp
+++ b/dom/media/mediasource/TrackBuffersManager.cpp
@@ -99,17 +99,16 @@ TrackBuffersManager::TrackBuffersManager
, mTaskQueue(aParentDecoder->GetDemuxer()->GetTaskQueue())
, mSourceBufferAttributes(aAttributes)
, mParentDecoder(new nsMainThreadPtrHolder<MediaSourceDecoder>(aParentDecoder, false /* strict */))
, mEvictionThreshold(Preferences::GetUint("media.mediasource.eviction_threshold",
100 * (1 << 20)))
, mEvictionOccurred(false)
, mMonitor("TrackBuffersManager")
, mAppendRunning(false)
- , mSegmentParserLoopRunning(false)
{
MOZ_ASSERT(NS_IsMainThread(), "Must be instanciated on the main thread");
}
TrackBuffersManager::~TrackBuffersManager()
{
ShutdownDemuxers();
}
@@ -296,17 +295,17 @@ TrackBuffersManager::Detach()
MOZ_ASSERT(NS_IsMainThread());
MSE_DEBUG("");
}
void
TrackBuffersManager::CompleteResetParserState()
{
MOZ_ASSERT(OnTaskQueue());
- MOZ_DIAGNOSTIC_ASSERT(!mSegmentParserLoopRunning);
+ MOZ_DIAGNOSTIC_ASSERT(!mAppendRunning, "Append is running");
MSE_DEBUG("");
for (auto& track : GetTracksList()) {
// 2. Unset the last decode timestamp on all track buffers.
// 3. Unset the last frame duration on all track buffers.
// 4. Unset the highest end timestamp on all track buffers.
// 5. Set the need random access point flag on all track buffers to true.
track->ResetAppendState();
@@ -424,25 +423,25 @@ TrackBuffersManager::DoEvictData(const T
TimeUnit::FromInfinity()));
}
}
RefPtr<TrackBuffersManager::RangeRemovalPromise>
TrackBuffersManager::CodedFrameRemovalWithPromise(TimeInterval aInterval)
{
MOZ_ASSERT(OnTaskQueue());
+ MOZ_DIAGNOSTIC_ASSERT(!mAppendRunning, "Logic error: Append in progress");
bool rv = CodedFrameRemoval(aInterval);
return RangeRemovalPromise::CreateAndResolve(rv, __func__);
}
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());
#if DEBUG
if (HasVideo()) {
MSE_DEBUG("before video ranges=%s",
DumpTimeRanges(mVideoTracks.mBufferedRanges).get());
}
@@ -571,18 +570,16 @@ TrackBuffersManager::AppendIncomingBuffe
TimeUnit::FromSeconds(mSourceBufferAttributes->GetAppendWindowEnd()));
}
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()) {
NeedMoreData();
return;
}
// 2. If the input buffer contains bytes that violate the SourceBuffer
// byte stream format specification, then run the append error algorithm with
@@ -697,31 +694,29 @@ TrackBuffersManager::SegmentParserLoop()
}
void
TrackBuffersManager::NeedMoreData()
{
MSE_DEBUG("");
RestoreCachedVariables();
mAppendRunning = false;
- mSegmentParserLoopRunning = false;
{
// Wake-up any pending Abort()
MonitorAutoLock mon(mMonitor);
mon.NotifyAll();
}
mAppendPromise.ResolveIfExists(mActiveTrack, __func__);
}
void
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);
}
--- a/dom/media/mediasource/TrackBuffersManager.h
+++ b/dom/media/mediasource/TrackBuffersManager.h
@@ -345,21 +345,18 @@ private:
// Global size of this source buffer content.
Atomic<int64_t> mSizeSourceBuffer;
uint32_t mEvictionThreshold;
Atomic<bool> mEvictionOccurred;
// Monitor to protect following objects accessed across multipple 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<bool> 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.
media::TimeIntervals mVideoBufferedRanges;
media::TimeIntervals mAudioBufferedRanges;
media::TimeUnit mOfficialGroupEndTimestamp;
// MediaInfo of the first init segment read.
MediaInfo mInfo;
};