summaryrefslogtreecommitdiffstats
path: root/media
diff options
context:
space:
mode:
authorMarco Nelissen <marcone@google.com>2014-10-16 10:51:23 -0700
committerMarco Nelissen <marcone@google.com>2014-10-16 10:51:23 -0700
commit942481eee58cb1e81853bc79e25359a7ee8a59e1 (patch)
tree571b20ba30443519247650955079ddde1a7306bb /media
parent380757ba5c927015d403e3b97cc418413330453e (diff)
downloadframeworks_av-942481eee58cb1e81853bc79e25359a7ee8a59e1.zip
frameworks_av-942481eee58cb1e81853bc79e25359a7ee8a59e1.tar.gz
frameworks_av-942481eee58cb1e81853bc79e25359a7ee8a59e1.tar.bz2
Fix freed memory references
MPEG4Source references memory owned by MPEG4Extractor, and therefore an MPEG4Extractor needs to be kept around as long as the MPEG4Sources obtained from it exist. Bug: 17890354 Change-Id: I399e18ec78517559ccc0914ffc7e099687c0ba51
Diffstat (limited to 'media')
-rw-r--r--media/libstagefright/MPEG4Extractor.cpp11
1 files changed, 8 insertions, 3 deletions
diff --git a/media/libstagefright/MPEG4Extractor.cpp b/media/libstagefright/MPEG4Extractor.cpp
index 1729f93..d922dc0 100644
--- a/media/libstagefright/MPEG4Extractor.cpp
+++ b/media/libstagefright/MPEG4Extractor.cpp
@@ -48,7 +48,8 @@ namespace android {
class MPEG4Source : public MediaSource {
public:
// Caller retains ownership of both "dataSource" and "sampleTable".
- MPEG4Source(const sp<MetaData> &format,
+ MPEG4Source(const sp<MPEG4Extractor> &owner,
+ const sp<MetaData> &format,
const sp<DataSource> &dataSource,
int32_t timeScale,
const sp<SampleTable> &sampleTable,
@@ -70,6 +71,8 @@ protected:
private:
Mutex mLock;
+ // keep the MPEG4Extractor around, since we're referencing its data
+ sp<MPEG4Extractor> mOwner;
sp<MetaData> mFormat;
sp<DataSource> mDataSource;
int32_t mTimescale;
@@ -2593,7 +2596,7 @@ sp<MediaSource> MPEG4Extractor::getTrack(size_t index) {
ALOGV("getTrack called, pssh: %zu", mPssh.size());
- return new MPEG4Source(
+ return new MPEG4Source(this,
track->meta, mDataSource, track->timescale, track->sampleTable,
mSidxEntries, trex, mMoofOffset);
}
@@ -2940,6 +2943,7 @@ status_t MPEG4Extractor::updateAudioTrackInfoFromESDS_MPEG4Audio(
////////////////////////////////////////////////////////////////////////////////
MPEG4Source::MPEG4Source(
+ const sp<MPEG4Extractor> &owner,
const sp<MetaData> &format,
const sp<DataSource> &dataSource,
int32_t timeScale,
@@ -2947,7 +2951,8 @@ MPEG4Source::MPEG4Source(
Vector<SidxEntry> &sidx,
const Trex *trex,
off64_t firstMoofOffset)
- : mFormat(format),
+ : mOwner(owner),
+ mFormat(format),
mDataSource(dataSource),
mTimescale(timeScale),
mSampleTable(sampleTable),