From b6c8fd6ec726450217f0b9bac95cd70b8c2ce5f1 Mon Sep 17 00:00:00 2001 From: Benjamin Chen Date: Fri, 16 Jan 2015 18:59:12 +0800 Subject: [PATCH] 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 | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/dom/media/omx/MediaCodecReader.cpp b/dom/media/omx/MediaCodecReader.cpp index b0bdbac92486..2bad150d6152 100644 --- a/dom/media/omx/MediaCodecReader.cpp +++ b/dom/media/omx/MediaCodecReader.cpp @@ -33,6 +33,7 @@ #include "MediaStreamSource.h" #include "MediaTaskQueue.h" #include "MP3FrameParser.h" +#include "nsMimeTypes.h" #include "nsThreadUtils.h" #include "ImageContainer.h" #include "SharedThreadPool.h" @@ -688,7 +689,9 @@ MediaCodecReader::ReadMetadata(MediaInfo* aInfo, return NS_ERROR_FAILURE; } - if (!TriggerIncrementalParser()) { + bool incrementalParserNeeded = + mDecoder->GetResource()->GetContentType().EqualsASCII(AUDIO_MP3); + if (incrementalParserNeeded && !TriggerIncrementalParser()) { return NS_ERROR_FAILURE; } @@ -1419,10 +1422,10 @@ MediaCodecReader::TriggerIncrementalParser() 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.