Bug 1245542 - I suspect AudioData::mAudioData/mFrames are poisoned when sample format doesn't match the metadata. Let's ignore these samples to see if crash volume can be reduced. r=kinetik. a=lizzard
authorJW Wang <jwwang@mozilla.com>
Fri, 05 Feb 2016 10:19:12 +0800
changeset 316928 1803328a709c1a84ba8aadeb203b8a85eae6ef18
parent 316927 e397f9ecd8310d03ef19ed9381caf89a137d187a
child 316929 d46a689e9e67c19039f0e8314ac04661d6976654
push id5703
push userraliiev@mozilla.com
push dateMon, 07 Mar 2016 14:18:41 +0000
treeherdermozilla-beta@31e373ad5b5f [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewerskinetik, lizzard
bugs1245542
milestone46.0a2
Bug 1245542 - I suspect AudioData::mAudioData/mFrames are poisoned when sample format doesn't match the metadata. Let's ignore these samples to see if crash volume can be reduced. r=kinetik. a=lizzard
dom/media/mediasink/DecodedAudioDataSink.cpp
--- a/dom/media/mediasink/DecodedAudioDataSink.cpp
+++ b/dom/media/mediasink/DecodedAudioDataSink.cpp
@@ -1,14 +1,15 @@
 /* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
 /* vim:set ts=2 sw=2 sts=2 et cindent: */
 /* This Source Code Form is subject to the terms of the Mozilla Public
  * License, v. 2.0. If a copy of the MPL was not distributed with this
  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
 
+#include "nsPrintfCString.h"
 #include "MediaQueue.h"
 #include "DecodedAudioDataSink.h"
 #include "VideoUtils.h"
 
 #include "mozilla/CheckedInt.h"
 #include "mozilla/DebugOnly.h"
 
 namespace mozilla {
@@ -203,18 +204,29 @@ DecodedAudioDataSink::PopFrames(uint32_t
   };
 
   while (!mCurrentData) {
     // No data in the queue. Return an empty chunk.
     if (AudioQueue().GetSize() == 0) {
       return MakeUnique<Chunk>();
     }
 
+    AudioData* a = AudioQueue().PeekFront()->As<AudioData>();
+
     // Ignore the element with 0 frames and try next.
-    if (AudioQueue().PeekFront()->mFrames == 0) {
+    if (a->mFrames == 0) {
+      RefPtr<MediaData> releaseMe = AudioQueue().PopFront();
+      continue;
+    }
+
+    // Ignore invalid samples.
+    if (a->mRate != mInfo.mRate || a->mChannels != mInfo.mChannels) {
+      NS_WARNING(nsPrintfCString(
+        "mismatched sample format, data=%p rate=%u channels=%u frames=%u",
+        a->mAudioData.get(), a->mRate, a->mChannels, a->mFrames).get());
       RefPtr<MediaData> releaseMe = AudioQueue().PopFront();
       continue;
     }
 
     // See if there's a gap in the audio. If there is, push silence into the
     // audio hardware, so we can play across the gap.
     // Calculate the timestamp of the next chunk of audio in numbers of
     // samples.