Loading services/camera/libcameraservice/CameraService.cpp +1 −1 Original line number Diff line number Diff line Loading @@ -1975,7 +1975,7 @@ String8 CameraService::CameraClientManager::toString() const { auto conflicting = i->getConflicting(); auto clientSp = i->getValue(); String8 packageName; userid_t clientUserId; userid_t clientUserId = 0; if (clientSp.get() != nullptr) { packageName = String8{clientSp->getPackageName()}; uid_t clientUid = clientSp->getClientUid(); Loading services/camera/libcameraservice/api1/Camera2Client.cpp +10 −0 Original line number Diff line number Diff line Loading @@ -1881,6 +1881,16 @@ void Camera2Client::notifyAutoExposure(uint8_t newState, int triggerId) { mCaptureSequencer->notifyAutoExposure(newState, triggerId); } void Camera2Client::notifyShutter(const CaptureResultExtras& resultExtras, nsecs_t timestamp) { (void)resultExtras; (void)timestamp; ALOGV("%s: Shutter notification for request id %" PRId32 " at time %" PRId64, __FUNCTION__, resultExtras.requestId, timestamp); mCaptureSequencer->notifyShutter(resultExtras, timestamp); } camera2::SharedParameters& Camera2Client::getParameters() { return mParameters; } Loading services/camera/libcameraservice/api1/Camera2Client.h +2 −0 Original line number Diff line number Diff line Loading @@ -106,6 +106,8 @@ public: virtual void notifyAutoFocus(uint8_t newState, int triggerId); virtual void notifyAutoExposure(uint8_t newState, int triggerId); virtual void notifyShutter(const CaptureResultExtras& resultExtras, nsecs_t timestamp); /** * Interface used by independent components of Camera2Client. Loading services/camera/libcameraservice/api1/client2/CaptureSequencer.cpp +44 −10 Original line number Diff line number Diff line Loading @@ -43,6 +43,8 @@ CaptureSequencer::CaptureSequencer(wp<Camera2Client> client): mNewFrameReceived(false), mNewCaptureReceived(false), mShutterNotified(false), mHalNotifiedShutter(false), mShutterCaptureId(-1), mClient(client), mCaptureState(IDLE), mStateTransitionCount(0), Loading Loading @@ -106,6 +108,16 @@ void CaptureSequencer::notifyAutoExposure(uint8_t newState, int triggerId) { } } void CaptureSequencer::notifyShutter(const CaptureResultExtras& resultExtras, nsecs_t timestamp) { ATRACE_CALL(); Mutex::Autolock l(mInputMutex); if (!mHalNotifiedShutter && resultExtras.requestId == mShutterCaptureId) { mHalNotifiedShutter = true; mShutterNotifySignal.signal(); } } void CaptureSequencer::onResultAvailable(const CaptureResult &result) { ATRACE_CALL(); ALOGV("%s: New result available.", __FUNCTION__); Loading Loading @@ -335,6 +347,11 @@ CaptureSequencer::CaptureState CaptureSequencer::manageStart( } else { nextState = STANDARD_START; } { Mutex::Autolock l(mInputMutex); mShutterCaptureId = mCaptureId; mHalNotifiedShutter = false; } mShutterNotified = false; return nextState; Loading Loading @@ -541,6 +558,7 @@ CaptureSequencer::CaptureState CaptureSequencer::manageStandardCapture( return DONE; } } // TODO: Capture should be atomic with setStreamingRequest here res = client->getCameraDevice()->capture(captureCopy); if (res != OK) { Loading @@ -560,23 +578,39 @@ CaptureSequencer::CaptureState CaptureSequencer::manageStandardCaptureWait( ATRACE_CALL(); Mutex::Autolock l(mInputMutex); // Wait for new metadata result (mNewFrame) while (!mNewFrameReceived) { res = mNewFrameSignal.waitRelative(mInputMutex, kWaitDuration); // Wait for shutter callback while (!mHalNotifiedShutter) { if (mTimeoutCount <= 0) { break; } res = mShutterNotifySignal.waitRelative(mInputMutex, kWaitDuration); if (res == TIMED_OUT) { mTimeoutCount--; break; return STANDARD_CAPTURE_WAIT; } } // Approximation of the shutter being closed // - TODO: use the hal3 exposure callback in Camera3Device instead if (mNewFrameReceived && !mShutterNotified) { if (mHalNotifiedShutter) { if (!mShutterNotified) { SharedParameters::Lock l(client->getParameters()); /* warning: this also locks a SharedCameraCallbacks */ shutterNotifyLocked(l.mParameters, client, mMsgType); mShutterNotified = true; } } else if (mTimeoutCount <= 0) { ALOGW("Timed out waiting for shutter notification"); return DONE; } // Wait for new metadata result (mNewFrame) while (!mNewFrameReceived) { res = mNewFrameSignal.waitRelative(mInputMutex, kWaitDuration); if (res == TIMED_OUT) { mTimeoutCount--; break; } } // Wait until jpeg was captured by JpegProcessor while (mNewFrameReceived && !mNewCaptureReceived) { Loading @@ -591,6 +625,7 @@ CaptureSequencer::CaptureState CaptureSequencer::manageStandardCaptureWait( return DONE; } if (mNewFrameReceived && mNewCaptureReceived) { if (mNewFrameId != mCaptureId) { ALOGW("Mismatched capture frame IDs: Expected %d, got %d", mCaptureId, mNewFrameId); Loading Loading @@ -667,7 +702,6 @@ CaptureSequencer::CaptureState CaptureSequencer::manageBurstCaptureWait( sp<Camera2Client> &/*client*/) { status_t res; ATRACE_CALL(); while (!mNewCaptureReceived) { res = mNewCaptureSignal.waitRelative(mInputMutex, kWaitDuration); if (res == TIMED_OUT) { Loading services/camera/libcameraservice/api1/client2/CaptureSequencer.h +8 −1 Original line number Diff line number Diff line Loading @@ -62,6 +62,10 @@ class CaptureSequencer: // Notifications about AE state changes void notifyAutoExposure(uint8_t newState, int triggerId); // Notifications about shutter (capture start) void notifyShutter(const CaptureResultExtras& resultExtras, nsecs_t timestamp); // Notification from the frame processor virtual void onResultAvailable(const CaptureResult &result); Loading Loading @@ -95,7 +99,10 @@ class CaptureSequencer: sp<MemoryBase> mCaptureBuffer; Condition mNewCaptureSignal; bool mShutterNotified; bool mShutterNotified; // Has CaptureSequencer sent shutter to Client bool mHalNotifiedShutter; // Has HAL sent shutter to CaptureSequencer int32_t mShutterCaptureId; // The captureId which is waiting for shutter notification Condition mShutterNotifySignal; /** * Internal to CaptureSequencer Loading Loading
services/camera/libcameraservice/CameraService.cpp +1 −1 Original line number Diff line number Diff line Loading @@ -1975,7 +1975,7 @@ String8 CameraService::CameraClientManager::toString() const { auto conflicting = i->getConflicting(); auto clientSp = i->getValue(); String8 packageName; userid_t clientUserId; userid_t clientUserId = 0; if (clientSp.get() != nullptr) { packageName = String8{clientSp->getPackageName()}; uid_t clientUid = clientSp->getClientUid(); Loading
services/camera/libcameraservice/api1/Camera2Client.cpp +10 −0 Original line number Diff line number Diff line Loading @@ -1881,6 +1881,16 @@ void Camera2Client::notifyAutoExposure(uint8_t newState, int triggerId) { mCaptureSequencer->notifyAutoExposure(newState, triggerId); } void Camera2Client::notifyShutter(const CaptureResultExtras& resultExtras, nsecs_t timestamp) { (void)resultExtras; (void)timestamp; ALOGV("%s: Shutter notification for request id %" PRId32 " at time %" PRId64, __FUNCTION__, resultExtras.requestId, timestamp); mCaptureSequencer->notifyShutter(resultExtras, timestamp); } camera2::SharedParameters& Camera2Client::getParameters() { return mParameters; } Loading
services/camera/libcameraservice/api1/Camera2Client.h +2 −0 Original line number Diff line number Diff line Loading @@ -106,6 +106,8 @@ public: virtual void notifyAutoFocus(uint8_t newState, int triggerId); virtual void notifyAutoExposure(uint8_t newState, int triggerId); virtual void notifyShutter(const CaptureResultExtras& resultExtras, nsecs_t timestamp); /** * Interface used by independent components of Camera2Client. Loading
services/camera/libcameraservice/api1/client2/CaptureSequencer.cpp +44 −10 Original line number Diff line number Diff line Loading @@ -43,6 +43,8 @@ CaptureSequencer::CaptureSequencer(wp<Camera2Client> client): mNewFrameReceived(false), mNewCaptureReceived(false), mShutterNotified(false), mHalNotifiedShutter(false), mShutterCaptureId(-1), mClient(client), mCaptureState(IDLE), mStateTransitionCount(0), Loading Loading @@ -106,6 +108,16 @@ void CaptureSequencer::notifyAutoExposure(uint8_t newState, int triggerId) { } } void CaptureSequencer::notifyShutter(const CaptureResultExtras& resultExtras, nsecs_t timestamp) { ATRACE_CALL(); Mutex::Autolock l(mInputMutex); if (!mHalNotifiedShutter && resultExtras.requestId == mShutterCaptureId) { mHalNotifiedShutter = true; mShutterNotifySignal.signal(); } } void CaptureSequencer::onResultAvailable(const CaptureResult &result) { ATRACE_CALL(); ALOGV("%s: New result available.", __FUNCTION__); Loading Loading @@ -335,6 +347,11 @@ CaptureSequencer::CaptureState CaptureSequencer::manageStart( } else { nextState = STANDARD_START; } { Mutex::Autolock l(mInputMutex); mShutterCaptureId = mCaptureId; mHalNotifiedShutter = false; } mShutterNotified = false; return nextState; Loading Loading @@ -541,6 +558,7 @@ CaptureSequencer::CaptureState CaptureSequencer::manageStandardCapture( return DONE; } } // TODO: Capture should be atomic with setStreamingRequest here res = client->getCameraDevice()->capture(captureCopy); if (res != OK) { Loading @@ -560,23 +578,39 @@ CaptureSequencer::CaptureState CaptureSequencer::manageStandardCaptureWait( ATRACE_CALL(); Mutex::Autolock l(mInputMutex); // Wait for new metadata result (mNewFrame) while (!mNewFrameReceived) { res = mNewFrameSignal.waitRelative(mInputMutex, kWaitDuration); // Wait for shutter callback while (!mHalNotifiedShutter) { if (mTimeoutCount <= 0) { break; } res = mShutterNotifySignal.waitRelative(mInputMutex, kWaitDuration); if (res == TIMED_OUT) { mTimeoutCount--; break; return STANDARD_CAPTURE_WAIT; } } // Approximation of the shutter being closed // - TODO: use the hal3 exposure callback in Camera3Device instead if (mNewFrameReceived && !mShutterNotified) { if (mHalNotifiedShutter) { if (!mShutterNotified) { SharedParameters::Lock l(client->getParameters()); /* warning: this also locks a SharedCameraCallbacks */ shutterNotifyLocked(l.mParameters, client, mMsgType); mShutterNotified = true; } } else if (mTimeoutCount <= 0) { ALOGW("Timed out waiting for shutter notification"); return DONE; } // Wait for new metadata result (mNewFrame) while (!mNewFrameReceived) { res = mNewFrameSignal.waitRelative(mInputMutex, kWaitDuration); if (res == TIMED_OUT) { mTimeoutCount--; break; } } // Wait until jpeg was captured by JpegProcessor while (mNewFrameReceived && !mNewCaptureReceived) { Loading @@ -591,6 +625,7 @@ CaptureSequencer::CaptureState CaptureSequencer::manageStandardCaptureWait( return DONE; } if (mNewFrameReceived && mNewCaptureReceived) { if (mNewFrameId != mCaptureId) { ALOGW("Mismatched capture frame IDs: Expected %d, got %d", mCaptureId, mNewFrameId); Loading Loading @@ -667,7 +702,6 @@ CaptureSequencer::CaptureState CaptureSequencer::manageBurstCaptureWait( sp<Camera2Client> &/*client*/) { status_t res; ATRACE_CALL(); while (!mNewCaptureReceived) { res = mNewCaptureSignal.waitRelative(mInputMutex, kWaitDuration); if (res == TIMED_OUT) { Loading
services/camera/libcameraservice/api1/client2/CaptureSequencer.h +8 −1 Original line number Diff line number Diff line Loading @@ -62,6 +62,10 @@ class CaptureSequencer: // Notifications about AE state changes void notifyAutoExposure(uint8_t newState, int triggerId); // Notifications about shutter (capture start) void notifyShutter(const CaptureResultExtras& resultExtras, nsecs_t timestamp); // Notification from the frame processor virtual void onResultAvailable(const CaptureResult &result); Loading Loading @@ -95,7 +99,10 @@ class CaptureSequencer: sp<MemoryBase> mCaptureBuffer; Condition mNewCaptureSignal; bool mShutterNotified; bool mShutterNotified; // Has CaptureSequencer sent shutter to Client bool mHalNotifiedShutter; // Has HAL sent shutter to CaptureSequencer int32_t mShutterCaptureId; // The captureId which is waiting for shutter notification Condition mShutterNotifySignal; /** * Internal to CaptureSequencer Loading