Loading services/camera/libcameraservice/common/Camera2ClientBase.cpp +2 −1 Original line number Diff line number Diff line Loading @@ -104,7 +104,8 @@ status_t Camera2ClientBase<TClientBase>::initialize(CameraModule *module) { return res; } res = mDevice->setNotifyCallback(this); wp<CameraDeviceBase::NotificationListener> weakThis(this); res = mDevice->setNotifyCallback(weakThis); return OK; } Loading services/camera/libcameraservice/common/CameraDeviceBase.h +2 −2 Original line number Diff line number Diff line Loading @@ -190,7 +190,7 @@ class CameraDeviceBase : public virtual RefBase { /** * Abstract class for HAL notification listeners */ class NotificationListener { class NotificationListener : public virtual RefBase { public: // The set of notifications is a merge of the notifications required for // API1 and API2. Loading Loading @@ -219,7 +219,7 @@ class CameraDeviceBase : public virtual RefBase { * Connect HAL notifications to a listener. Overwrites previous * listener. Set to NULL to stop receiving notifications. */ virtual status_t setNotifyCallback(NotificationListener *listener) = 0; virtual status_t setNotifyCallback(wp<NotificationListener> listener) = 0; /** * Whether the device supports calling notifyAutofocus, notifyAutoExposure, Loading services/camera/libcameraservice/device3/Camera3Device.cpp +37 −33 Original line number Diff line number Diff line Loading @@ -259,7 +259,7 @@ status_t Camera3Device::disconnect() { ATRACE_CALL(); Mutex::Autolock il(mInterfaceLock); ALOGV("%s: E", __FUNCTION__); ALOGI("%s: E", __FUNCTION__); status_t res = OK; Loading Loading @@ -336,7 +336,7 @@ status_t Camera3Device::disconnect() { internalUpdateStatusLocked(STATUS_UNINITIALIZED); } ALOGV("%s: X", __FUNCTION__); ALOGI("%s: X", __FUNCTION__); return res; } Loading Loading @@ -1482,7 +1482,7 @@ status_t Camera3Device::waitUntilStateThenRelock(bool active, nsecs_t timeout) { } status_t Camera3Device::setNotifyCallback(NotificationListener *listener) { status_t Camera3Device::setNotifyCallback(wp<NotificationListener> listener) { ATRACE_CALL(); Mutex::Autolock l(mOutputLock); Loading Loading @@ -1615,15 +1615,9 @@ status_t Camera3Device::flush(int64_t *frameNumber) { ALOGV("%s: Camera %d: Flushing all requests", __FUNCTION__, mId); Mutex::Autolock il(mInterfaceLock); NotificationListener* listener; { Mutex::Autolock l(mOutputLock); listener = mListener; } { Mutex::Autolock l(mLock); mRequestThread->clear(listener, /*out*/frameNumber); mRequestThread->clear(/*out*/frameNumber); } status_t res; Loading Loading @@ -1749,10 +1743,11 @@ void Camera3Device::notifyStatus(bool idle) { // state changes if (mPauseStateNotify) return; } NotificationListener *listener; sp<NotificationListener> listener; { Mutex::Autolock l(mOutputLock); listener = mListener; listener = mListener.promote(); } if (idle && listener != NULL) { listener->notifyIdle(); Loading Loading @@ -2172,8 +2167,9 @@ void Camera3Device::setErrorStateLockedV(const char *fmt, va_list args) { internalUpdateStatusLocked(STATUS_ERROR); // Notify upstream about a device error if (mListener != NULL) { mListener->notifyError(hardware::camera2::ICameraDeviceCallbacks::ERROR_CAMERA_DEVICE, sp<NotificationListener> listener = mListener.promote(); if (listener != NULL) { listener->notifyError(hardware::camera2::ICameraDeviceCallbacks::ERROR_CAMERA_DEVICE, CaptureResultExtras()); } Loading Loading @@ -2575,10 +2571,10 @@ void Camera3Device::processCaptureResult(const camera3_capture_result *result) { void Camera3Device::notify(const camera3_notify_msg *msg) { ATRACE_CALL(); NotificationListener *listener; sp<NotificationListener> listener; { Mutex::Autolock l(mOutputLock); listener = mListener; listener = mListener.promote(); } if (msg == NULL) { Loading @@ -2602,7 +2598,7 @@ void Camera3Device::notify(const camera3_notify_msg *msg) { } void Camera3Device::notifyError(const camera3_error_msg_t &msg, NotificationListener *listener) { sp<NotificationListener> listener) { // Map camera HAL error codes to ICameraDeviceCallback error codes // Index into this with the HAL error code Loading Loading @@ -2673,7 +2669,7 @@ void Camera3Device::notifyError(const camera3_error_msg_t &msg, } void Camera3Device::notifyShutter(const camera3_shutter_msg_t &msg, NotificationListener *listener) { sp<NotificationListener> listener) { ssize_t idx; // Set timestamp for the request in the in-flight tracking Loading Loading @@ -2782,7 +2778,7 @@ Camera3Device::RequestThread::RequestThread(wp<Camera3Device> parent, } void Camera3Device::RequestThread::setNotificationListener( NotificationListener *listener) { wp<NotificationListener> listener) { Mutex::Autolock l(mRequestLock); mListener = listener; } Loading Loading @@ -2917,7 +2913,6 @@ status_t Camera3Device::RequestThread::clearRepeatingRequestsLocked(/*out*/int64 } status_t Camera3Device::RequestThread::clear( NotificationListener *listener, /*out*/int64_t *lastFrameNumber) { Mutex::Autolock l(mRequestLock); ALOGV("RequestThread::%s:", __FUNCTION__); Loading @@ -2926,6 +2921,7 @@ status_t Camera3Device::RequestThread::clear( // Send errors for all requests pending in the request queue, including // pending repeating requests sp<NotificationListener> listener = mListener.promote(); if (listener != NULL) { for (RequestList::iterator it = mRequestQueue.begin(); it != mRequestQueue.end(); ++it) { Loading Loading @@ -3065,6 +3061,7 @@ void Camera3Device::overrideResultForPrecaptureCancel( void Camera3Device::RequestThread::checkAndStopRepeatingRequest() { bool surfaceAbandoned = false; int64_t lastFrameNumber = 0; sp<NotificationListener> listener; { Mutex::Autolock l(mRequestLock); // Check all streams needed by repeating requests are still valid. Otherwise, stop Loading @@ -3081,9 +3078,11 @@ void Camera3Device::RequestThread::checkAndStopRepeatingRequest() { break; } } listener = mListener.promote(); } if (surfaceAbandoned) { mListener->notifyRepeatingRequestError(lastFrameNumber); if (listener != NULL && surfaceAbandoned) { listener->notifyRepeatingRequestError(lastFrameNumber); } } Loading Loading @@ -3426,8 +3425,9 @@ void Camera3Device::RequestThread::cleanUpFailedRequests(bool sendRequestError) if (sendRequestError) { Mutex::Autolock l(mRequestLock); if (mListener != NULL) { mListener->notifyError( sp<NotificationListener> listener = mListener.promote(); if (listener != NULL) { listener->notifyError( hardware::camera2::ICameraDeviceCallbacks::ERROR_CAMERA_REQUEST, captureRequest->mResultExtras); } Loading Loading @@ -3566,8 +3566,10 @@ sp<Camera3Device::CaptureRequest> // error ALOGE("%s: Can't get input buffer, skipping request:" " %s (%d)", __FUNCTION__, strerror(-res), res); if (mListener != NULL) { mListener->notifyError( sp<NotificationListener> listener = mListener.promote(); if (listener != NULL) { listener->notifyError( hardware::camera2::ICameraDeviceCallbacks::ERROR_CAMERA_REQUEST, nextRequest->mResultExtras); } Loading Loading @@ -3847,13 +3849,14 @@ status_t Camera3Device::PreparerThread::prepare(int maxCount, sp<Camera3StreamIn status_t res; Mutex::Autolock l(mLock); sp<NotificationListener> listener = mListener.promote(); res = stream->startPrepare(maxCount); if (res == OK) { // No preparation needed, fire listener right off ALOGV("%s: Stream %d already prepared", __FUNCTION__, stream->getId()); if (mListener) { mListener->notifyPrepared(stream->getId()); if (listener != NULL) { listener->notifyPrepared(stream->getId()); } return OK; } else if (res != NOT_ENOUGH_DATA) { Loading @@ -3868,8 +3871,8 @@ status_t Camera3Device::PreparerThread::prepare(int maxCount, sp<Camera3StreamIn res = Thread::run("C3PrepThread", PRIORITY_BACKGROUND); if (res != OK) { ALOGE("%s: Unable to start preparer stream: %d (%s)", __FUNCTION__, res, strerror(-res)); if (mListener) { mListener->notifyPrepared(stream->getId()); if (listener != NULL) { listener->notifyPrepared(stream->getId()); } return res; } Loading Loading @@ -3897,7 +3900,7 @@ status_t Camera3Device::PreparerThread::clear() { return OK; } void Camera3Device::PreparerThread::setNotificationListener(NotificationListener *listener) { void Camera3Device::PreparerThread::setNotificationListener(wp<NotificationListener> listener) { Mutex::Autolock l(mLock); mListener = listener; } Loading Loading @@ -3944,10 +3947,11 @@ bool Camera3Device::PreparerThread::threadLoop() { // This stream has finished, notify listener Mutex::Autolock l(mLock); if (mListener) { sp<NotificationListener> listener = mListener.promote(); if (listener != NULL) { ALOGV("%s: Stream %d prepare done, signaling listener", __FUNCTION__, mCurrentStream->getId()); mListener->notifyPrepared(mCurrentStream->getId()); listener->notifyPrepared(mCurrentStream->getId()); } ATRACE_ASYNC_END("stream prepare", mCurrentStream->getId()); Loading services/camera/libcameraservice/device3/Camera3Device.h +9 −11 Original line number Diff line number Diff line Loading @@ -132,7 +132,7 @@ class Camera3Device : // Transitions to the idle state on success virtual status_t waitUntilDrained(); virtual status_t setNotifyCallback(NotificationListener *listener); virtual status_t setNotifyCallback(wp<NotificationListener> listener); virtual bool willNotify3A(); virtual status_t waitForNextFrame(nsecs_t timeout); virtual status_t getNextResult(CaptureResult *frame); Loading Loading @@ -460,7 +460,7 @@ class Camera3Device : camera3_device_t *hal3Device, bool aeLockAvailable); void setNotificationListener(NotificationListener *listener); void setNotificationListener(wp<NotificationListener> listener); /** * Call after stream (re)-configuration is completed. Loading @@ -485,9 +485,7 @@ class Camera3Device : /** * Remove all queued and repeating requests, and pending triggers */ status_t clear(NotificationListener *listener, /*out*/ int64_t *lastFrameNumber = NULL); status_t clear(/*out*/int64_t *lastFrameNumber = NULL); /** * Flush all pending requests in HAL. Loading Loading @@ -603,7 +601,7 @@ class Camera3Device : wp<camera3::StatusTracker> mStatusTracker; camera3_device_t *mHal3Device; NotificationListener *mListener; wp<NotificationListener> mListener; const int mId; // The camera ID int mStatusId; // The RequestThread's component ID for Loading Loading @@ -760,7 +758,7 @@ class Camera3Device : PreparerThread(); ~PreparerThread(); void setNotificationListener(NotificationListener *listener); void setNotificationListener(wp<NotificationListener> listener); /** * Queue up a stream to be prepared. Streams are processed by a background thread in FIFO Loading @@ -781,7 +779,7 @@ class Camera3Device : // Guarded by mLock NotificationListener *mListener; wp<NotificationListener> mListener; List<sp<camera3::Camera3StreamInterface> > mPendingStreams; bool mActive; bool mCancelNow; Loading Loading @@ -810,7 +808,7 @@ class Camera3Device : uint32_t mNextReprocessShutterFrameNumber; List<CaptureResult> mResultQueue; Condition mResultSignal; NotificationListener *mListener; wp<NotificationListener> mListener; /**** End scope for mOutputLock ****/ Loading @@ -823,9 +821,9 @@ class Camera3Device : // Specific notify handlers void notifyError(const camera3_error_msg_t &msg, NotificationListener *listener); sp<NotificationListener> listener); void notifyShutter(const camera3_shutter_msg_t &msg, NotificationListener *listener); sp<NotificationListener> listener); // helper function to return the output buffers to the streams. void returnOutputBuffers(const camera3_stream_buffer_t *outputBuffers, Loading Loading
services/camera/libcameraservice/common/Camera2ClientBase.cpp +2 −1 Original line number Diff line number Diff line Loading @@ -104,7 +104,8 @@ status_t Camera2ClientBase<TClientBase>::initialize(CameraModule *module) { return res; } res = mDevice->setNotifyCallback(this); wp<CameraDeviceBase::NotificationListener> weakThis(this); res = mDevice->setNotifyCallback(weakThis); return OK; } Loading
services/camera/libcameraservice/common/CameraDeviceBase.h +2 −2 Original line number Diff line number Diff line Loading @@ -190,7 +190,7 @@ class CameraDeviceBase : public virtual RefBase { /** * Abstract class for HAL notification listeners */ class NotificationListener { class NotificationListener : public virtual RefBase { public: // The set of notifications is a merge of the notifications required for // API1 and API2. Loading Loading @@ -219,7 +219,7 @@ class CameraDeviceBase : public virtual RefBase { * Connect HAL notifications to a listener. Overwrites previous * listener. Set to NULL to stop receiving notifications. */ virtual status_t setNotifyCallback(NotificationListener *listener) = 0; virtual status_t setNotifyCallback(wp<NotificationListener> listener) = 0; /** * Whether the device supports calling notifyAutofocus, notifyAutoExposure, Loading
services/camera/libcameraservice/device3/Camera3Device.cpp +37 −33 Original line number Diff line number Diff line Loading @@ -259,7 +259,7 @@ status_t Camera3Device::disconnect() { ATRACE_CALL(); Mutex::Autolock il(mInterfaceLock); ALOGV("%s: E", __FUNCTION__); ALOGI("%s: E", __FUNCTION__); status_t res = OK; Loading Loading @@ -336,7 +336,7 @@ status_t Camera3Device::disconnect() { internalUpdateStatusLocked(STATUS_UNINITIALIZED); } ALOGV("%s: X", __FUNCTION__); ALOGI("%s: X", __FUNCTION__); return res; } Loading Loading @@ -1482,7 +1482,7 @@ status_t Camera3Device::waitUntilStateThenRelock(bool active, nsecs_t timeout) { } status_t Camera3Device::setNotifyCallback(NotificationListener *listener) { status_t Camera3Device::setNotifyCallback(wp<NotificationListener> listener) { ATRACE_CALL(); Mutex::Autolock l(mOutputLock); Loading Loading @@ -1615,15 +1615,9 @@ status_t Camera3Device::flush(int64_t *frameNumber) { ALOGV("%s: Camera %d: Flushing all requests", __FUNCTION__, mId); Mutex::Autolock il(mInterfaceLock); NotificationListener* listener; { Mutex::Autolock l(mOutputLock); listener = mListener; } { Mutex::Autolock l(mLock); mRequestThread->clear(listener, /*out*/frameNumber); mRequestThread->clear(/*out*/frameNumber); } status_t res; Loading Loading @@ -1749,10 +1743,11 @@ void Camera3Device::notifyStatus(bool idle) { // state changes if (mPauseStateNotify) return; } NotificationListener *listener; sp<NotificationListener> listener; { Mutex::Autolock l(mOutputLock); listener = mListener; listener = mListener.promote(); } if (idle && listener != NULL) { listener->notifyIdle(); Loading Loading @@ -2172,8 +2167,9 @@ void Camera3Device::setErrorStateLockedV(const char *fmt, va_list args) { internalUpdateStatusLocked(STATUS_ERROR); // Notify upstream about a device error if (mListener != NULL) { mListener->notifyError(hardware::camera2::ICameraDeviceCallbacks::ERROR_CAMERA_DEVICE, sp<NotificationListener> listener = mListener.promote(); if (listener != NULL) { listener->notifyError(hardware::camera2::ICameraDeviceCallbacks::ERROR_CAMERA_DEVICE, CaptureResultExtras()); } Loading Loading @@ -2575,10 +2571,10 @@ void Camera3Device::processCaptureResult(const camera3_capture_result *result) { void Camera3Device::notify(const camera3_notify_msg *msg) { ATRACE_CALL(); NotificationListener *listener; sp<NotificationListener> listener; { Mutex::Autolock l(mOutputLock); listener = mListener; listener = mListener.promote(); } if (msg == NULL) { Loading @@ -2602,7 +2598,7 @@ void Camera3Device::notify(const camera3_notify_msg *msg) { } void Camera3Device::notifyError(const camera3_error_msg_t &msg, NotificationListener *listener) { sp<NotificationListener> listener) { // Map camera HAL error codes to ICameraDeviceCallback error codes // Index into this with the HAL error code Loading Loading @@ -2673,7 +2669,7 @@ void Camera3Device::notifyError(const camera3_error_msg_t &msg, } void Camera3Device::notifyShutter(const camera3_shutter_msg_t &msg, NotificationListener *listener) { sp<NotificationListener> listener) { ssize_t idx; // Set timestamp for the request in the in-flight tracking Loading Loading @@ -2782,7 +2778,7 @@ Camera3Device::RequestThread::RequestThread(wp<Camera3Device> parent, } void Camera3Device::RequestThread::setNotificationListener( NotificationListener *listener) { wp<NotificationListener> listener) { Mutex::Autolock l(mRequestLock); mListener = listener; } Loading Loading @@ -2917,7 +2913,6 @@ status_t Camera3Device::RequestThread::clearRepeatingRequestsLocked(/*out*/int64 } status_t Camera3Device::RequestThread::clear( NotificationListener *listener, /*out*/int64_t *lastFrameNumber) { Mutex::Autolock l(mRequestLock); ALOGV("RequestThread::%s:", __FUNCTION__); Loading @@ -2926,6 +2921,7 @@ status_t Camera3Device::RequestThread::clear( // Send errors for all requests pending in the request queue, including // pending repeating requests sp<NotificationListener> listener = mListener.promote(); if (listener != NULL) { for (RequestList::iterator it = mRequestQueue.begin(); it != mRequestQueue.end(); ++it) { Loading Loading @@ -3065,6 +3061,7 @@ void Camera3Device::overrideResultForPrecaptureCancel( void Camera3Device::RequestThread::checkAndStopRepeatingRequest() { bool surfaceAbandoned = false; int64_t lastFrameNumber = 0; sp<NotificationListener> listener; { Mutex::Autolock l(mRequestLock); // Check all streams needed by repeating requests are still valid. Otherwise, stop Loading @@ -3081,9 +3078,11 @@ void Camera3Device::RequestThread::checkAndStopRepeatingRequest() { break; } } listener = mListener.promote(); } if (surfaceAbandoned) { mListener->notifyRepeatingRequestError(lastFrameNumber); if (listener != NULL && surfaceAbandoned) { listener->notifyRepeatingRequestError(lastFrameNumber); } } Loading Loading @@ -3426,8 +3425,9 @@ void Camera3Device::RequestThread::cleanUpFailedRequests(bool sendRequestError) if (sendRequestError) { Mutex::Autolock l(mRequestLock); if (mListener != NULL) { mListener->notifyError( sp<NotificationListener> listener = mListener.promote(); if (listener != NULL) { listener->notifyError( hardware::camera2::ICameraDeviceCallbacks::ERROR_CAMERA_REQUEST, captureRequest->mResultExtras); } Loading Loading @@ -3566,8 +3566,10 @@ sp<Camera3Device::CaptureRequest> // error ALOGE("%s: Can't get input buffer, skipping request:" " %s (%d)", __FUNCTION__, strerror(-res), res); if (mListener != NULL) { mListener->notifyError( sp<NotificationListener> listener = mListener.promote(); if (listener != NULL) { listener->notifyError( hardware::camera2::ICameraDeviceCallbacks::ERROR_CAMERA_REQUEST, nextRequest->mResultExtras); } Loading Loading @@ -3847,13 +3849,14 @@ status_t Camera3Device::PreparerThread::prepare(int maxCount, sp<Camera3StreamIn status_t res; Mutex::Autolock l(mLock); sp<NotificationListener> listener = mListener.promote(); res = stream->startPrepare(maxCount); if (res == OK) { // No preparation needed, fire listener right off ALOGV("%s: Stream %d already prepared", __FUNCTION__, stream->getId()); if (mListener) { mListener->notifyPrepared(stream->getId()); if (listener != NULL) { listener->notifyPrepared(stream->getId()); } return OK; } else if (res != NOT_ENOUGH_DATA) { Loading @@ -3868,8 +3871,8 @@ status_t Camera3Device::PreparerThread::prepare(int maxCount, sp<Camera3StreamIn res = Thread::run("C3PrepThread", PRIORITY_BACKGROUND); if (res != OK) { ALOGE("%s: Unable to start preparer stream: %d (%s)", __FUNCTION__, res, strerror(-res)); if (mListener) { mListener->notifyPrepared(stream->getId()); if (listener != NULL) { listener->notifyPrepared(stream->getId()); } return res; } Loading Loading @@ -3897,7 +3900,7 @@ status_t Camera3Device::PreparerThread::clear() { return OK; } void Camera3Device::PreparerThread::setNotificationListener(NotificationListener *listener) { void Camera3Device::PreparerThread::setNotificationListener(wp<NotificationListener> listener) { Mutex::Autolock l(mLock); mListener = listener; } Loading Loading @@ -3944,10 +3947,11 @@ bool Camera3Device::PreparerThread::threadLoop() { // This stream has finished, notify listener Mutex::Autolock l(mLock); if (mListener) { sp<NotificationListener> listener = mListener.promote(); if (listener != NULL) { ALOGV("%s: Stream %d prepare done, signaling listener", __FUNCTION__, mCurrentStream->getId()); mListener->notifyPrepared(mCurrentStream->getId()); listener->notifyPrepared(mCurrentStream->getId()); } ATRACE_ASYNC_END("stream prepare", mCurrentStream->getId()); Loading
services/camera/libcameraservice/device3/Camera3Device.h +9 −11 Original line number Diff line number Diff line Loading @@ -132,7 +132,7 @@ class Camera3Device : // Transitions to the idle state on success virtual status_t waitUntilDrained(); virtual status_t setNotifyCallback(NotificationListener *listener); virtual status_t setNotifyCallback(wp<NotificationListener> listener); virtual bool willNotify3A(); virtual status_t waitForNextFrame(nsecs_t timeout); virtual status_t getNextResult(CaptureResult *frame); Loading Loading @@ -460,7 +460,7 @@ class Camera3Device : camera3_device_t *hal3Device, bool aeLockAvailable); void setNotificationListener(NotificationListener *listener); void setNotificationListener(wp<NotificationListener> listener); /** * Call after stream (re)-configuration is completed. Loading @@ -485,9 +485,7 @@ class Camera3Device : /** * Remove all queued and repeating requests, and pending triggers */ status_t clear(NotificationListener *listener, /*out*/ int64_t *lastFrameNumber = NULL); status_t clear(/*out*/int64_t *lastFrameNumber = NULL); /** * Flush all pending requests in HAL. Loading Loading @@ -603,7 +601,7 @@ class Camera3Device : wp<camera3::StatusTracker> mStatusTracker; camera3_device_t *mHal3Device; NotificationListener *mListener; wp<NotificationListener> mListener; const int mId; // The camera ID int mStatusId; // The RequestThread's component ID for Loading Loading @@ -760,7 +758,7 @@ class Camera3Device : PreparerThread(); ~PreparerThread(); void setNotificationListener(NotificationListener *listener); void setNotificationListener(wp<NotificationListener> listener); /** * Queue up a stream to be prepared. Streams are processed by a background thread in FIFO Loading @@ -781,7 +779,7 @@ class Camera3Device : // Guarded by mLock NotificationListener *mListener; wp<NotificationListener> mListener; List<sp<camera3::Camera3StreamInterface> > mPendingStreams; bool mActive; bool mCancelNow; Loading Loading @@ -810,7 +808,7 @@ class Camera3Device : uint32_t mNextReprocessShutterFrameNumber; List<CaptureResult> mResultQueue; Condition mResultSignal; NotificationListener *mListener; wp<NotificationListener> mListener; /**** End scope for mOutputLock ****/ Loading @@ -823,9 +821,9 @@ class Camera3Device : // Specific notify handlers void notifyError(const camera3_error_msg_t &msg, NotificationListener *listener); sp<NotificationListener> listener); void notifyShutter(const camera3_shutter_msg_t &msg, NotificationListener *listener); sp<NotificationListener> listener); // helper function to return the output buffers to the streams. void returnOutputBuffers(const camera3_stream_buffer_t *outputBuffers, Loading