Bug 1163597 - MediaStreamGraphImpl::RecomputeBlockingAt: optimization in the number of loops for the mStreams array, r=padenot

This commit is contained in:
Andrea Marchesini 2015-05-11 18:50:55 +01:00
parent e3861219bd
commit 6395e487c2

View File

@ -914,13 +914,29 @@ MediaStreamGraphImpl::RecomputeBlockingAt(const nsTArray<MediaStream*>& 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<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