Bug 1163585 - Small improvement of the use of nsTArray in MSG::UpdateCurrentTimeForStreams, r=padenot

This commit is contained in:
Andrea Marchesini 2015-05-11 15:06:44 +01:00
Родитель 0a3702094f
Коммит 097cbfb77f
1 изменённых файлов: 10 добавлений и 12 удалений

Просмотреть файл

@ -400,15 +400,13 @@ MediaStreamGraphImpl::IterationEnd()
void
MediaStreamGraphImpl::UpdateCurrentTimeForStreams(GraphTime aPrevCurrentTime, GraphTime aNextCurrentTime)
{
nsTArray<MediaStream*> streamsReadyToFinish;
nsAutoTArray<bool,800> streamHasOutput;
nsAutoTArray<MediaStream*, 800> streamsReadyToFinish;
nsAutoTArray<MediaStream*, 800> streamsWithOutput;
nsTArray<MediaStream*>* runningAndSuspendedPair[2];
runningAndSuspendedPair[0] = &mStreams;
runningAndSuspendedPair[1] = &mSuspendedStreams;
streamHasOutput.SetLength(mStreams.Length());
for (uint32_t array = 0; array < 2; array++) {
for (uint32_t i = 0; i < runningAndSuspendedPair[array]->Length(); ++i) {
MediaStream* stream = (*runningAndSuspendedPair[array])[i];
@ -445,12 +443,16 @@ MediaStreamGraphImpl::UpdateCurrentTimeForStreams(GraphTime aPrevCurrentTime, Gr
stream->mBlocked.AdvanceCurrentTime(aNextCurrentTime);
if (runningAndSuspendedPair[array] == &mStreams) {
streamHasOutput[i] = blockedTime < aNextCurrentTime - aPrevCurrentTime;
bool streamHasOutput = blockedTime < aNextCurrentTime - aPrevCurrentTime;
// Make this an assertion when bug 957832 is fixed.
NS_WARN_IF_FALSE(
!streamHasOutput[i] || !stream->mNotifiedFinished,
!streamHasOutput || !stream->mNotifiedFinished,
"Shouldn't have already notified of finish *and* have output!");
if (streamHasOutput) {
streamsWithOutput.AppendElement(stream);
}
if (stream->mFinished && !stream->mNotifiedFinished) {
streamsReadyToFinish.AppendElement(stream);
}
@ -462,12 +464,8 @@ MediaStreamGraphImpl::UpdateCurrentTimeForStreams(GraphTime aPrevCurrentTime, Gr
}
}
for (uint32_t i = 0; i < streamHasOutput.Length(); ++i) {
if (!streamHasOutput[i]) {
continue;
}
MediaStream* stream = mStreams[i];
for (uint32_t i = 0; i < streamsWithOutput.Length(); ++i) {
MediaStream* stream = streamsWithOutput[i];
for (uint32_t j = 0; j < stream->mListeners.Length(); ++j) {
MediaStreamListener* l = stream->mListeners[j];
l->NotifyOutput(this, IterationEnd());