Bug 1175396 - Handle mismatched sample formats. r=jwwang, a=2.0+
authorMatthew Gregan <kinetik@flim.org>
Fri, 17 Jul 2015 11:29:11 +1200
changeset 204935 34a6a0090649b46bf00efc5b9b5390b361e10767
parent 204934 2b69da6a768e15b19e6a20a8745dab3583f31446
child 204936 e1f3530ac909fac480390cb8138b02e92b6a210a
push id856
push userryanvm@gmail.com
push dateFri, 17 Jul 2015 01:24:04 +0000
treeherdermozilla-b2g32_v2_0@34a6a0090649 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersjwwang, 2
bugs1175396
milestone32.0
Bug 1175396 - Handle mismatched sample formats. r=jwwang, a=2.0+
content/media/MediaDecoderStateMachine.cpp
--- a/content/media/MediaDecoderStateMachine.cpp
+++ b/content/media/MediaDecoderStateMachine.cpp
@@ -994,18 +994,23 @@ uint32_t MediaDecoderStateMachine::PlayF
     // Awaken the decode loop if it's waiting for space to free up in the
     // audio queue.
     mDecoder->GetReentrantMonitor().NotifyAll();
   }
   int64_t offset = -1;
   uint32_t frames = 0;
   VERBOSE_LOG("playing %d frames of data to stream for AudioData at %lld",
               audio->mFrames, audio->mTime);
-  mAudioStream->Write(audio->mAudioData,
-                      audio->mFrames);
+  if (audio->mChannels == aChannels) {
+    mAudioStream->Write(audio->mAudioData, audio->mFrames);
+  } else {
+    VERBOSE_LOG("mismatched sample format mInfo=[%u channels] audio=[%u channels]",
+                 aChannels, audio->mChannels);
+    PlaySilence(audio->mFrames, aChannels, 0);
+  }
 
   aChannels = mAudioStream->GetOutChannels();
 
   StartAudioStreamPlaybackIfNeeded(mAudioStream);
 
   offset = audio->mOffset;
   frames = audio->mFrames;