Bug 1118632 - Fix the duration updated by mp3 incremental parser when we are playing a non-mp3 stream. r=cajbir
authorBenjamin Chen <bechen@mozilla.com>
Fri, 16 Jan 2015 18:59:12 +0800
changeset 224862 684267d1eaf46ccbad162fa1f236b5733eba7f04
parent 224861 71ad6315d88c1e4fa7dae595c576af7426b7ca47
child 224863 e1a9476d44f648334be746c936362f02065003b2
push id28146
push usercbook@mozilla.com
push dateWed, 21 Jan 2015 13:22:59 +0000
treeherdermozilla-central@0f2b4a7a9daf [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewerscajbir
bugs1118632
milestone38.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 1118632 - Fix the duration updated by mp3 incremental parser when we are playing a non-mp3 stream. r=cajbir
dom/media/omx/MediaCodecReader.cpp
--- a/dom/media/omx/MediaCodecReader.cpp
+++ b/dom/media/omx/MediaCodecReader.cpp
@@ -28,16 +28,17 @@
 #include "mozilla/TimeStamp.h"
 #include "mozilla/layers/GrallocTextureClient.h"
 
 #include "gfx2DGlue.h"
 
 #include "MediaStreamSource.h"
 #include "MediaTaskQueue.h"
 #include "MP3FrameParser.h"
+#include "nsMimeTypes.h"
 #include "nsThreadUtils.h"
 #include "ImageContainer.h"
 #include "SharedThreadPool.h"
 #include "VideoFrameContainer.h"
 #include "VideoUtils.h"
 
 using namespace android;
 
@@ -683,17 +684,19 @@ MediaCodecReader::ReadMetadata(MediaInfo
                                MetadataTags** aTags)
 {
   MOZ_ASSERT(mDecoder->OnDecodeThread(), "Should be on decode thread.");
 
   if (!ReallocateResources()) {
     return NS_ERROR_FAILURE;
   }
 
-  if (!TriggerIncrementalParser()) {
+  bool incrementalParserNeeded =
+    mDecoder->GetResource()->GetContentType().EqualsASCII(AUDIO_MP3);
+  if (incrementalParserNeeded && !TriggerIncrementalParser()) {
     return NS_ERROR_FAILURE;
   }
 
   // Bug 1050667, both MediaDecoderStateMachine and MediaCodecReader
   // relies on IsWaitingMediaResources() function. And the waiting state will be
   // changed by binder thread, so we store the waiting state in a cache value to
   // make them in the same waiting state.
   UpdateIsWaitingMediaResources();
@@ -1414,20 +1417,20 @@ MediaCodecReader::TriggerIncrementalPars
       return true;
     }
 
     mParseDataFromCache = true;
     mNextParserPosition = INT64_C(0);
     mParsedDataLength = INT64_C(0);
 
     // MP3 file duration
-    mMP3FrameParser = new MP3FrameParser(mDecoder->GetResource()->GetLength());
     const char* mime = nullptr;
     if (mMetaData->findCString(kKeyMIMEType, &mime) &&
         !strcasecmp(mime, MEDIA_MIMETYPE_AUDIO_MPEG)) {
+      mMP3FrameParser = new MP3FrameParser(mDecoder->GetResource()->GetLength());
       {
         MonitorAutoUnlock monUnlock(mParserMonitor);
         // trigger parsing logic and wait for finishing parsing data in the beginning.
         nsRefPtr<SignalObject> signalObject = new SignalObject("MediaCodecReader::UpdateDuration()");
         if (ProcessCachedData(INT64_C(0), signalObject) > INT64_C(0)) {
           signalObject->Wait();
         }
       }