From 05a8724f6ab98bb3effd4d43ef4550c4efbe9b25 Mon Sep 17 00:00:00 2001 From: Sotaro Ikeda Date: Mon, 2 Dec 2013 22:38:16 -0500 Subject: [PATCH] Bug 941274 - Fix ResetDecode in MediaOmxReader. r=doublec --- content/media/omx/MediaOmxReader.cpp | 25 +++++++++++-------------- content/media/omx/MediaOmxReader.h | 1 - 2 files changed, 11 insertions(+), 15 deletions(-) diff --git a/content/media/omx/MediaOmxReader.cpp b/content/media/omx/MediaOmxReader.cpp index 9442e0f93140..fc14561e49e7 100644 --- a/content/media/omx/MediaOmxReader.cpp +++ b/content/media/omx/MediaOmxReader.cpp @@ -37,6 +37,10 @@ MediaOmxReader::MediaOmxReader(AbstractMediaDecoder *aDecoder) : MediaOmxReader::~MediaOmxReader() { ResetDecode(); + VideoFrameContainer* container = mDecoder->GetVideoFrameContainer(); + if (container) { + container->ClearCurrentFrame(); + } mOmxDecoder.clear(); } @@ -64,6 +68,12 @@ bool MediaOmxReader::IsDormantNeeded() void MediaOmxReader::ReleaseMediaResources() { ResetDecode(); + // Before freeing a video codec, all video buffers needed to be released + // even from graphics pipeline. + VideoFrameContainer* container = mDecoder->GetVideoFrameContainer(); + if (container) { + container->ClearCurrentFrame(); + } if (mOmxDecoder.get()) { mOmxDecoder->ReleaseMediaResources(); } @@ -166,18 +176,6 @@ nsresult MediaOmxReader::ReadMetadata(MediaInfo* aInfo, return NS_OK; } -// Resets all state related to decoding, emptying all buffers etc. -nsresult MediaOmxReader::ResetDecode() -{ - MediaDecoderReader::ResetDecode(); - - VideoFrameContainer* container = mDecoder->GetVideoFrameContainer(); - if (container) { - container->ClearCurrentFrame(); - } - return NS_OK; -} - bool MediaOmxReader::DecodeVideoFrame(bool &aKeyframeSkip, int64_t aTimeThreshold) { @@ -347,12 +345,11 @@ nsresult MediaOmxReader::Seek(int64_t aTarget, int64_t aStartTime, int64_t aEndT { NS_ASSERTION(mDecoder->OnDecodeThread(), "Should be on decode thread."); + ResetDecode(); VideoFrameContainer* container = mDecoder->GetVideoFrameContainer(); if (container && container->GetImageContainer()) { container->GetImageContainer()->ClearAllImagesExceptFront(); } - mVideoQueue.Reset(); - mAudioQueue.Reset(); mAudioSeekTimeUs = mVideoSeekTimeUs = aTarget; diff --git a/content/media/omx/MediaOmxReader.h b/content/media/omx/MediaOmxReader.h index 58329da25688..a8c6d714905e 100644 --- a/content/media/omx/MediaOmxReader.h +++ b/content/media/omx/MediaOmxReader.h @@ -48,7 +48,6 @@ public: ~MediaOmxReader(); virtual nsresult Init(MediaDecoderReader* aCloneDonor); - virtual nsresult ResetDecode(); virtual void NotifyDataArrived(const char* aBuffer, uint32_t aLength, int64_t aOffset);