From 803cbf6190f16f7b2c43cbc51d0df21ec888abdd Mon Sep 17 00:00:00 2001 From: Eino-Ville Talvala Date: Wed, 25 Jul 2012 15:23:36 -0700 Subject: Camera2: Use more buffers for video encoding. To avoid starvation, set the number of simultaneously available buffers to the encoder to 8. Bug: 6243944 Change-Id: I6d0e9f3c0426d62d374c0ae0d427bf5189141adf --- services/camera/libcameraservice/Camera2Client.cpp | 6 +++--- services/camera/libcameraservice/Camera2Client.h | 5 +++-- 2 files changed, 6 insertions(+), 5 deletions(-) (limited to 'services/camera/libcameraservice') diff --git a/services/camera/libcameraservice/Camera2Client.cpp b/services/camera/libcameraservice/Camera2Client.cpp index 2e1940a..47d1588 100644 --- a/services/camera/libcameraservice/Camera2Client.cpp +++ b/services/camera/libcameraservice/Camera2Client.cpp @@ -769,7 +769,7 @@ void Camera2Client::releaseRecordingFrame(const sp& mem) { } buffer_handle_t imgBuffer = *(buffer_handle_t*)(data + 4); ALOGV("%s: Camera %d: Freeing buffer_handle_t %p", __FUNCTION__, mCameraId, - imgBuffer, *(uint32_t*)(data + 4)); + imgBuffer); res = mRecordingConsumer->freeBuffer(imgBuffer); if (res != OK) { ALOGE("%s: Camera %d: Unable to free recording frame (buffer_handle_t: %p):" @@ -1623,7 +1623,7 @@ void Camera2Client::onRecordingFrameAvailable() { memcpy(data, &type, 4); memcpy(data + 4, &imgBuffer, sizeof(buffer_handle_t)); ALOGV("%s: Camera %d: Sending out buffer_handle_t %p", - __FUNCTION__, mCameraId, imgBuffer, *(uint32_t*)(data + 4)); + __FUNCTION__, mCameraId, imgBuffer); currentClient = mCameraClient; } // Call outside mICameraLock to allow re-entrancy from notification @@ -2615,7 +2615,7 @@ status_t Camera2Client::updateRecordingStream() { if (mRecordingConsumer == 0) { // Create CPU buffer queue endpoint - mRecordingConsumer = new MediaConsumer(4); + mRecordingConsumer = new MediaConsumer(kRecordingHeapCount); mRecordingConsumer->setFrameAvailableListener(new RecordingWaiter(this)); mRecordingConsumer->setName(String8("Camera2Client::RecordingConsumer")); mRecordingWindow = new SurfaceTextureClient( diff --git a/services/camera/libcameraservice/Camera2Client.h b/services/camera/libcameraservice/Camera2Client.h index d7836ca..83fe94e 100644 --- a/services/camera/libcameraservice/Camera2Client.h +++ b/services/camera/libcameraservice/Camera2Client.h @@ -238,8 +238,9 @@ private: sp mRecordingHeap; // TODO: This needs to be queried from somewhere, or the BufferQueue needs - // to be passed all the way to stagefright - static const size_t kRecordingHeapCount = 4; + // to be passed all the way to stagefright. Right now, set to a large number + // to avoid starvation of the video encoders. + static const size_t kRecordingHeapCount = 8; size_t mRecordingHeapHead, mRecordingHeapFree; // Handle new recording image buffers void onRecordingFrameAvailable(); -- cgit v1.1