diff --git a/dom/media/AudioStream.cpp b/dom/media/AudioStream.cpp index 314e6312adb1..0c2d6fd8731a 100644 --- a/dom/media/AudioStream.cpp +++ b/dom/media/AudioStream.cpp @@ -597,7 +597,17 @@ AudioStream::DataCallback(void* aBuffer, long aFrames) auto writer = AudioBufferWriter( reinterpret_cast(aBuffer), mOutChannels, aFrames); - MOZ_ASSERT(mState != INITIALIZED); + if (!strcmp(cubeb_get_backend_id(CubebUtils::GetCubebContext()), "winmm")) { + // Don't consume audio data until Start() is called. + // Expected only with cubeb winmm backend. + if (mState == INITIALIZED) { + NS_WARNING("data callback fires before cubeb_stream_start() is called"); + mAudioClock.UpdateFrameHistory(0, aFrames); + return writer.WriteZeros(aFrames); + } + } else { + MOZ_ASSERT(mState != INITIALIZED); + } // NOTE: wasapi (others?) can call us back *after* stop()/Shutdown() (mState == SHUTDOWN) // Bug 996162