Bug 1286041 - Assert audio callback is not called in initialized state. r=jwwang

MozReview-Commit-ID: JX7QVba9O2I

--HG--
extra : rebase_source : 4058fcc3795b24fa3e209ca59a347b6e41564a65
This commit is contained in:
Alex Chronopoulos 2016-07-12 16:53:58 +02:00
Родитель b8d6550755
Коммит 942a71b7a1
1 изменённых файлов: 4 добавлений и 7 удалений

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

@ -400,6 +400,9 @@ AudioStream::Start()
{
MonitorAutoLock mon(mMonitor);
MOZ_ASSERT(mState == INITIALIZED);
// Callback might start before the return of the invoke
// change state to avoid any assert break.
mState = STARTED;
auto r = InvokeCubeb(cubeb_stream_start);
mState = r == CUBEB_OK ? STARTED : ERRORED;
LOG("started, state %s", mState == STARTED ? "STARTED" : "ERRORED");
@ -593,13 +596,7 @@ AudioStream::DataCallback(void* aBuffer, long aFrames)
auto writer = AudioBufferWriter(
reinterpret_cast<AudioDataValue*>(aBuffer), mOutChannels, aFrames);
// FIXME: cubeb_pulse sometimes calls us before cubeb_stream_start() is called.
// We don't want to consume audio data until Start() is called by the client.
if (mState == INITIALIZED) {
NS_WARNING("data callback fires before cubeb_stream_start() is called");
mAudioClock.UpdateFrameHistory(0, aFrames);
return writer.WriteZeros(aFrames);
}
MOZ_ASSERT(mState != INITIALIZED);
// NOTE: wasapi (others?) can call us back *after* stop()/Shutdown() (mState == SHUTDOWN)
// Bug 996162