diff options
author | James Dong <jdong@google.com> | 2011-01-25 15:33:27 -0800 |
---|---|---|
committer | Android Git Automerger <android-git-automerger@android.com> | 2011-01-25 15:33:27 -0800 |
commit | 5895b78183840f3d56a6e50af26a4b9f778a5b14 (patch) | |
tree | 31e2137478b262747aa71e84bfa8b632f96135ad | |
parent | 47fac46eeb5f522fc964bcaadf27512e29d691fb (diff) | |
parent | eaae38445a340c4857c1c5569475879a728e63b7 (diff) | |
download | frameworks_av-5895b78183840f3d56a6e50af26a4b9f778a5b14.zip frameworks_av-5895b78183840f3d56a6e50af26a4b9f778a5b14.tar.gz frameworks_av-5895b78183840f3d56a6e50af26a4b9f778a5b14.tar.bz2 |
am 3115dad3: Merge "Report errors to applications if AudioRecord->start() fails" into honeycomb
* commit '3115dad3fc8493ff510b9f6a46b18d951bf5c162':
Report errors to applications if AudioRecord->start() fails
-rw-r--r-- | media/libstagefright/AudioSource.cpp | 5 | ||||
-rw-r--r-- | media/libstagefright/MPEG4Writer.cpp | 9 | ||||
-rw-r--r-- | media/libstagefright/codecs/aacenc/AACEncoder.cpp | 26 |
3 files changed, 27 insertions, 13 deletions
diff --git a/media/libstagefright/AudioSource.cpp b/media/libstagefright/AudioSource.cpp index 235d752..f96df18 100644 --- a/media/libstagefright/AudioSource.cpp +++ b/media/libstagefright/AudioSource.cpp @@ -91,14 +91,17 @@ status_t AudioSource::start(MetaData *params) { mStartTimeUs = startTimeUs; } status_t err = mRecord->start(); - if (err == OK) { mGroup = new MediaBufferGroup; mGroup->add_buffer(new MediaBuffer(kMaxBufferSize)); mStarted = true; + } else { + delete mRecord; + mRecord = NULL; } + return err; } diff --git a/media/libstagefright/MPEG4Writer.cpp b/media/libstagefright/MPEG4Writer.cpp index a47ee3a..d1a497f 100644 --- a/media/libstagefright/MPEG4Writer.cpp +++ b/media/libstagefright/MPEG4Writer.cpp @@ -78,6 +78,7 @@ private: volatile bool mDone; volatile bool mPaused; volatile bool mResumed; + volatile bool mStarted; bool mIsAvc; bool mIsAudio; bool mIsMPEG4; @@ -951,6 +952,7 @@ MPEG4Writer::Track::Track( mDone(false), mPaused(false), mResumed(false), + mStarted(false), mTrackDurationUs(0), mEstimatedTrackSizeBytes(0), mSamplesHaveSameSize(true), @@ -1279,6 +1281,7 @@ status_t MPEG4Writer::Track::start(MetaData *params) { pthread_attr_setdetachstate(&attr, PTHREAD_CREATE_JOINABLE); mDone = false; + mStarted = true; mTrackDurationUs = 0; mReachedEOS = false; mEstimatedTrackSizeBytes = 0; @@ -1307,10 +1310,14 @@ status_t MPEG4Writer::Track::pause() { status_t MPEG4Writer::Track::stop() { LOGD("Stopping %s track", mIsAudio? "Audio": "Video"); + if (!mStarted) { + LOGE("Stop() called but track is not started"); + return ERROR_END_OF_STREAM; + } + if (mDone) { return OK; } - mDone = true; void *dummy; diff --git a/media/libstagefright/codecs/aacenc/AACEncoder.cpp b/media/libstagefright/codecs/aacenc/AACEncoder.cpp index 9524884..a8b1292 100644 --- a/media/libstagefright/codecs/aacenc/AACEncoder.cpp +++ b/media/libstagefright/codecs/aacenc/AACEncoder.cpp @@ -151,7 +151,11 @@ status_t AACEncoder::start(MetaData *params) { mInputFrame = new int16_t[mChannels * kNumSamplesPerFrame]; CHECK(mInputFrame != NULL); - mSource->start(params); + status_t err = mSource->start(params); + if (err != OK) { + LOGE("AudioSource is not available"); + return err; + } mStarted = true; @@ -159,11 +163,6 @@ status_t AACEncoder::start(MetaData *params) { } status_t AACEncoder::stop() { - if (!mStarted) { - LOGW("Call stop() when encoder has not started"); - return OK; - } - if (mInputBuffer) { mInputBuffer->release(); mInputBuffer = NULL; @@ -172,8 +171,17 @@ status_t AACEncoder::stop() { delete mBufferGroup; mBufferGroup = NULL; - mSource->stop(); + if (mInputFrame) { + delete[] mInputFrame; + mInputFrame = NULL; + } + + if (!mStarted) { + LOGW("Call stop() when encoder has not started"); + return ERROR_END_OF_STREAM; + } + mSource->stop(); if (mEncoderHandle) { CHECK_EQ(VO_ERR_NONE, mApiHandle->Uninit(mEncoderHandle)); mEncoderHandle = NULL; @@ -182,10 +190,6 @@ status_t AACEncoder::stop() { mApiHandle = NULL; mStarted = false; - if (mInputFrame) { - delete[] mInputFrame; - mInputFrame = NULL; - } return OK; } |