bug 1081766 clear audio/video track/reader only once r=kinetik
authorKarl Tomlinson <karlt+@karlt.net>
Fri, 10 Oct 2014 18:26:12 +1300
changeset 210651 a5eca3f1dee878b7d183ef72b5a0b6ea5c84abf2
parent 210650 0004a6330d53c07baea3f31b7819fee5cf631540
child 210652 3a3d2d09ccca24362eb2cdfd81834f5bea8a823d
push id1
push userroot
push dateMon, 20 Oct 2014 17:29:22 +0000
reviewerskinetik
bugs1081766
milestone36.0a1
bug 1081766 clear audio/video track/reader only once r=kinetik Clearing tracks after Shutdown of TrackBuffers means they are cleared after any more can be added.
content/media/mediasource/MediaSourceReader.cpp
--- a/content/media/mediasource/MediaSourceReader.cpp
+++ b/content/media/mediasource/MediaSourceReader.cpp
@@ -197,34 +197,37 @@ MediaSourceReader::OnDecodeError()
   MSE_DEBUG("MediaSourceReader(%p)::OnDecodeError", this);
   GetCallback()->OnDecodeError();
 }
 
 void
 MediaSourceReader::Shutdown()
 {
   MediaDecoderReader::Shutdown();
+  for (uint32_t i = 0; i < mTrackBuffers.Length(); ++i) {
+    mTrackBuffers[i]->Shutdown();
+  }
   mAudioTrack = nullptr;
   mAudioReader = nullptr;
   mVideoTrack = nullptr;
   mVideoReader = nullptr;
-  for (uint32_t i = 0; i < mTrackBuffers.Length(); ++i) {
-    mTrackBuffers[i]->Shutdown();
-  }
   mTrackBuffers.Clear();
 }
 
 void
 MediaSourceReader::BreakCycles()
 {
   MediaDecoderReader::BreakCycles();
-  mAudioTrack = nullptr;
-  mAudioReader = nullptr;
-  mVideoTrack = nullptr;
-  mVideoReader = nullptr;
+
+  // These were cleared in Shutdown().
+  MOZ_ASSERT(!mAudioTrack);
+  MOZ_ASSERT(!mAudioReader);
+  MOZ_ASSERT(!mVideoTrack);
+  MOZ_ASSERT(!mVideoReader);
+
   for (uint32_t i = 0; i < mTrackBuffers.Length(); ++i) {
     mTrackBuffers[i]->BreakCycles();
   }
   mTrackBuffers.Clear();
 }
 
 already_AddRefed<MediaDecoderReader>
 MediaSourceReader::SelectReader(int64_t aTarget,