Bug 1061702: Stop audio sources from continuing to play garbage after being stopped r=roc

* clear audio callback buffer if no streams have audio
This commit is contained in:
Randell Jesup 2014-10-03 00:47:59 -04:00
parent c22ac086c3
commit 869f9d8a0d

View File

@ -77,9 +77,18 @@ public:
void BufferFilled() {
// It's okay to have exactly zero samples here, it can happen we have an
// audio callback driver because of a hint on MSG creation, but the
// AudioOutputStream has not been created yet.
// AudioOutputStream has not been created yet, or if all the streams have finished
// but we're still running.
// Note: it's also ok if we had data in the scratch buffer - and we usually do - and
// all the streams were ended (no mixer callback occured).
// XXX Remove this warning, or find a way to avoid it if the mixer callback
// isn't called.
NS_WARN_IF_FALSE(Available() == 0 || mSampleWriteOffset == 0,
"Audio Buffer is not full by the end of the callback.");
// Make sure the data returned is always set and not random!
if (Available()) {
PodZero(mBuffer + mSampleWriteOffset, FramesToSamples(CHANNELS, Available()));
}
MOZ_ASSERT(mSamples, "Buffer not set.");
mSamples = 0;
mSampleWriteOffset = 0;