Bug 1264199: P7. Stop early if audio queue got flushed. r=me
☠☠ backed out by 64a0ad4f6ac0 ☠ ☠
authorJean-Yves Avenard <jyavenard@mozilla.com>
Mon, 18 Apr 2016 19:16:36 +1000
changeset 333444 1d139b7422c8bad036d3b21308e0ceef87ae1cf8
parent 333443 8871f41bc394c29815e4bf2130be2c7711fcf3db
child 333445 6828e2e05e1690cc36b1e282ee2f997ffce12e1f
push id1146
push userCallek@gmail.com
push dateMon, 25 Jul 2016 16:35:44 +0000
treeherdermozilla-release@a55778f9cd5a [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersme
bugs1264199
milestone48.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 1264199: P7. Stop early if audio queue got flushed. r=me MozReview-Commit-ID: EMj2LMgRIzU
dom/media/mediasink/DecodedAudioDataSink.cpp
--- a/dom/media/mediasink/DecodedAudioDataSink.cpp
+++ b/dom/media/mediasink/DecodedAudioDataSink.cpp
@@ -325,18 +325,23 @@ DecodedAudioDataSink::NotifyAudioNeeded(
     // We have reached the end of the data, drain the resampler.
     DrainConverter();
     return;
   }
 
   // Always ensure we have two processed frames pending to allow for processing
   // latency.
   while (AudioQueue().GetSize() && mProcessedQueue.GetSize() < 2) {
-    RefPtr<AudioData> data =
-      dont_AddRef(AudioQueue().PopFront().take()->As<AudioData>());
+    RefPtr<MediaData> media = AudioQueue().PopFront();
+    if (!media || mShutdown) {
+      // AudioQueue was flushed or shutdown since checking the size of the queue.
+      return;
+    }
+    RefPtr<AudioData> data = dont_AddRef(media.forget().take()->As<AudioData>());
+
     // Ignore the element with 0 frames and try next.
     if (!data->mFrames) {
       continue;
     }
 
     if (!mConverter ||
         (data->mRate != mConverter->InputConfig().Rate() ||
          data->mChannels != mConverter->InputConfig().Channels())) {