Bug 993753 - Don't set media decoders idle while seeking. r=kinetik

This commit is contained in:
Chris Pearce 2014-04-15 15:01:34 +12:00
Родитель 6a988d1ac5
Коммит 5ce7ac50f4
3 изменённых файлов: 27 добавлений и 7 удалений

Просмотреть файл

@ -1556,6 +1556,7 @@ MediaDecoderStateMachine::DispatchDecodeTasksIfNeeded()
(!needToDecodeAudio && !needToDecodeVideo)); (!needToDecodeAudio && !needToDecodeVideo));
bool needIdle = !mDecoder->IsLogicallyPlaying() && bool needIdle = !mDecoder->IsLogicallyPlaying() &&
mState != DECODER_STATE_SEEKING &&
!needToDecodeAudio && !needToDecodeAudio &&
!needToDecodeVideo && !needToDecodeVideo &&
!IsPlaying(); !IsPlaying();

Просмотреть файл

@ -40,13 +40,16 @@ extern PRLogModuleInfo* gMediaDecoderLog;
#define DECODER_LOG(type, msg) #define DECODER_LOG(type, msg)
#endif #endif
MediaOmxReader::MediaOmxReader(AbstractMediaDecoder *aDecoder) : MediaOmxReader::MediaOmxReader(AbstractMediaDecoder *aDecoder)
MediaDecoderReader(aDecoder), : MediaDecoderReader(aDecoder)
mHasVideo(false), , mHasVideo(false)
mHasAudio(false), , mHasAudio(false)
mVideoSeekTimeUs(-1), , mVideoSeekTimeUs(-1)
mAudioSeekTimeUs(-1), , mAudioSeekTimeUs(-1)
mSkipCount(0) , mSkipCount(0)
#ifdef DEBUG
, mIsActive(true)
#endif
{ {
#ifdef PR_LOGGING #ifdef PR_LOGGING
if (!gMediaDecoderLog) { if (!gMediaDecoderLog) {
@ -132,6 +135,7 @@ nsresult MediaOmxReader::ReadMetadata(MediaInfo* aInfo,
MetadataTags** aTags) MetadataTags** aTags)
{ {
NS_ASSERTION(mDecoder->OnDecodeThread(), "Should be on decode thread."); NS_ASSERTION(mDecoder->OnDecodeThread(), "Should be on decode thread.");
MOZ_ASSERT(mIsActive);
*aTags = nullptr; *aTags = nullptr;
@ -207,6 +211,8 @@ nsresult MediaOmxReader::ReadMetadata(MediaInfo* aInfo,
bool MediaOmxReader::DecodeVideoFrame(bool &aKeyframeSkip, bool MediaOmxReader::DecodeVideoFrame(bool &aKeyframeSkip,
int64_t aTimeThreshold) int64_t aTimeThreshold)
{ {
MOZ_ASSERT(mIsActive);
// Record number of frames decoded and parsed. Automatically update the // Record number of frames decoded and parsed. Automatically update the
// stats counters using the AutoNotifyDecoded stack-based class. // stats counters using the AutoNotifyDecoded stack-based class.
uint32_t parsed = 0, decoded = 0; uint32_t parsed = 0, decoded = 0;
@ -335,6 +341,7 @@ void MediaOmxReader::NotifyDataArrived(const char* aBuffer, uint32_t aLength, in
bool MediaOmxReader::DecodeAudioData() bool MediaOmxReader::DecodeAudioData()
{ {
NS_ASSERTION(mDecoder->OnDecodeThread(), "Should be on decode thread."); NS_ASSERTION(mDecoder->OnDecodeThread(), "Should be on decode thread.");
MOZ_ASSERT(mIsActive);
// This is the approximate byte position in the stream. // This is the approximate byte position in the stream.
int64_t pos = mDecoder->GetResource()->Tell(); int64_t pos = mDecoder->GetResource()->Tell();
@ -368,6 +375,7 @@ bool MediaOmxReader::DecodeAudioData()
nsresult MediaOmxReader::Seek(int64_t aTarget, int64_t aStartTime, int64_t aEndTime, int64_t aCurrentTime) nsresult MediaOmxReader::Seek(int64_t aTarget, int64_t aStartTime, int64_t aEndTime, int64_t aCurrentTime)
{ {
NS_ASSERTION(mDecoder->OnDecodeThread(), "Should be on decode thread."); NS_ASSERTION(mDecoder->OnDecodeThread(), "Should be on decode thread.");
MOZ_ASSERT(mIsActive);
ResetDecode(); ResetDecode();
VideoFrameContainer* container = mDecoder->GetVideoFrameContainer(); VideoFrameContainer* container = mDecoder->GetVideoFrameContainer();
@ -402,6 +410,9 @@ static uint64_t BytesToTime(int64_t offset, uint64_t length, uint64_t durationUs
} }
void MediaOmxReader::SetIdle() { void MediaOmxReader::SetIdle() {
#ifdef DEBUG
mIsActive = false;
#endif
if (!mOmxDecoder.get()) { if (!mOmxDecoder.get()) {
return; return;
} }
@ -409,6 +420,9 @@ void MediaOmxReader::SetIdle() {
} }
void MediaOmxReader::SetActive() { void MediaOmxReader::SetActive() {
#ifdef DEBUG
mIsActive = true;
#endif
if (!mOmxDecoder.get()) { if (!mOmxDecoder.get()) {
return; return;
} }

Просмотреть файл

@ -100,6 +100,11 @@ public:
void CheckAudioOffload(); void CheckAudioOffload();
#endif #endif
private:
// This flag is true when SetActive() has been called without a matching
// SetIdle(). This is used to sanity check the SetIdle/SetActive calls, to
// ensure SetActive has been called before a decode call.
DebugOnly<bool> mIsActive;
}; };
} // namespace mozilla } // namespace mozilla