summaryrefslogtreecommitdiffstats
path: root/services/camera/libcameraservice/Camera2Client.cpp
diff options
context:
space:
mode:
authorEino-Ville Talvala <etalvala@google.com>2012-10-05 11:22:12 -0700
committerAndroid Git Automerger <android-git-automerger@android.com>2012-10-05 11:22:12 -0700
commit577ac8a74e8af7fcc7bc714874b8da21f57989b5 (patch)
tree1a9d2465bbd037a7d7bbc657cc44295363632fed /services/camera/libcameraservice/Camera2Client.cpp
parent6c9282d3bb5082266cfd9042f62ceea131e5b849 (diff)
parent4865c526e681366481b0ab242ffa1ead57bb02cc (diff)
downloadframeworks_av-577ac8a74e8af7fcc7bc714874b8da21f57989b5.zip
frameworks_av-577ac8a74e8af7fcc7bc714874b8da21f57989b5.tar.gz
frameworks_av-577ac8a74e8af7fcc7bc714874b8da21f57989b5.tar.bz2
am 4865c526: Camera2: Synchronize mode changes and triggers
* commit '4865c526e681366481b0ab242ffa1ead57bb02cc': Camera2: Synchronize mode changes and triggers
Diffstat (limited to 'services/camera/libcameraservice/Camera2Client.cpp')
-rw-r--r--services/camera/libcameraservice/Camera2Client.cpp65
1 files changed, 57 insertions, 8 deletions
diff --git a/services/camera/libcameraservice/Camera2Client.cpp b/services/camera/libcameraservice/Camera2Client.cpp
index 948b59f..9bcaef1 100644
--- a/services/camera/libcameraservice/Camera2Client.cpp
+++ b/services/camera/libcameraservice/Camera2Client.cpp
@@ -536,7 +536,7 @@ status_t Camera2Client::setPreviewWindowL(const sp<IBinder>& binder,
// Already running preview - need to stop and create a new stream
// TODO: Optimize this so that we don't wait for old stream to drain
// before spinning up new stream
- mDevice->clearStreamingRequest();
+ mStreamingProcessor->stopStream();
l.mParameters.state = Parameters::WAITING_FOR_PREVIEW_WINDOW;
break;
}
@@ -719,6 +719,7 @@ void Camera2Client::stopPreview() {
void Camera2Client::stopPreviewL() {
ATRACE_CALL();
+ status_t res;
Parameters::State state;
{
SharedParameters::Lock l(mParameters);
@@ -740,6 +741,11 @@ void Camera2Client::stopPreviewL() {
// no break - identical to preview
case Parameters::PREVIEW:
mStreamingProcessor->stopStream();
+ res = mDevice->waitUntilDrained();
+ if (res != OK) {
+ ALOGE("%s: Camera %d: Waiting to stop streaming failed: %s (%d)",
+ __FUNCTION__, mCameraId, strerror(-res), res);
+ }
// no break
case Parameters::WAITING_FOR_PREVIEW_WINDOW: {
SharedParameters::Lock l(mParameters);
@@ -946,9 +952,14 @@ status_t Camera2Client::autoFocus() {
int triggerId;
{
SharedParameters::Lock l(mParameters);
+ if (l.mParameters.state < Parameters::PREVIEW) {
+ return INVALID_OPERATION;
+ }
+
l.mParameters.currentAfTriggerId = ++l.mParameters.afTriggerCounter;
triggerId = l.mParameters.currentAfTriggerId;
}
+ syncWithDevice();
mDevice->triggerAutofocus(triggerId);
@@ -967,6 +978,7 @@ status_t Camera2Client::cancelAutoFocus() {
SharedParameters::Lock l(mParameters);
triggerId = ++l.mParameters.afTriggerCounter;
}
+ syncWithDevice();
mDevice->triggerCancelAutofocus(triggerId);
@@ -1017,6 +1029,9 @@ status_t Camera2Client::takePicture(int msgType) {
return res;
}
+ // Need HAL to have correct settings before (possibly) triggering precapture
+ syncWithDevice();
+
res = mCaptureSequencer->startCapture();
if (res != OK) {
ALOGE("%s: Camera %d: Unable to start capture: %s (%d)",
@@ -1397,13 +1412,18 @@ int Camera2Client::getZslStreamId() const {
return mZslProcessor->getStreamId();
}
-status_t Camera2Client::registerFrameListener(int32_t id,
+status_t Camera2Client::registerFrameListener(int32_t minId, int32_t maxId,
+ wp<camera2::FrameProcessor::FilteredListener> listener) {
+ return mFrameProcessor->registerListener(minId, maxId, listener);
+}
+
+status_t Camera2Client::removeFrameListener(int32_t minId, int32_t maxId,
wp<camera2::FrameProcessor::FilteredListener> listener) {
- return mFrameProcessor->registerListener(id, listener);
+ return mFrameProcessor->removeListener(minId, maxId, listener);
}
-status_t Camera2Client::removeFrameListener(int32_t id) {
- return mFrameProcessor->removeListener(id);
+status_t Camera2Client::stopStream() {
+ return mStreamingProcessor->stopStream();
}
Camera2Client::SharedCameraClient::Lock::Lock(SharedCameraClient &client):
@@ -1432,9 +1452,12 @@ void Camera2Client::SharedCameraClient::clear() {
mCameraClient.clear();
}
-const int32_t Camera2Client::kPreviewRequestId;
-const int32_t Camera2Client::kRecordRequestId;
-const int32_t Camera2Client::kFirstCaptureRequestId;
+const int32_t Camera2Client::kPreviewRequestIdStart;
+const int32_t Camera2Client::kPreviewRequestIdEnd;
+const int32_t Camera2Client::kRecordingRequestIdStart;
+const int32_t Camera2Client::kRecordingRequestIdEnd;
+const int32_t Camera2Client::kCaptureRequestIdStart;
+const int32_t Camera2Client::kCaptureRequestIdEnd;
/** Utility methods */
@@ -1443,6 +1466,13 @@ status_t Camera2Client::updateRequests(Parameters &params) {
ALOGV("%s: Camera %d: state = %d", __FUNCTION__, getCameraId(), params.state);
+ res = mStreamingProcessor->incrementStreamingIds();
+ if (res != OK) {
+ ALOGE("%s: Camera %d: Unable to increment request IDs: %s (%d)",
+ __FUNCTION__, mCameraId, strerror(-res), res);
+ return res;
+ }
+
res = mStreamingProcessor->updatePreviewRequest(params);
if (res != OK) {
ALOGE("%s: Camera %d: Unable to update preview request: %s (%d)",
@@ -1504,4 +1534,23 @@ size_t Camera2Client::calculateBufferSize(int width, int height,
}
}
+status_t Camera2Client::syncWithDevice() {
+ ATRACE_CALL();
+ const nsecs_t kMaxSyncTimeout = 100000000; // 100 ms
+ status_t res;
+
+ int32_t activeRequestId = mStreamingProcessor->getActiveRequestId();
+ if (activeRequestId == 0) return OK;
+
+ res = mDevice->waitUntilRequestReceived(activeRequestId, kMaxSyncTimeout);
+ if (res == TIMED_OUT) {
+ ALOGE("%s: Camera %d: Timed out waiting sync with HAL",
+ __FUNCTION__, mCameraId);
+ } else if (res != OK) {
+ ALOGE("%s: Camera %d: Error while waiting to sync with HAL",
+ __FUNCTION__, mCameraId);
+ }
+ return res;
+}
+
} // namespace android