Bug 924678: Explicitly clear OmxDecoder::mDecoder, r=doublec

The MediaDecoderStateMachine frees the Decoder during its own
shutdown. If the the MediaDecoderStateMachine for an MP3 file
gets cleaned up before the MP3 frame parser is finished, the
OmxDecoder operates with an invalid Decoder.

With this patch, the MediaDecoderStateMachine informs the
OmxDecoder to clear the decoder field. The MP3 parser logic
detects this case and returns.

--HG--
extra : rebase_source : 0a00de3cf7b95ede77408e5d43cccbcd706750cd
This commit is contained in:
Thomas Zimmermann 2013-10-14 10:38:17 +02:00
parent f2fa823868
commit 568572011d
6 changed files with 26 additions and 2 deletions

View File

@ -447,6 +447,8 @@ public:
virtual bool IsDormantNeeded() { return false; }
// Release media resources they should be released in dormant state
virtual void ReleaseMediaResources() {};
// Release the decoder during shutdown
virtual void ReleaseDecoder() {};
// Resets all state related to decoding, emptying all buffers etc.
virtual nsresult ResetDecode();

View File

@ -320,7 +320,13 @@ public:
void SetFragmentEndTime(int64_t aEndTime);
// Drop reference to decoder. Only called during shutdown dance.
void ReleaseDecoder() { mDecoder = nullptr; }
void ReleaseDecoder() {
MOZ_ASSERT(mReader);
if (mReader) {
mReader->ReleaseDecoder();
}
mDecoder = nullptr;
}
// Called when a "MozAudioAvailable" event listener is added to the media
// element. Called on the main thread.

View File

@ -69,6 +69,13 @@ void MediaOmxReader::ReleaseMediaResources()
}
}
void MediaOmxReader::ReleaseDecoder()
{
if (mOmxDecoder.get()) {
mOmxDecoder->ReleaseDecoder();
}
}
nsresult MediaOmxReader::ReadMetadata(MediaInfo* aInfo,
MetadataTags** aTags)
{

View File

@ -62,6 +62,8 @@ public:
virtual bool IsDormantNeeded();
virtual void ReleaseMediaResources();
virtual void ReleaseDecoder() MOZ_OVERRIDE;
virtual nsresult ReadMetadata(MediaInfo* aInfo,
MetadataTags** aTags);
virtual nsresult Seek(int64_t aTime, int64_t aStartTime, int64_t aEndTime, int64_t aCurrentTime);

View File

@ -628,9 +628,14 @@ bool OmxDecoder::SetAudioFormat() {
return true;
}
void OmxDecoder::ReleaseDecoder()
{
mDecoder = nullptr;
}
void OmxDecoder::NotifyDataArrived(const char* aBuffer, uint32_t aLength, int64_t aOffset)
{
if (!mAudioTrack.get() || !mIsMp3 || !mMP3FrameParser.IsMP3()) {
if (!mAudioTrack.get() || !mIsMp3 || !mMP3FrameParser.IsMP3() || !mDecoder) {
return;
}

View File

@ -181,6 +181,8 @@ public:
bool SetVideoFormat();
bool SetAudioFormat();
void ReleaseDecoder();
void NotifyDataArrived(const char* aBuffer, uint32_t aLength, int64_t aOffset);
void GetDuration(int64_t *durationUs) {