From a0ead0a2d2ce1d114ad3a17d755dddce831abb40 Mon Sep 17 00:00:00 2001 From: Jamie Gennis Date: Thu, 23 Aug 2012 20:24:09 -0700 Subject: SurfaceMediaSource: a few fixes / cleanups - Remove the setting of mStopped to true in onBuffersReleased - Cleaned up a few function call logs - Removed the 'reset' method. Change-Id: I56bab1d5cb2f3e6d59d54698c2e045d796d1849f --- include/media/stagefright/SurfaceMediaSource.h | 9 +++------ media/libstagefright/SurfaceMediaSource.cpp | 28 +++++++++++--------------- 2 files changed, 15 insertions(+), 22 deletions(-) diff --git a/include/media/stagefright/SurfaceMediaSource.h b/include/media/stagefright/SurfaceMediaSource.h index 4a8e221..724c68d 100644 --- a/include/media/stagefright/SurfaceMediaSource.h +++ b/include/media/stagefright/SurfaceMediaSource.h @@ -73,10 +73,9 @@ public: // For the MediaSource interface for use by StageFrightRecorder: virtual status_t start(MetaData *params = NULL); - - virtual status_t stop() { return reset(); } - virtual status_t read( - MediaBuffer **buffer, const ReadOptions *options = NULL); + virtual status_t stop(); + virtual status_t read(MediaBuffer **buffer, + const ReadOptions *options = NULL); virtual sp getFormat(); // Get / Set the frame rate used for encoding. Default fps = 30 @@ -204,8 +203,6 @@ private: // is a frame available for dequeuing Condition mFrameAvailableCondition; - status_t reset(); - // Avoid copying and equating and default constructor DISALLOW_IMPLICIT_CONSTRUCTORS(SurfaceMediaSource); }; diff --git a/media/libstagefright/SurfaceMediaSource.cpp b/media/libstagefright/SurfaceMediaSource.cpp index f1f444e..f5c8c93 100644 --- a/media/libstagefright/SurfaceMediaSource.cpp +++ b/media/libstagefright/SurfaceMediaSource.cpp @@ -46,7 +46,7 @@ SurfaceMediaSource::SurfaceMediaSource(uint32_t bufferWidth, uint32_t bufferHeig mNumFramesEncoded(0), mFirstFrameTimestamp(0) { - ALOGV("SurfaceMediaSource::SurfaceMediaSource"); + ALOGV("SurfaceMediaSource"); if (bufferWidth == 0 || bufferHeight == 0) { ALOGE("Invalid dimensions %dx%d", bufferWidth, bufferHeight); @@ -77,21 +77,19 @@ SurfaceMediaSource::SurfaceMediaSource(uint32_t bufferWidth, uint32_t bufferHeig } SurfaceMediaSource::~SurfaceMediaSource() { - ALOGV("SurfaceMediaSource::~SurfaceMediaSource"); - if (!mStopped) { - reset(); - } + ALOGV("~SurfaceMediaSource"); + CHECK(mStopped == true); } nsecs_t SurfaceMediaSource::getTimestamp() { - ALOGV("SurfaceMediaSource::getTimestamp"); + ALOGV("getTimestamp"); Mutex::Autolock lock(mMutex); return mCurrentTimestamp; } void SurfaceMediaSource::setFrameAvailableListener( const sp& listener) { - ALOGV("SurfaceMediaSource::setFrameAvailableListener"); + ALOGV("setFrameAvailableListener"); Mutex::Autolock lock(mMutex); mFrameAvailableListener = listener; } @@ -113,6 +111,7 @@ void SurfaceMediaSource::dump(String8& result, const char* prefix, status_t SurfaceMediaSource::setFrameRate(int32_t fps) { + ALOGV("setFrameRate"); Mutex::Autolock lock(mMutex); const int MAX_FRAME_RATE = 60; if (fps < 0 || fps > MAX_FRAME_RATE) { @@ -128,13 +127,14 @@ bool SurfaceMediaSource::isMetaDataStoredInVideoBuffers() const { } int32_t SurfaceMediaSource::getFrameRate( ) const { + ALOGV("getFrameRate"); Mutex::Autolock lock(mMutex); return mFrameRate; } status_t SurfaceMediaSource::start(MetaData *params) { - ALOGV("started!"); + ALOGV("start"); mStartTimeNs = 0; int64_t startTimeUs; @@ -146,18 +146,15 @@ status_t SurfaceMediaSource::start(MetaData *params) } -status_t SurfaceMediaSource::reset() +status_t SurfaceMediaSource::stop() { - ALOGV("Reset"); - + ALOGV("stop"); Mutex::Autolock lock(mMutex); - // TODO: Add waiting on mFrameCompletedCondition here? - mStopped = true; + mStopped = true; mFrameAvailableCondition.signal(); - mBufferQueue->consumerDisconnect(); - return OK; + return mBufferQueue->consumerDisconnect(); } sp SurfaceMediaSource::getFormat() @@ -376,7 +373,6 @@ void SurfaceMediaSource::onBuffersReleased() { Mutex::Autolock lock(mMutex); mFrameAvailableCondition.signal(); - mStopped = true; for (int i = 0; i < BufferQueue::NUM_BUFFER_SLOTS; i++) { mBufferSlot[i] = 0; -- cgit v1.1