summaryrefslogtreecommitdiffstats
path: root/media/libstagefright/MediaAdapter.cpp
diff options
context:
space:
mode:
authorxiaoqiny <quic_xiaoqiny@codeaurora.org>2015-01-13 17:59:04 +0800
committerSteve Kondik <steve@cyngn.com>2016-04-13 13:54:55 -0700
commitf888cedf170f6d3cc060cc14ad9c56918f3a03c3 (patch)
tree666c429913ec56e43948136169c3b46d50173745 /media/libstagefright/MediaAdapter.cpp
parent0ecd6fb627dabf286b7742862e25a592bc1f606c (diff)
downloadframeworks_av-f888cedf170f6d3cc060cc14ad9c56918f3a03c3.zip
frameworks_av-f888cedf170f6d3cc060cc14ad9c56918f3a03c3.tar.gz
frameworks_av-f888cedf170f6d3cc060cc14ad9c56918f3a03c3.tar.bz2
libstagefright: handle error when B-frame is sent to MPEG4Writer
Without this patch, writing B-frame to MediaMuxer will be blocked and cannot return a result. This may cause an endless progress bar shown in gallery when triming or muting some videos. Change-Id: Ib9f902a57da470c0357ec68aab00a35fbb26fb77 CRs-Fixed: 521005
Diffstat (limited to 'media/libstagefright/MediaAdapter.cpp')
-rw-r--r--media/libstagefright/MediaAdapter.cpp18
1 files changed, 16 insertions, 2 deletions
diff --git a/media/libstagefright/MediaAdapter.cpp b/media/libstagefright/MediaAdapter.cpp
index d680e0c..ec4550f 100644
--- a/media/libstagefright/MediaAdapter.cpp
+++ b/media/libstagefright/MediaAdapter.cpp
@@ -27,7 +27,8 @@ namespace android {
MediaAdapter::MediaAdapter(const sp<MetaData> &meta)
: mCurrentMediaBuffer(NULL),
mStarted(false),
- mOutputFormat(meta) {
+ mOutputFormat(meta),
+ mStatus(OK) {
}
MediaAdapter::~MediaAdapter() {
@@ -51,6 +52,9 @@ status_t MediaAdapter::stop() {
// If stop() happens immediately after a pushBuffer(), we should
// clean up the mCurrentMediaBuffer
if (mCurrentMediaBuffer != NULL) {
+ mCurrentMediaBuffer->setObserver(this);
+ mCurrentMediaBuffer->claim();
+ mCurrentMediaBuffer->setObserver(0);
mCurrentMediaBuffer->release();
mCurrentMediaBuffer = NULL;
}
@@ -113,13 +117,23 @@ status_t MediaAdapter::pushBuffer(MediaBuffer *buffer) {
ALOGE("pushBuffer called before start");
return INVALID_OPERATION;
}
+ if (mStatus != OK) {
+ ALOGE("pushBuffer called when MediaAdapter in error status");
+ return mStatus;
+ }
mCurrentMediaBuffer = buffer;
mBufferReadCond.signal();
ALOGV("wait for the buffer returned @ pushBuffer! %p", buffer);
mBufferReturnedCond.wait(mAdapterLock);
- return OK;
+ return mStatus;
+}
+
+void MediaAdapter::notifyError(status_t err) {
+ Mutex::Autolock autoLock(mAdapterLock);
+ mStatus = err;
+ mBufferReturnedCond.signal();
}
} // namespace android