diff --git a/dom/media/MediaStreamGraph.cpp b/dom/media/MediaStreamGraph.cpp index ccafd9506602..6e51d5d52736 100644 --- a/dom/media/MediaStreamGraph.cpp +++ b/dom/media/MediaStreamGraph.cpp @@ -914,13 +914,29 @@ MediaStreamGraphImpl::RecomputeBlockingAt(const nsTArray& aStreams GraphTime aEndBlockingDecisions, GraphTime* aEnd) { - for (uint32_t i = 0; i < aStreams.Length(); ++i) { - MediaStream* stream = aStreams[i]; - stream->mBlockInThisPhase = false; - } + class MOZ_STACK_CLASS AfterLoop + { + public: + AfterLoop(MediaStream* aStream, GraphTime& aTime) + : mStream(aStream) + , mTime(aTime) + {} + + ~AfterLoop() + { + mStream->mBlocked.SetAtAndAfter(mTime, mStream->mBlockInThisPhase); + } + + private: + MediaStream* mStream; + GraphTime& mTime; + }; for (uint32_t i = 0; i < aStreams.Length(); ++i) { MediaStream* stream = aStreams[i]; + stream->mBlockInThisPhase = false; + + AfterLoop al(stream, aTime); if (stream->mFinished) { GraphTime endTime = StreamTimeToGraphTime(stream, @@ -956,12 +972,8 @@ MediaStreamGraphImpl::RecomputeBlockingAt(const nsTArray& aStreams continue; } } - NS_ASSERTION(*aEnd > aTime, "Failed to advance!"); - for (uint32_t i = 0; i < aStreams.Length(); ++i) { - MediaStream* stream = aStreams[i]; - stream->mBlocked.SetAtAndAfter(aTime, stream->mBlockInThisPhase); - } + NS_ASSERTION(*aEnd > aTime, "Failed to advance!"); } void