Bug 973710 - Drain MP4Reader's decoders on EOS. r=kinetik
authorChris Pearce <cpearce@mozilla.com>
Thu, 17 Jul 2014 10:37:17 +1200
changeset 216439 a59633595bcc42948f5eb00351eae0bd48239197
parent 216438 25f9fbb4d6b9f51edbbf2d7f0a6de989844dff06
child 216440 df330e73a20d72b49867a2b209b3dbd3ecc7b8d0
push id515
push userraliiev@mozilla.com
push dateMon, 06 Oct 2014 12:51:51 +0000
treeherdermozilla-release@267c7a481bef [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewerskinetik
bugs973710
milestone33.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 973710 - Drain MP4Reader's decoders on EOS. r=kinetik
content/media/fmp4/MP4Reader.cpp
content/media/fmp4/PlatformDecoderModule.h
content/media/fmp4/wmf/WMFMediaDataDecoder.cpp
content/media/fmp4/wmf/WMFVideoMFTManager.cpp
--- a/content/media/fmp4/MP4Reader.cpp
+++ b/content/media/fmp4/MP4Reader.cpp
@@ -34,31 +34,29 @@ PRLogModuleInfo* GetDemuxerLog() {
 
 using namespace mp4_demuxer;
 
 namespace mozilla {
 
 // Uncomment to enable verbose per-sample logging.
 //#define LOG_SAMPLE_DECODE 1
 
-#ifdef LOG_SAMPLE_DECODE
 static const char*
 TrackTypeToStr(TrackType aTrack)
 {
   MOZ_ASSERT(aTrack == kAudio || aTrack == kVideo);
   switch (aTrack) {
   case kAudio:
     return "Audio";
   case kVideo:
     return "Video";
   default:
     return "Unknown";
   }
 }
-#endif
 
 class MP4Stream : public Stream {
 public:
 
   MP4Stream(MediaResource* aResource)
     : mResource(aResource)
   {
     MOZ_COUNT_CTOR(MP4Stream);
@@ -346,19 +344,18 @@ MP4Reader::Decode(TrackType aTrack)
            (data.mInputExhausted ||
            (data.mNumSamplesInput - data.mNumSamplesOutput) < data.mDecodeAhead)) {
       data.mMonitor.AssertCurrentThreadOwns();
       data.mMonitor.Unlock();
       nsAutoPtr<MP4Sample> compressed(PopSample(aTrack));
       if (!compressed) {
         // EOS, or error. Let the state machine know there are no more
         // frames coming.
-#ifdef LOG_SAMPLE_DECODE
-        LOG("PopSample %s nullptr", TrackTypeToStr(aTrack));
-#endif
+        LOG("Draining %s", TrackTypeToStr(aTrack));
+        data.mDecoder->Drain();
         return false;
       } else {
 #ifdef LOG_SAMPLE_DECODE
         LOG("PopSample %s time=%lld dur=%lld", TrackTypeToStr(aTrack),
             compressed->composition_timestamp, compressed->duration);
 #endif
       }
       data.mMonitor.Lock();
--- a/content/media/fmp4/PlatformDecoderModule.h
+++ b/content/media/fmp4/PlatformDecoderModule.h
@@ -174,16 +174,18 @@ public:
   virtual nsresult Flush() = 0;
 
   // Causes all complete samples in the pipeline that can be decoded to be
   // output. If the decoder can't produce samples from the current output,
   // it drops the input samples. The decoder may be holding onto samples
   // that are required to decode samples that it expects to get in future.
   // This is called when the demuxer reaches end of stream.
   // The MP4Reader will not call Input() while it's calling Drain().
+  // This function is synchronous. Once it's returned, all samples to be
+  // output should have been returned via callback to the MP4Reader.
   virtual nsresult Drain() = 0;
 
   // Cancels all init/input/drain operations, and shuts down the
   // decoder. The platform decoder should clean up any resources it's using
   // and release memory etc. Shutdown() must block until the decoder has
   // completed shutdown. The reader calls Flush() before calling Shutdown().
   // The reader will delete the decoder once Shutdown() returns.
   // The MediaDataDecoderCallback *must* not be called after Shutdown() has
--- a/content/media/fmp4/wmf/WMFMediaDataDecoder.cpp
+++ b/content/media/fmp4/wmf/WMFMediaDataDecoder.cpp
@@ -115,17 +115,17 @@ WMFMediaDataDecoder::Flush()
   return NS_OK;
 }
 
 void
 WMFMediaDataDecoder::ProcessDrain()
 {
   // Order the decoder to drain...
   if (FAILED(mDecoder->SendMFTMessage(MFT_MESSAGE_COMMAND_DRAIN, 0))) {
-    NS_WARNING("Failed to send DRAIN command to audio MFT");
+    NS_WARNING("Failed to send DRAIN command to MFT");
   }
   // Then extract all available output.
   ProcessOutput();
 }
 
 nsresult
 WMFMediaDataDecoder::Drain()
 {
--- a/content/media/fmp4/wmf/WMFVideoMFTManager.cpp
+++ b/content/media/fmp4/wmf/WMFVideoMFTManager.cpp
@@ -200,17 +200,17 @@ WMFVideoMFTManager::ConfigureVideoFrameG
   // Success! Save state.
   mVideoInfo.mDisplay = displaySize;
   mVideoInfo.mHasVideo = true;
   GetDefaultStride(mediaType, &mVideoStride);
   mVideoWidth = width;
   mVideoHeight = height;
   mPictureRegion = pictureRegion;
 
-  LOG("WMFReader frame geometry frame=(%u,%u) stride=%u picture=(%d, %d, %d, %d) display=(%d,%d) PAR=%d:%d",
+  LOG("WMFVideoMFTManager frame geometry frame=(%u,%u) stride=%u picture=(%d, %d, %d, %d) display=(%d,%d) PAR=%d:%d",
       width, height,
       mVideoStride,
       mPictureRegion.x, mPictureRegion.y, mPictureRegion.width, mPictureRegion.height,
       displaySize.width, displaySize.height,
       aspectNum, aspectDenom);
 
   return S_OK;
 }