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

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

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