gecko/content/media/omx/MediaOmxReader.h
Thomas Zimmermann 112777cbb8 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
2013-10-14 10:38:17 +02:00

89 lines
2.3 KiB
C++

/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
/* vim:set ts=2 sw=2 sts=2 et cindent: */
/* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this file,
* You can obtain one at http://mozilla.org/MPL/2.0/. */
#if !defined(MediaOmxReader_h_)
#define MediaOmxReader_h_
#include "MediaResource.h"
#include "MediaDecoderReader.h"
#include "nsRect.h"
#include <ui/GraphicBuffer.h>
namespace android {
class OmxDecoder;
}
namespace mozilla {
namespace dom {
class TimeRanges;
}
class AbstractMediaDecoder;
class MediaOmxReader : public MediaDecoderReader
{
nsCString mType;
bool mHasVideo;
bool mHasAudio;
nsIntRect mPicture;
nsIntSize mInitialFrame;
int64_t mVideoSeekTimeUs;
int64_t mAudioSeekTimeUs;
int32_t mSkipCount;
protected:
android::sp<android::OmxDecoder> mOmxDecoder;
// Called by ReadMetadata() during MediaDecoderStateMachine::DecodeMetadata()
// on decode thread. It create and initialize the OMX decoder including
// setting up custom extractor. The extractor provide the essential
// information used for creating OMX decoder such as video/audio codec.
virtual nsresult InitOmxDecoder();
public:
MediaOmxReader(AbstractMediaDecoder* aDecoder);
~MediaOmxReader();
virtual nsresult Init(MediaDecoderReader* aCloneDonor);
virtual nsresult ResetDecode();
virtual void NotifyDataArrived(const char* aBuffer, uint32_t aLength, int64_t aOffset);
virtual bool DecodeAudioData();
virtual bool DecodeVideoFrame(bool &aKeyframeSkip,
int64_t aTimeThreshold);
virtual bool HasAudio()
{
return mHasAudio;
}
virtual bool HasVideo()
{
return mHasVideo;
}
virtual bool IsWaitingMediaResources();
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);
virtual nsresult GetBuffered(mozilla::dom::TimeRanges* aBuffered, int64_t aStartTime);
virtual void OnDecodeThreadStart() MOZ_OVERRIDE;
virtual void OnDecodeThreadFinish() MOZ_OVERRIDE;
};
} // namespace mozilla
#endif