Skip to content

Commit

Permalink
Bug 1163597 - MediaStreamGraphImpl::RecomputeBlockingAt: optimization…
Browse files Browse the repository at this point in the history
… in the number of loops for the mStreams array, r=padenot
  • Loading branch information
bakulf committed May 11, 2015
1 parent c11b7f4 commit 17d5829
Showing 1 changed file with 20 additions and 8 deletions.
28 changes: 20 additions & 8 deletions dom/media/MediaStreamGraph.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -914,13 +914,29 @@ MediaStreamGraphImpl::RecomputeBlockingAt(const nsTArray<MediaStream*>& aStreams
GraphTime aEndBlockingDecisions,
GraphTime* aEnd)
{
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;
}

for (uint32_t i = 0; i < aStreams.Length(); ++i) {
MediaStream* stream = aStreams[i];
AfterLoop al(stream, aTime);

if (stream->mFinished) {
GraphTime endTime = StreamTimeToGraphTime(stream,
Expand Down Expand Up @@ -956,12 +972,8 @@ MediaStreamGraphImpl::RecomputeBlockingAt(const nsTArray<MediaStream*>& 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
Expand Down

0 comments on commit 17d5829

Please sign in to comment.