mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-10-23 18:26:15 +00:00
Bug 1150322 - Fix duration parsing in MediaOmxReader - r=sotaro
This commit is contained in:
parent
6eb4312856
commit
eaf37d1af9
@ -137,7 +137,6 @@ MediaOmxReader::MediaOmxReader(AbstractMediaDecoder *aDecoder)
|
||||
, mAudioSeekTimeUs(-1)
|
||||
, mLastParserDuration(-1)
|
||||
, mSkipCount(0)
|
||||
, mUseParserDuration(false)
|
||||
, mIsShutdown(false)
|
||||
, mMP3FrameParser(-1)
|
||||
, mIsWaitingResources(false)
|
||||
@ -290,16 +289,16 @@ nsresult MediaOmxReader::ReadMetadata(MediaInfo* aInfo,
|
||||
}
|
||||
|
||||
if (isMP3 && mMP3FrameParser.IsMP3()) {
|
||||
int64_t duration = mMP3FrameParser.GetDuration();
|
||||
// The MP3FrameParser may reported a duration;
|
||||
// return -1 if no frame has been parsed.
|
||||
if (duration >= 0) {
|
||||
ReentrantMonitorAutoEnter mon(mDecoder->GetReentrantMonitor());
|
||||
mUseParserDuration = true;
|
||||
mLastParserDuration = duration;
|
||||
mDecoder->SetMediaDuration(mLastParserDuration);
|
||||
}
|
||||
// Check if the MP3 frame parser found a duration.
|
||||
mLastParserDuration = mMP3FrameParser.GetDuration();
|
||||
}
|
||||
|
||||
if (mLastParserDuration >= 0) {
|
||||
// Prefer the parser duration if we have it.
|
||||
ReentrantMonitorAutoEnter mon(mDecoder->GetReentrantMonitor());
|
||||
mDecoder->SetMediaDuration(mLastParserDuration);
|
||||
} else {
|
||||
// MP3 parser failed to find a duration.
|
||||
// Set the total duration (the max of the audio and video track).
|
||||
int64_t durationUs;
|
||||
mOmxDecoder->GetDuration(&durationUs);
|
||||
@ -501,7 +500,7 @@ void MediaOmxReader::NotifyDataArrived(const char* aBuffer, uint32_t aLength, in
|
||||
}
|
||||
|
||||
int64_t duration = mMP3FrameParser.GetDuration();
|
||||
if (duration != mLastParserDuration && mUseParserDuration) {
|
||||
if (duration != mLastParserDuration) {
|
||||
ReentrantMonitorAutoEnter mon(decoder->GetReentrantMonitor());
|
||||
mLastParserDuration = duration;
|
||||
decoder->UpdateEstimatedMediaDuration(mLastParserDuration);
|
||||
|
@ -38,7 +38,6 @@ class MediaOmxReader : public MediaOmxCommonReader
|
||||
int64_t mAudioSeekTimeUs;
|
||||
int64_t mLastParserDuration;
|
||||
int32_t mSkipCount;
|
||||
bool mUseParserDuration;
|
||||
// If mIsShutdown is false, and mShutdownMutex is held, then
|
||||
// AbstractMediaDecoder::mDecoder will be non-null.
|
||||
bool mIsShutdown;
|
||||
|
Loading…
Reference in New Issue
Block a user