Bug 1194518 - Part 5: Using std::deque instead of nsTArray to store delayed frames. r=jya

--HG--
extra : histedit_source : de2ea03ed86f397cd22af57712c0cac2b059dd25
This commit is contained in:
Gerald Squelart 2015-08-26 18:50:00 -04:00
Родитель 653149094c
Коммит 6d3ff1e50e
2 изменённых файлов: 16 добавлений и 14 удалений

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

@ -147,16 +147,16 @@ DecoderCallbackFuzzingWrapper::Output(MediaData* aData)
MOZ_ASSERT(mCallback);
if (mFrameOutputMinimumInterval) {
if (!mPreviousOutput.IsNull()) {
if (!mDelayedOutput.IsEmpty()) {
if (!mDelayedOutput.empty()) {
// We already have some delayed frames, just add this one to the queue.
mDelayedOutput.AppendElement(MakePair<nsRefPtr<MediaData>, bool>(aData, false));
mDelayedOutput.push_back(MakePair<nsRefPtr<MediaData>, bool>(aData, false));
CFW_LOGD("delaying output of sample@%lld, total queued:%d",
aData->mTime, int(mDelayedOutput.Length()));
aData->mTime, int(mDelayedOutput.size()));
return;
}
if (TimeStamp::Now() < mPreviousOutput + mFrameOutputMinimumInterval) {
// Frame arriving too soon after the previous one, start queuing.
mDelayedOutput.AppendElement(MakePair<nsRefPtr<MediaData>, bool>(aData, false));
mDelayedOutput.push_back(MakePair<nsRefPtr<MediaData>, bool>(aData, false));
CFW_LOGD("delaying output of sample@%lld, first queued", aData->mTime);
if (!mDelayedOutputTimer) {
mDelayedOutputTimer = new MediaTimer();
@ -198,8 +198,8 @@ DecoderCallbackFuzzingWrapper::InputExhausted()
mTaskQueue->Dispatch(task.forget());
return;
}
if (!mDontDelayInputExhausted && !mDelayedOutput.IsEmpty()) {
MediaDataAndInputExhausted& last = mDelayedOutput.LastElement();
if (!mDontDelayInputExhausted && !mDelayedOutput.empty()) {
MediaDataAndInputExhausted& last = mDelayedOutput.back();
CFW_LOGD("InputExhausted delayed until after output of sample@%lld",
last.first()->mTime);
last.second() = true;
@ -220,7 +220,7 @@ DecoderCallbackFuzzingWrapper::DrainComplete()
return;
}
MOZ_ASSERT(mCallback);
if (mDelayedOutput.IsEmpty()) {
if (mDelayedOutput.empty()) {
// No queued output -> Draining is complete now.
CFW_LOGV("No delayed output -> DrainComplete now");
mCallback->DrainComplete();
@ -270,7 +270,7 @@ void
DecoderCallbackFuzzingWrapper::OutputDelayedFrame()
{
MOZ_ASSERT(mTaskQueue->IsCurrentThreadIn());
if (mDelayedOutput.IsEmpty()) {
if (mDelayedOutput.empty()) {
if (mDraining) {
// No more output, and we were draining -> Send DrainComplete.
mDraining = false;
@ -278,17 +278,17 @@ DecoderCallbackFuzzingWrapper::OutputDelayedFrame()
}
return;
}
MediaDataAndInputExhausted& data = mDelayedOutput[0];
MediaDataAndInputExhausted& data = mDelayedOutput.front();
CFW_LOGD("Outputting delayed sample@%lld, remaining:%d",
data.first()->mTime, int(mDelayedOutput.Length() - 1));
data.first()->mTime, int(mDelayedOutput.size() - 1));
mPreviousOutput = TimeStamp::Now();
mCallback->Output(data.first());
if (data.second()) {
CFW_LOGD("InputExhausted after delayed sample@%lld", data.first()->mTime);
mCallback->InputExhausted();
}
mDelayedOutput.RemoveElementAt(0);
if (!mDelayedOutput.IsEmpty()) {
mDelayedOutput.pop_front();
if (!mDelayedOutput.empty()) {
// More output -> Send it later.
ScheduleOutputDelayedFrame();
} else if (mDraining) {
@ -309,7 +309,7 @@ DecoderCallbackFuzzingWrapper::ClearDelayedOutput()
return;
}
mDelayedOutputTimer = nullptr;
mDelayedOutput.Clear();
mDelayedOutput.clear();
}
void

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

@ -10,6 +10,8 @@
#include "mozilla/Pair.h"
#include "PlatformDecoderModule.h"
#include <deque>
namespace mozilla {
// Fuzzing wrapper for media decoders.
@ -77,7 +79,7 @@ private:
// Second member is true if an 'InputExhausted' arrived after that frame; in
// which case an InputExhausted will be sent after finally outputting the frame.
typedef Pair<nsRefPtr<MediaData>, bool> MediaDataAndInputExhausted;
nsTArray<MediaDataAndInputExhausted> mDelayedOutput;
std::deque<MediaDataAndInputExhausted> mDelayedOutput;
nsRefPtr<MediaTimer> mDelayedOutputTimer;
// If draining, a 'DrainComplete' will be sent after all delayed frames have
// been output.