summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJamie Gennis <jgennis@google.com>2012-08-26 16:28:14 -0700
committerAndroid (Google) Code Review <android-gerrit@google.com>2012-08-26 16:28:14 -0700
commit690921927f289da73556ea71c28981194af8ffcd (patch)
treee4bef9233f3f73be80d44ee99dd140e933a4c723
parent96272d57caa39566842795ba1f0605a5a5f72272 (diff)
parenta0ead0a2d2ce1d114ad3a17d755dddce831abb40 (diff)
downloadframeworks_av-690921927f289da73556ea71c28981194af8ffcd.zip
frameworks_av-690921927f289da73556ea71c28981194af8ffcd.tar.gz
frameworks_av-690921927f289da73556ea71c28981194af8ffcd.tar.bz2
Merge "SurfaceMediaSource: a few fixes / cleanups" into jb-mr1-dev
-rw-r--r--include/media/stagefright/SurfaceMediaSource.h9
-rw-r--r--media/libstagefright/SurfaceMediaSource.cpp28
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<MetaData> 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<FrameAvailableListener>& 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<MetaData> 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;