summaryrefslogtreecommitdiffstats
path: root/services
diff options
context:
space:
mode:
authorEino-Ville Talvala <etalvala@google.com>2014-03-07 18:31:19 +0000
committerAndroid Git Automerger <android-git-automerger@android.com>2014-03-07 18:31:19 +0000
commit6a7b53008ac0831431f42c620d2988c65b21d859 (patch)
treed48189392e641c2f38b595ea170943e8b8f70c76 /services
parent7d37d4eca3867773cf5cbb81533af0462be8a60f (diff)
parenta11111f9135c98cf4247bbd1a61d7df3053e549e (diff)
downloadframeworks_av-6a7b53008ac0831431f42c620d2988c65b21d859.zip
frameworks_av-6a7b53008ac0831431f42c620d2988c65b21d859.tar.gz
frameworks_av-6a7b53008ac0831431f42c620d2988c65b21d859.tar.bz2
am a11111f9: Merge changes Id28b35fd,Ie4e64977,I2950f31e into klp-dev
* commit 'a11111f9135c98cf4247bbd1a61d7df3053e549e': DO NOT MERGE: Camera: fix focusArea wrong indexing issue DO NOT MERGE: camera2: Fix race with stream deletion during disconnect. DO NOT MERGE: camera2/3: Add protection for still capture path
Diffstat (limited to 'services')
-rw-r--r--services/camera/libcameraservice/api1/Camera2Client.cpp14
-rw-r--r--services/camera/libcameraservice/api1/client2/JpegProcessor.cpp79
-rw-r--r--services/camera/libcameraservice/api1/client2/Parameters.cpp28
3 files changed, 66 insertions, 55 deletions
diff --git a/services/camera/libcameraservice/api1/Camera2Client.cpp b/services/camera/libcameraservice/api1/Camera2Client.cpp
index ba1e772..50a5084 100644
--- a/services/camera/libcameraservice/api1/Camera2Client.cpp
+++ b/services/camera/libcameraservice/api1/Camera2Client.cpp
@@ -407,12 +407,6 @@ void Camera2Client::disconnect() {
l.mParameters.state = Parameters::DISCONNECTED;
}
- mStreamingProcessor->deletePreviewStream();
- mStreamingProcessor->deleteRecordingStream();
- mJpegProcessor->deleteStream();
- mCallbackProcessor->deleteStream();
- mZslProcessor->deleteStream();
-
mStreamingProcessor->requestExit();
mFrameProcessor->requestExit();
mCaptureSequencer->requestExit();
@@ -429,6 +423,14 @@ void Camera2Client::disconnect() {
mZslProcessorThread->join();
mCallbackProcessor->join();
+ ALOGV("Camera %d: Deleting streams", mCameraId);
+
+ mStreamingProcessor->deletePreviewStream();
+ mStreamingProcessor->deleteRecordingStream();
+ mJpegProcessor->deleteStream();
+ mCallbackProcessor->deleteStream();
+ mZslProcessor->deleteStream();
+
ALOGV("Camera %d: Disconnecting device", mCameraId);
mDevice->disconnect();
diff --git a/services/camera/libcameraservice/api1/client2/JpegProcessor.cpp b/services/camera/libcameraservice/api1/client2/JpegProcessor.cpp
index 77d5c8a..ec81456 100644
--- a/services/camera/libcameraservice/api1/client2/JpegProcessor.cpp
+++ b/services/camera/libcameraservice/api1/client2/JpegProcessor.cpp
@@ -200,50 +200,59 @@ status_t JpegProcessor::processNewCapture() {
ATRACE_CALL();
status_t res;
sp<Camera2Heap> captureHeap;
+ sp<MemoryBase> captureBuffer;
CpuConsumer::LockedBuffer imgBuffer;
- res = mCaptureConsumer->lockNextBuffer(&imgBuffer);
- if (res != OK) {
- if (res != BAD_VALUE) {
- ALOGE("%s: Camera %d: Error receiving still image buffer: "
- "%s (%d)", __FUNCTION__,
- mId, strerror(-res), res);
+ {
+ Mutex::Autolock l(mInputMutex);
+ if (mCaptureStreamId == NO_STREAM) {
+ ALOGW("%s: Camera %d: No stream is available", __FUNCTION__, mId);
+ return INVALID_OPERATION;
}
- return res;
- }
- ALOGV("%s: Camera %d: Still capture available", __FUNCTION__,
- mId);
+ res = mCaptureConsumer->lockNextBuffer(&imgBuffer);
+ if (res != OK) {
+ if (res != BAD_VALUE) {
+ ALOGE("%s: Camera %d: Error receiving still image buffer: "
+ "%s (%d)", __FUNCTION__,
+ mId, strerror(-res), res);
+ }
+ return res;
+ }
- if (imgBuffer.format != HAL_PIXEL_FORMAT_BLOB) {
- ALOGE("%s: Camera %d: Unexpected format for still image: "
- "%x, expected %x", __FUNCTION__, mId,
- imgBuffer.format,
- HAL_PIXEL_FORMAT_BLOB);
- mCaptureConsumer->unlockBuffer(imgBuffer);
- return OK;
- }
+ ALOGV("%s: Camera %d: Still capture available", __FUNCTION__,
+ mId);
- // Find size of JPEG image
- size_t jpegSize = findJpegSize(imgBuffer.data, imgBuffer.width);
- if (jpegSize == 0) { // failed to find size, default to whole buffer
- jpegSize = imgBuffer.width;
- }
- size_t heapSize = mCaptureHeap->getSize();
- if (jpegSize > heapSize) {
- ALOGW("%s: JPEG image is larger than expected, truncating "
- "(got %d, expected at most %d bytes)",
- __FUNCTION__, jpegSize, heapSize);
- jpegSize = heapSize;
- }
+ if (imgBuffer.format != HAL_PIXEL_FORMAT_BLOB) {
+ ALOGE("%s: Camera %d: Unexpected format for still image: "
+ "%x, expected %x", __FUNCTION__, mId,
+ imgBuffer.format,
+ HAL_PIXEL_FORMAT_BLOB);
+ mCaptureConsumer->unlockBuffer(imgBuffer);
+ return OK;
+ }
- // TODO: Optimize this to avoid memcopy
- sp<MemoryBase> captureBuffer = new MemoryBase(mCaptureHeap, 0, jpegSize);
- void* captureMemory = mCaptureHeap->getBase();
- memcpy(captureMemory, imgBuffer.data, jpegSize);
+ // Find size of JPEG image
+ size_t jpegSize = findJpegSize(imgBuffer.data, imgBuffer.width);
+ if (jpegSize == 0) { // failed to find size, default to whole buffer
+ jpegSize = imgBuffer.width;
+ }
+ size_t heapSize = mCaptureHeap->getSize();
+ if (jpegSize > heapSize) {
+ ALOGW("%s: JPEG image is larger than expected, truncating "
+ "(got %d, expected at most %d bytes)",
+ __FUNCTION__, jpegSize, heapSize);
+ jpegSize = heapSize;
+ }
+
+ // TODO: Optimize this to avoid memcopy
+ captureBuffer = new MemoryBase(mCaptureHeap, 0, jpegSize);
+ void* captureMemory = mCaptureHeap->getBase();
+ memcpy(captureMemory, imgBuffer.data, jpegSize);
- mCaptureConsumer->unlockBuffer(imgBuffer);
+ mCaptureConsumer->unlockBuffer(imgBuffer);
+ }
sp<CaptureSequencer> sequencer = mSequencer.promote();
if (sequencer != 0) {
diff --git a/services/camera/libcameraservice/api1/client2/Parameters.cpp b/services/camera/libcameraservice/api1/client2/Parameters.cpp
index 08af566..5196e09 100644
--- a/services/camera/libcameraservice/api1/client2/Parameters.cpp
+++ b/services/camera/libcameraservice/api1/client2/Parameters.cpp
@@ -1858,23 +1858,23 @@ status_t Parameters::updateRequest(CameraMetadata *request) const {
size_t reqFocusingAreasSize = focusingAreas.size() * 5;
int32_t *reqFocusingAreas = new int32_t[reqFocusingAreasSize];
- for (size_t i = 0; i < reqFocusingAreasSize; i += 5) {
- if (focusingAreas[i].weight != 0) {
+ for (size_t i = 0, j = 0; i < reqFocusingAreasSize; i += 5, j++) {
+ if (focusingAreas[j].weight != 0) {
reqFocusingAreas[i + 0] =
- normalizedXToArray(focusingAreas[i].left);
+ normalizedXToArray(focusingAreas[j].left);
reqFocusingAreas[i + 1] =
- normalizedYToArray(focusingAreas[i].top);
+ normalizedYToArray(focusingAreas[j].top);
reqFocusingAreas[i + 2] =
- normalizedXToArray(focusingAreas[i].right);
+ normalizedXToArray(focusingAreas[j].right);
reqFocusingAreas[i + 3] =
- normalizedYToArray(focusingAreas[i].bottom);
+ normalizedYToArray(focusingAreas[j].bottom);
} else {
reqFocusingAreas[i + 0] = 0;
reqFocusingAreas[i + 1] = 0;
reqFocusingAreas[i + 2] = 0;
reqFocusingAreas[i + 3] = 0;
}
- reqFocusingAreas[i + 4] = focusingAreas[i].weight;
+ reqFocusingAreas[i + 4] = focusingAreas[j].weight;
}
res = request->update(ANDROID_CONTROL_AF_REGIONS,
reqFocusingAreas, reqFocusingAreasSize);
@@ -1887,23 +1887,23 @@ status_t Parameters::updateRequest(CameraMetadata *request) const {
size_t reqMeteringAreasSize = meteringAreas.size() * 5;
int32_t *reqMeteringAreas = new int32_t[reqMeteringAreasSize];
- for (size_t i = 0; i < reqMeteringAreasSize; i += 5) {
- if (meteringAreas[i].weight != 0) {
+ for (size_t i = 0, j = 0; i < reqMeteringAreasSize; i += 5, j++) {
+ if (meteringAreas[j].weight != 0) {
reqMeteringAreas[i + 0] =
- normalizedXToArray(meteringAreas[i].left);
+ normalizedXToArray(meteringAreas[j].left);
reqMeteringAreas[i + 1] =
- normalizedYToArray(meteringAreas[i].top);
+ normalizedYToArray(meteringAreas[j].top);
reqMeteringAreas[i + 2] =
- normalizedXToArray(meteringAreas[i].right);
+ normalizedXToArray(meteringAreas[j].right);
reqMeteringAreas[i + 3] =
- normalizedYToArray(meteringAreas[i].bottom);
+ normalizedYToArray(meteringAreas[j].bottom);
} else {
reqMeteringAreas[i + 0] = 0;
reqMeteringAreas[i + 1] = 0;
reqMeteringAreas[i + 2] = 0;
reqMeteringAreas[i + 3] = 0;
}
- reqMeteringAreas[i + 4] = meteringAreas[i].weight;
+ reqMeteringAreas[i + 4] = meteringAreas[j].weight;
}
res = request->update(ANDROID_CONTROL_AE_REGIONS,
reqMeteringAreas, reqMeteringAreasSize);