Bug 1246108 - Don't restart completed audio streams. r=jwwang

This commit is contained in:
Matthew Gregan 2016-03-22 20:55:51 +13:00
Родитель 3569deb1b0
Коммит d2da3ad7e8
2 изменённых файлов: 6 добавлений и 4 удалений

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

@ -38,6 +38,7 @@ DecodedAudioDataSink::DecodedAudioDataSink(MediaQueue<MediaData>& aAudioQueue,
, mInfo(aInfo)
, mChannel(aChannel)
, mPlaying(true)
, mPlaybackComplete(false)
{
}
@ -119,7 +120,7 @@ DecodedAudioDataSink::SetPreservesPitch(bool aPreservesPitch)
void
DecodedAudioDataSink::SetPlaying(bool aPlaying)
{
if (!mAudioStream || mPlaying == aPlaying) {
if (!mAudioStream || mPlaying == aPlaying || mPlaybackComplete) {
return;
}
// pause/resume AudioStream as necessary.
@ -291,9 +292,7 @@ void
DecodedAudioDataSink::Drained()
{
SINK_LOG("Drained");
// FIXME : In OSX, the audio backend could trigger Drained() twice, then it
// cause the crash because the promise had already been resolve and free.
// You can fix it on the bug 1246108.
mPlaybackComplete = true;
mEndPromise.ResolveIfExists(true, __func__);
}

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

@ -101,6 +101,9 @@ private:
UniquePtr<AudioBufferCursor> mCursor;
// True if there is any error in processing audio data like overflow.
bool mErrored = false;
// Set on the callback thread of cubeb once the stream has drained.
Atomic<bool> mPlaybackComplete;
};
} // namespace media