Bug 1118632 - Fix the duration updated by mp3 incremental parser when we are playing a non-mp3 stream. r=cajbir

This commit is contained in:
Benjamin Chen 2015-01-16 18:59:12 +08:00
parent 49c42b50f9
commit 9d71b9259a

View File

@ -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.