diff options
author | Andreas Huber <andih@google.com> | 2010-02-12 10:42:02 -0800 |
---|---|---|
committer | Andreas Huber <andih@google.com> | 2010-02-12 12:43:34 -0800 |
commit | 7b3396acc702451be9bafb19d7fe26d55d43a316 (patch) | |
tree | eadd21b8b9142e7f0ece40c4f6b8b55323b5dd6d /media/libstagefright/MPEG4Extractor.cpp | |
parent | 328901bdc7c00ab361c5ef16d0d69c94a0458e95 (diff) | |
download | frameworks_av-7b3396acc702451be9bafb19d7fe26d55d43a316.zip frameworks_av-7b3396acc702451be9bafb19d7fe26d55d43a316.tar.gz frameworks_av-7b3396acc702451be9bafb19d7fe26d55d43a316.tar.bz2 |
Squashed commit of the following:
commit 427e927298449826bb5b98327b0c05957aa051e6
Author: Andreas Huber <andih@google.com>
Date: Fri Feb 12 10:39:07 2010 -0800
Fixing a race condition in AwesomePlayer and support for suspend/resume.
commit 96201a04b6657b6bd69ec6100f4de66aebcaa0b4
Author: Andreas Huber <andih@google.com>
Date: Fri Feb 12 10:36:15 2010 -0800
Protect MPEG4Source's sanity by properly locking.
related-to-bug: 2231576
Diffstat (limited to 'media/libstagefright/MPEG4Extractor.cpp')
-rw-r--r-- | media/libstagefright/MPEG4Extractor.cpp | 14 |
1 files changed, 14 insertions, 0 deletions
diff --git a/media/libstagefright/MPEG4Extractor.cpp b/media/libstagefright/MPEG4Extractor.cpp index 666ed08..16635d3 100644 --- a/media/libstagefright/MPEG4Extractor.cpp +++ b/media/libstagefright/MPEG4Extractor.cpp @@ -60,6 +60,8 @@ protected: virtual ~MPEG4Source(); private: + Mutex mLock; + sp<MetaData> mFormat; sp<DataSource> mDataSource; int32_t mTimescale; @@ -1300,6 +1302,8 @@ MPEG4Source::~MPEG4Source() { } status_t MPEG4Source::start(MetaData *params) { + Mutex::Autolock autoLock(mLock); + CHECK(!mStarted); int32_t val; @@ -1325,6 +1329,8 @@ status_t MPEG4Source::start(MetaData *params) { } status_t MPEG4Source::stop() { + Mutex::Autolock autoLock(mLock); + CHECK(mStarted); if (mBuffer != NULL) { @@ -1345,6 +1351,8 @@ status_t MPEG4Source::stop() { } sp<MetaData> MPEG4Source::getFormat() { + Mutex::Autolock autoLock(mLock); + return mFormat; } @@ -1369,6 +1377,8 @@ size_t MPEG4Source::parseNALSize(const uint8_t *data) const { status_t MPEG4Source::read( MediaBuffer **out, const ReadOptions *options) { + Mutex::Autolock autoLock(mLock); + CHECK(mStarted); *out = NULL; @@ -1428,6 +1438,7 @@ status_t MPEG4Source::read( return ERROR_IO; } + CHECK(mBuffer != NULL); mBuffer->set_range(0, size); mBuffer->meta_data()->clear(); mBuffer->meta_data()->setInt64( @@ -1461,8 +1472,10 @@ status_t MPEG4Source::read( } MediaBuffer *clone = mBuffer->clone(); + CHECK(clone != NULL); clone->set_range(mBuffer->range_offset() + mNALLengthSize, nal_size); + CHECK(mBuffer != NULL); mBuffer->set_range( mBuffer->range_offset() + mNALLengthSize + nal_size, mBuffer->range_length() - mNALLengthSize - nal_size); @@ -1521,6 +1534,7 @@ status_t MPEG4Source::read( } CHECK_EQ(srcOffset, size); + CHECK(mBuffer != NULL); mBuffer->set_range(0, dstOffset); mBuffer->meta_data()->clear(); mBuffer->meta_data()->setInt64( |