Bug 1296533: [ogg] P1. Fix memory leak in OggDemuxer. r?gerald
MozReview-Commit-ID: D8ya0vDrHVp
--- a/dom/media/ogg/OggDemuxer.cpp
+++ b/dom/media/ogg/OggDemuxer.cpp
@@ -119,22 +119,17 @@ OggDemuxer::InitTrack(MessageField* aMsg
aInfo->Init(sName? NS_ConvertUTF8toUTF16(*sName):EmptyString(),
sRole? GetKind(*sRole):EmptyString(),
sTitle? NS_ConvertUTF8toUTF16(*sTitle):EmptyString(),
sLanguage? NS_ConvertUTF8toUTF16(*sLanguage):EmptyString(),
aEnable);
}
OggDemuxer::OggDemuxer(MediaResource* aResource)
- : mTheoraState(nullptr)
- , mVorbisState(nullptr)
- , mOpusState(nullptr)
- , mFlacState(nullptr)
- , mOpusEnabled(MediaDecoder::IsOpusEnabled())
- , mSkeletonState(nullptr)
+ : mOpusEnabled(MediaDecoder::IsOpusEnabled())
, mAudioOggState(aResource)
, mVideoOggState(aResource)
, mVorbisSerial(0)
, mOpusSerial(0)
, mTheoraSerial(0)
, mFlacSerial(0)
, mOpusPreSkip(0)
, mIsChained(false)
--- a/dom/media/ogg/OggDemuxer.h
+++ b/dom/media/ogg/OggDemuxer.h
@@ -251,38 +251,38 @@ private:
MediaInfo mInfo;
nsTArray<RefPtr<OggTrackDemuxer>> mDemuxers;
// Map of codec-specific bitstream states.
OggCodecStore mCodecStore;
// Decode state of the Theora bitstream we're decoding, if we have video.
- TheoraState* mTheoraState;
+ nsAutoPtr<TheoraState> mTheoraState;
// Decode state of the Vorbis bitstream we're decoding, if we have audio.
- VorbisState* mVorbisState;
+ nsAutoPtr<VorbisState> mVorbisState;
// Decode state of the Opus bitstream we're decoding, if we have one.
- OpusState* mOpusState;
+ nsAutoPtr<OpusState> mOpusState;
// Get the bitstream decode state for the given track type
// Decode state of the Flac bitstream we're decoding, if we have one.
- FlacState* mFlacState;
+ nsAutoPtr<FlacState> mFlacState;
OggCodecState* GetTrackCodecState(TrackInfo::TrackType aType) const;
TrackInfo::TrackType GetCodecStateType(OggCodecState* aState) const;
// Represents the user pref media.opus.enabled at the time our
// contructor was called. We can't check it dynamically because
// we're not on the main thread;
bool mOpusEnabled;
// Decode state of the Skeleton bitstream.
- SkeletonState* mSkeletonState;
+ nsAutoPtr<SkeletonState> mSkeletonState;
// Ogg decoding state.
struct OggStateContext
{
explicit OggStateContext(MediaResource* aResource)
: mResource(aResource), mNeedKeyframe(true) {}
nsAutoOggSyncState mOggState;
MediaResourceIndex mResource;