Bug 1241003 - ignore AudioData with 0 frames to avoid silence. r=kinetik.

This commit is contained in:
JW Wang 2016-01-21 21:14:42 +08:00
Родитель dd544927e1
Коммит b9727f12f3
1 изменённых файлов: 8 добавлений и 1 удалений

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

@ -202,12 +202,18 @@ DecodedAudioDataSink::PopFrames(uint32_t aFrames)
UniquePtr<AudioDataValue[]> mData;
};
if (!mCurrentData) {
while (!mCurrentData) {
// No data in the queue. Return an empty chunk.
if (AudioQueue().GetSize() == 0) {
return MakeUnique<Chunk>();
}
// Ignore the element with 0 frames and try next.
if (AudioQueue().PeekFront()->mFrames == 0) {
RefPtr<MediaData> releaseMe = AudioQueue().PopFront();
continue;
}
// See if there's a gap in the audio. If there is, push silence into the
// audio hardware, so we can play across the gap.
// Calculate the timestamp of the next chunk of audio in numbers of
@ -239,6 +245,7 @@ DecodedAudioDataSink::PopFrames(uint32_t aFrames)
mCursor = MakeUnique<AudioBufferCursor>(mCurrentData->mAudioData.get(),
mCurrentData->mChannels,
mCurrentData->mFrames);
MOZ_ASSERT(mCurrentData->mFrames > 0);
}
auto framesToPop = std::min(aFrames, mCursor->Available());