diff options
Diffstat (limited to 'services/camera')
16 files changed, 46 insertions, 34 deletions
diff --git a/services/camera/libcameraservice/api1/Camera2Client.cpp b/services/camera/libcameraservice/api1/Camera2Client.cpp index ec1a341..3bdeab2 100644 --- a/services/camera/libcameraservice/api1/Camera2Client.cpp +++ b/services/camera/libcameraservice/api1/Camera2Client.cpp @@ -420,12 +420,20 @@ void Camera2Client::disconnect() { ALOGV("Camera %d: Waiting for threads", mCameraId); - mStreamingProcessor->join(); - mFrameProcessor->join(); - mCaptureSequencer->join(); - mJpegProcessor->join(); - mZslProcessorThread->join(); - mCallbackProcessor->join(); + { + // Don't wait with lock held, in case the other threads need to + // complete callbacks that re-enter Camera2Client + mBinderSerializationLock.unlock(); + + mStreamingProcessor->join(); + mFrameProcessor->join(); + mCaptureSequencer->join(); + mJpegProcessor->join(); + mZslProcessorThread->join(); + mCallbackProcessor->join(); + + mBinderSerializationLock.lock(); + } ALOGV("Camera %d: Deleting streams", mCameraId); diff --git a/services/camera/libcameraservice/api1/client2/BurstCapture.cpp b/services/camera/libcameraservice/api1/client2/BurstCapture.cpp index 0bfdfd4..5502dcb 100644 --- a/services/camera/libcameraservice/api1/client2/BurstCapture.cpp +++ b/services/camera/libcameraservice/api1/client2/BurstCapture.cpp @@ -44,7 +44,7 @@ status_t BurstCapture::start(Vector<CameraMetadata> &/*metadatas*/, return INVALID_OPERATION; } -void BurstCapture::onFrameAvailable() { +void BurstCapture::onFrameAvailable(const BufferItem &/*item*/) { ALOGV("%s", __FUNCTION__); Mutex::Autolock l(mInputMutex); if(!mInputChanged) { diff --git a/services/camera/libcameraservice/api1/client2/BurstCapture.h b/services/camera/libcameraservice/api1/client2/BurstCapture.h index ea321fd..c3b7722 100644 --- a/services/camera/libcameraservice/api1/client2/BurstCapture.h +++ b/services/camera/libcameraservice/api1/client2/BurstCapture.h @@ -39,7 +39,7 @@ public: BurstCapture(wp<Camera2Client> client, wp<CaptureSequencer> sequencer); virtual ~BurstCapture(); - virtual void onFrameAvailable(); + virtual void onFrameAvailable(const BufferItem& item); virtual status_t start(Vector<CameraMetadata> &metadatas, int32_t firstCaptureId); protected: diff --git a/services/camera/libcameraservice/api1/client2/CallbackProcessor.cpp b/services/camera/libcameraservice/api1/client2/CallbackProcessor.cpp index bf3318e..eadaa00 100644 --- a/services/camera/libcameraservice/api1/client2/CallbackProcessor.cpp +++ b/services/camera/libcameraservice/api1/client2/CallbackProcessor.cpp @@ -46,7 +46,7 @@ CallbackProcessor::~CallbackProcessor() { deleteStream(); } -void CallbackProcessor::onFrameAvailable() { +void CallbackProcessor::onFrameAvailable(const BufferItem& /*item*/) { Mutex::Autolock l(mInputMutex); if (!mCallbackAvailable) { mCallbackAvailable = true; diff --git a/services/camera/libcameraservice/api1/client2/CallbackProcessor.h b/services/camera/libcameraservice/api1/client2/CallbackProcessor.h index 613f5be..7fdc329 100644 --- a/services/camera/libcameraservice/api1/client2/CallbackProcessor.h +++ b/services/camera/libcameraservice/api1/client2/CallbackProcessor.h @@ -44,7 +44,7 @@ class CallbackProcessor: CallbackProcessor(sp<Camera2Client> client); ~CallbackProcessor(); - void onFrameAvailable(); + void onFrameAvailable(const BufferItem& item); // Set to NULL to disable the direct-to-app callback window status_t setCallbackWindow(sp<ANativeWindow> callbackWindow); diff --git a/services/camera/libcameraservice/api1/client2/JpegProcessor.cpp b/services/camera/libcameraservice/api1/client2/JpegProcessor.cpp index b433781..2772267 100644 --- a/services/camera/libcameraservice/api1/client2/JpegProcessor.cpp +++ b/services/camera/libcameraservice/api1/client2/JpegProcessor.cpp @@ -51,7 +51,7 @@ JpegProcessor::~JpegProcessor() { deleteStream(); } -void JpegProcessor::onFrameAvailable() { +void JpegProcessor::onFrameAvailable(const BufferItem& /*item*/) { Mutex::Autolock l(mInputMutex); if (!mCaptureAvailable) { mCaptureAvailable = true; diff --git a/services/camera/libcameraservice/api1/client2/JpegProcessor.h b/services/camera/libcameraservice/api1/client2/JpegProcessor.h index b2c05df..2040b30 100644 --- a/services/camera/libcameraservice/api1/client2/JpegProcessor.h +++ b/services/camera/libcameraservice/api1/client2/JpegProcessor.h @@ -47,7 +47,7 @@ class JpegProcessor: ~JpegProcessor(); // CpuConsumer listener implementation - void onFrameAvailable(); + void onFrameAvailable(const BufferItem& item); status_t updateStream(const Parameters ¶ms); status_t deleteStream(); diff --git a/services/camera/libcameraservice/api1/client2/Parameters.cpp b/services/camera/libcameraservice/api1/client2/Parameters.cpp index 7b90d28..42a5507 100644 --- a/services/camera/libcameraservice/api1/client2/Parameters.cpp +++ b/services/camera/libcameraservice/api1/client2/Parameters.cpp @@ -2954,6 +2954,10 @@ status_t Parameters::calculatePictureFovs(float *horizFov, float *vertFov) staticInfo(ANDROID_SENSOR_INFO_PHYSICAL_SIZE, 2, 2); if (!sensorSize.count) return NO_INIT; + camera_metadata_ro_entry_t pixelArraySize = + staticInfo(ANDROID_SENSOR_INFO_PIXEL_ARRAY_SIZE, 2, 2); + if (!pixelArraySize.count) return NO_INIT; + float arrayAspect = static_cast<float>(fastInfo.arrayWidth) / fastInfo.arrayHeight; float stillAspect = static_cast<float>(pictureWidth) / pictureHeight; @@ -3003,6 +3007,16 @@ status_t Parameters::calculatePictureFovs(float *horizFov, float *vertFov) vertCropFactor = (arrayAspect < stillAspect) ? (arrayAspect / stillAspect) : 1.f; } + + /** + * Convert the crop factors w.r.t the active array size to the crop factors + * w.r.t the pixel array size. + */ + horizCropFactor *= (static_cast<float>(fastInfo.arrayWidth) / + pixelArraySize.data.i32[0]); + vertCropFactor *= (static_cast<float>(fastInfo.arrayHeight) / + pixelArraySize.data.i32[1]); + ALOGV("Horiz crop factor: %f, vert crop fact: %f", horizCropFactor, vertCropFactor); /** diff --git a/services/camera/libcameraservice/api1/client2/StreamingProcessor.cpp b/services/camera/libcameraservice/api1/client2/StreamingProcessor.cpp index 9e7fff8..470624b 100644 --- a/services/camera/libcameraservice/api1/client2/StreamingProcessor.cpp +++ b/services/camera/libcameraservice/api1/client2/StreamingProcessor.cpp @@ -635,7 +635,7 @@ status_t StreamingProcessor::incrementStreamingIds() { return OK; } -void StreamingProcessor::onFrameAvailable() { +void StreamingProcessor::onFrameAvailable(const BufferItem& /*item*/) { ATRACE_CALL(); Mutex::Autolock l(mMutex); if (!mRecordingFrameAvailable) { diff --git a/services/camera/libcameraservice/api1/client2/StreamingProcessor.h b/services/camera/libcameraservice/api1/client2/StreamingProcessor.h index 8466af4..1d679a4 100644 --- a/services/camera/libcameraservice/api1/client2/StreamingProcessor.h +++ b/services/camera/libcameraservice/api1/client2/StreamingProcessor.h @@ -80,7 +80,7 @@ class StreamingProcessor: status_t incrementStreamingIds(); // Callback for new recording frames from HAL - virtual void onFrameAvailable(); + virtual void onFrameAvailable(const BufferItem& item); // Callback from stagefright which returns used recording frames void releaseRecordingFrame(const sp<IMemory>& mem); diff --git a/services/camera/libcameraservice/api1/client2/ZslProcessor.cpp b/services/camera/libcameraservice/api1/client2/ZslProcessor.cpp index 8f78103..8b7e4b4 100644 --- a/services/camera/libcameraservice/api1/client2/ZslProcessor.cpp +++ b/services/camera/libcameraservice/api1/client2/ZslProcessor.cpp @@ -66,7 +66,7 @@ ZslProcessor::~ZslProcessor() { disconnect(); } -void ZslProcessor::onFrameAvailable() { +void ZslProcessor::onFrameAvailable(const BufferItem& /*item*/) { Mutex::Autolock l(mInputMutex); if (!mZslBufferAvailable) { mZslBufferAvailable = true; diff --git a/services/camera/libcameraservice/api1/client2/ZslProcessor.h b/services/camera/libcameraservice/api1/client2/ZslProcessor.h index b6533cf..2099c38 100644 --- a/services/camera/libcameraservice/api1/client2/ZslProcessor.h +++ b/services/camera/libcameraservice/api1/client2/ZslProcessor.h @@ -53,7 +53,7 @@ class ZslProcessor: ~ZslProcessor(); // From mZslConsumer - virtual void onFrameAvailable(); + virtual void onFrameAvailable(const BufferItem& item); // From FrameProcessor virtual void onResultAvailable(const CaptureResult &result); diff --git a/services/camera/libcameraservice/device2/Camera2Device.cpp b/services/camera/libcameraservice/device2/Camera2Device.cpp index 8caadd6..d1158d6 100644 --- a/services/camera/libcameraservice/device2/Camera2Device.cpp +++ b/services/camera/libcameraservice/device2/Camera2Device.cpp @@ -793,11 +793,6 @@ status_t Camera2Device::MetadataQueue::setStreamSlot(camera_metadata_t *buf) mStreamSlotCount = 0; return OK; } - camera_metadata_t *buf2 = clone_camera_metadata(buf); - if (!buf2) { - ALOGE("%s: Unable to clone metadata buffer!", __FUNCTION__); - return NO_MEMORY; - } if (mStreamSlotCount > 1) { List<camera_metadata_t*>::iterator deleter = ++mStreamSlot.begin(); @@ -806,9 +801,9 @@ status_t Camera2Device::MetadataQueue::setStreamSlot(camera_metadata_t *buf) } if (mStreamSlotCount == 1) { free_camera_metadata( *(mStreamSlot.begin()) ); - *(mStreamSlot.begin()) = buf2; + *(mStreamSlot.begin()) = buf; } else { - mStreamSlot.push_front(buf2); + mStreamSlot.push_front(buf); mStreamSlotCount = 1; } return signalConsumerLocked(); @@ -827,12 +822,7 @@ status_t Camera2Device::MetadataQueue::setStreamSlot( mStreamSlotCount = 0; for (List<camera_metadata_t*>::const_iterator r = bufs.begin(); r != bufs.end(); r++) { - camera_metadata_t *r2 = clone_camera_metadata(*r); - if (!r2) { - ALOGE("%s: Unable to clone metadata buffer!", __FUNCTION__); - return NO_MEMORY; - } - mStreamSlot.push_back(r2); + mStreamSlot.push_back(*r); mStreamSlotCount++; } return signalConsumerLocked(); diff --git a/services/camera/libcameraservice/device2/Camera2Device.h b/services/camera/libcameraservice/device2/Camera2Device.h index 2a3f1d9..4def8ae 100644 --- a/services/camera/libcameraservice/device2/Camera2Device.h +++ b/services/camera/libcameraservice/device2/Camera2Device.h @@ -124,8 +124,8 @@ class Camera2Device: public CameraDeviceBase { // Set repeating buffer(s); if the queue is empty on a dequeue call, the // queue copies the contents of the stream slot into the queue, and then - // dequeues the first new entry. The metadata buffers passed in are - // copied. + // dequeues the first new entry. The methods take the ownership of the + // metadata buffers passed in. status_t setStreamSlot(camera_metadata_t *buf); status_t setStreamSlot(const List<camera_metadata_t*> &bufs); diff --git a/services/camera/libcameraservice/gui/RingBufferConsumer.cpp b/services/camera/libcameraservice/gui/RingBufferConsumer.cpp index f8562ec..d0f29de 100644 --- a/services/camera/libcameraservice/gui/RingBufferConsumer.cpp +++ b/services/camera/libcameraservice/gui/RingBufferConsumer.cpp @@ -268,7 +268,7 @@ status_t RingBufferConsumer::releaseOldestBufferLocked(size_t* pinnedFrames) { return OK; } -void RingBufferConsumer::onFrameAvailable() { +void RingBufferConsumer::onFrameAvailable(const android::BufferItem& item) { status_t err; { @@ -321,7 +321,7 @@ void RingBufferConsumer::onFrameAvailable() { item.mGraphicBuffer = mSlots[item.mBuf].mGraphicBuffer; } // end of mMutex lock - ConsumerBase::onFrameAvailable(); + ConsumerBase::onFrameAvailable(item); } void RingBufferConsumer::unpinBuffer(const BufferItem& item) { diff --git a/services/camera/libcameraservice/gui/RingBufferConsumer.h b/services/camera/libcameraservice/gui/RingBufferConsumer.h index da97a11..90fd734 100644 --- a/services/camera/libcameraservice/gui/RingBufferConsumer.h +++ b/services/camera/libcameraservice/gui/RingBufferConsumer.h @@ -165,7 +165,7 @@ class RingBufferConsumer : public ConsumerBase, private: // Override ConsumerBase::onFrameAvailable - virtual void onFrameAvailable(); + virtual void onFrameAvailable(const android::BufferItem& item); void pinBufferLocked(const BufferItem& item); void unpinBuffer(const BufferItem& item); |