Bug 1058399 - Fix VideoData leak on osx fmp4 seek. r=cpearce
authorRalph Giles <giles@mozilla.com>
Tue, 26 Aug 2014 14:22:00 -0700
changeset 223390 8ad9756bb02568bffe436f26b794e0b5e4baa851
parent 223389 9cfeb1314dc16896d95060cfee344e8438e2afe7
child 223391 c5fbcc0109b3a413a103d9752e18a879a5492f1d
push id3979
push userraliiev@mozilla.com
push dateMon, 13 Oct 2014 16:35:44 +0000
treeherdermozilla-beta@30f2cc610691 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewerscpearce
bugs1058399
milestone34.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 1058399 - Fix VideoData leak on osx fmp4 seek. r=cpearce Calling Clear() on the reorder queue doesn't call delete on the stored pointer elements. Do this explicitly to avoid leaking decoded frames when ::Flush() is called.
content/media/fmp4/apple/AppleVTDecoder.cpp
content/media/fmp4/apple/AppleVTDecoder.h
--- a/content/media/fmp4/apple/AppleVTDecoder.cpp
+++ b/content/media/fmp4/apple/AppleVTDecoder.cpp
@@ -114,17 +114,18 @@ AppleVTDecoder::Input(mp4_demuxer::MP4Sa
 nsresult
 AppleVTDecoder::Flush()
 {
   mTaskQueue->Flush();
   nsresult rv = WaitForAsynchronousFrames();
   if (NS_FAILED(rv)) {
     LOG("AppleVTDecoder::Drain failed waiting for platform decoder.");
   }
-  mReorderQueue.Clear();
+  ClearReorderedFrames();
+
   return rv;
 }
 
 nsresult
 AppleVTDecoder::Drain()
 {
   mTaskQueue->AwaitIdle();
   nsresult rv = WaitForAsynchronousFrames();
@@ -216,16 +217,24 @@ AppleVTDecoder::WaitForAsynchronousFrame
 void
 AppleVTDecoder::DrainReorderedFrames()
 {
   while (!mReorderQueue.IsEmpty()) {
     mCallback->Output(mReorderQueue.Pop());
   }
 }
 
+void
+AppleVTDecoder::ClearReorderedFrames()
+{
+  while (!mReorderQueue.IsEmpty()) {
+    delete mReorderQueue.Pop();
+  }
+}
+
 // Copy and return a decoded frame.
 nsresult
 AppleVTDecoder::OutputFrame(CVPixelBufferRef aImage,
                             nsAutoPtr<FrameRef> aFrameRef)
 {
   size_t width = CVPixelBufferGetWidth(aImage);
   size_t height = CVPixelBufferGetHeight(aImage);
   LOG("  got decoded frame data... %ux%u %s", width, height,
--- a/content/media/fmp4/apple/AppleVTDecoder.h
+++ b/content/media/fmp4/apple/AppleVTDecoder.h
@@ -49,13 +49,14 @@ private:
   ReorderQueue mReorderQueue;
 
   // Method to pass a frame to VideoToolbox for decoding.
   nsresult SubmitFrame(mp4_demuxer::MP4Sample* aSample);
   // Method to set up the decompression session.
   nsresult InitializeSession();
   nsresult WaitForAsynchronousFrames();
   void DrainReorderedFrames();
+  void ClearReorderedFrames();
 };
 
 } // namespace mozilla
 
 #endif // mozilla_AppleVTDecoder_h