summaryrefslogtreecommitdiffstats
path: root/media/libstagefright/CameraSource.cpp
diff options
context:
space:
mode:
authorJames Dong <jdong@google.com>2012-08-01 16:39:55 -0700
committerJames Dong <jdong@google.com>2012-08-02 17:06:05 -0700
commit983cf231ab2d176a14595cdae46ff1b0c239af47 (patch)
tree01942a13a082e2116f8df5dbaca1a902ac52a299 /media/libstagefright/CameraSource.cpp
parent15d7245ed2193e4956ea87998321cbc16a3b0a46 (diff)
downloadframeworks_av-983cf231ab2d176a14595cdae46ff1b0c239af47.zip
frameworks_av-983cf231ab2d176a14595cdae46ff1b0c239af47.tar.gz
frameworks_av-983cf231ab2d176a14595cdae46ff1b0c239af47.tar.bz2
Dynamically configure the number of video buffers used by camera source, if supported
o related-to-bug: 6920805 Change-Id: I413bb50954cc84e32ed40bcb713842dc7b58e2b6
Diffstat (limited to 'media/libstagefright/CameraSource.cpp')
-rwxr-xr-xmedia/libstagefright/CameraSource.cpp28
1 files changed, 25 insertions, 3 deletions
diff --git a/media/libstagefright/CameraSource.cpp b/media/libstagefright/CameraSource.cpp
index a604c8f..efd7af7 100755
--- a/media/libstagefright/CameraSource.cpp
+++ b/media/libstagefright/CameraSource.cpp
@@ -155,6 +155,7 @@ CameraSource::CameraSource(
const sp<Surface>& surface,
bool storeMetaDataInVideoBuffers)
: mCameraFlags(0),
+ mNumInputBuffers(0),
mVideoFrameRate(-1),
mCamera(0),
mSurface(surface),
@@ -571,6 +572,18 @@ void CameraSource::startCameraRecording() {
// camera and recording is started by the applications. The applications
// will connect to the camera in ICameraRecordingProxy::startRecording.
int64_t token = IPCThreadState::self()->clearCallingIdentity();
+ if (mNumInputBuffers > 0) {
+ status_t err = mCamera->sendCommand(
+ CAMERA_CMD_SET_VIDEO_BUFFER_COUNT, mNumInputBuffers, 0);
+
+ // This could happen for CameraHAL1 clients; thus the failure is
+ // not a fatal error
+ if (err != OK) {
+ ALOGW("Failed to set video buffer count to %d due to %d",
+ mNumInputBuffers, err);
+ }
+ }
+
if (mCameraFlags & FLAGS_HOT_CAMERA) {
mCamera->unlock();
mCamera.clear();
@@ -599,9 +612,18 @@ status_t CameraSource::start(MetaData *meta) {
}
mStartTimeUs = 0;
- int64_t startTimeUs;
- if (meta && meta->findInt64(kKeyTime, &startTimeUs)) {
- mStartTimeUs = startTimeUs;
+ mNumInputBuffers = 0;
+ if (meta) {
+ int64_t startTimeUs;
+ if (meta->findInt64(kKeyTime, &startTimeUs)) {
+ mStartTimeUs = startTimeUs;
+ }
+
+ int32_t nBuffers;
+ if (meta->findInt32(kKeyNumBuffers, &nBuffers)) {
+ CHECK_GT(nBuffers, 0);
+ mNumInputBuffers = nBuffers;
+ }
}
startCameraRecording();