diff options
author | Chong Zhang <chz@google.com> | 2014-10-04 01:35:42 +0000 |
---|---|---|
committer | Android (Google) Code Review <android-gerrit@google.com> | 2014-10-04 01:35:43 +0000 |
commit | f0011d49c0f08753dc2dc254c5a70885a9986602 (patch) | |
tree | e6316e9316180b2ec5d63b6dae526343e0c206c2 | |
parent | af1a4dc989d6707116eaefab300ad55124aace66 (diff) | |
parent | f2a64852a4a48c5a3d8a08ffcda20d6884586672 (diff) | |
download | frameworks_av-f0011d49c0f08753dc2dc254c5a70885a9986602.zip frameworks_av-f0011d49c0f08753dc2dc254c5a70885a9986602.tar.gz frameworks_av-f0011d49c0f08753dc2dc254c5a70885a9986602.tar.bz2 |
Merge "MediaRecorder: only dequeue available buffers from MediaCodec" into lmp-dev
-rw-r--r-- | include/media/stagefright/MediaCodecSource.h | 2 | ||||
-rw-r--r-- | media/libstagefright/MediaCodecSource.cpp | 19 |
2 files changed, 15 insertions, 6 deletions
diff --git a/include/media/stagefright/MediaCodecSource.h b/include/media/stagefright/MediaCodecSource.h index e1b2830..3629c8b 100644 --- a/include/media/stagefright/MediaCodecSource.h +++ b/include/media/stagefright/MediaCodecSource.h @@ -86,7 +86,7 @@ private: void releaseEncoder(); status_t feedEncoderInputBuffers(); void scheduleDoMoreWork(); - status_t doMoreWork(); + status_t doMoreWork(int32_t numInput, int32_t numOutput); void suspend(); void resume(int64_t skipFramesBeforeUs = -1ll); void signalEOS(status_t err = ERROR_END_OF_STREAM); diff --git a/media/libstagefright/MediaCodecSource.cpp b/media/libstagefright/MediaCodecSource.cpp index 27cd231..0fecda8 100644 --- a/media/libstagefright/MediaCodecSource.cpp +++ b/media/libstagefright/MediaCodecSource.cpp @@ -615,11 +615,11 @@ status_t MediaCodecSource::feedEncoderInputBuffers() { return OK; } -status_t MediaCodecSource::doMoreWork() { - status_t err; +status_t MediaCodecSource::doMoreWork(int32_t numInput, int32_t numOutput) { + status_t err = OK; if (!(mFlags & FLAG_USE_SURFACE_INPUT)) { - for (;;) { + while (numInput-- > 0) { size_t bufferIndex; err = mEncoder->dequeueInputBuffer(&bufferIndex); @@ -633,7 +633,7 @@ status_t MediaCodecSource::doMoreWork() { feedEncoderInputBuffers(); } - for (;;) { + while (numOutput-- > 0) { size_t bufferIndex; size_t offset; size_t size; @@ -805,7 +805,16 @@ void MediaCodecSource::onMessageReceived(const sp<AMessage> &msg) { break; } - status_t err = doMoreWork(); + int32_t numInput, numOutput; + + if (!msg->findInt32("input-buffers", &numInput)) { + numInput = INT32_MAX; + } + if (!msg->findInt32("output-buffers", &numOutput)) { + numOutput = INT32_MAX; + } + + status_t err = doMoreWork(numInput, numOutput); if (err == OK) { scheduleDoMoreWork(); |