Bug 1175396 - Handle mismatched sample formats. r=jwwang, a=2.1+
--- a/content/media/AudioSink.cpp
+++ b/content/media/AudioSink.cpp
@@ -298,17 +298,23 @@ AudioSink::PlayFromAudioQueue()
ReentrantMonitorAutoEnter mon(GetReentrantMonitor());
NS_WARN_IF_FALSE(mPlaying, "Should be playing");
// Awaken the decode loop if it's waiting for space to free up in the
// audio queue.
GetReentrantMonitor().NotifyAll();
}
SINK_LOG_V("playing %u frames of audio at time %lld",
audio->mFrames, audio->mTime);
- mAudioStream->Write(audio->mAudioData, audio->mFrames);
+ if (audio->mRate == mInfo.mRate && audio->mChannels == mInfo.mChannels) {
+ mAudioStream->Write(audio->mAudioData, audio->mFrames);
+ } else {
+ SINK_LOG_V("mismatched sample format mInfo=[%uHz/%u channels] audio=[%uHz/%u channels]",
+ mInfo.mRate, mInfo.mChannels, audio->mRate, audio->mChannels);
+ PlaySilence(audio->mFrames);
+ }
StartAudioStreamPlaybackIfNeeded();
if (audio->mOffset != -1) {
mStateMachine->OnPlaybackOffsetUpdate(audio->mOffset);
}
return audio->mFrames;
}