Camera: fix race in onRepeatingRequestError callback

Test: CTS
Bug: 64180296
Change-Id: I620e238bf1f4e7ab72911b6e68c689580fba22f1
gugelfrei
Yin-Chia Yeh 7 years ago
parent 90153cae7f
commit 8ca23dca1c

@ -42,7 +42,9 @@ interface ICameraDeviceCallbacks
* Repeating request encountered an error and was stopped.
*
* @param lastFrameNumber Frame number of the last frame of the streaming request.
* @param repeatingRequestId the ID of the repeating request being stopped
*/
oneway void onRepeatingRequestError(in long lastFrameNumber);
oneway void onRepeatingRequestError(in long lastFrameNumber,
in int repeatingRequestId);
oneway void onRequestQueueEmpty();
}

@ -1353,7 +1353,8 @@ CameraDevice::ServiceCallback::onRequestQueueEmpty() {
}
binder::Status
CameraDevice::ServiceCallback::onRepeatingRequestError(int64_t lastFrameNumber) {
CameraDevice::ServiceCallback::onRepeatingRequestError(
int64_t lastFrameNumber, int32_t stoppedSequenceId) {
binder::Status ret = binder::Status::ok();
sp<CameraDevice> dev = mDevice.promote();
@ -1364,7 +1365,9 @@ CameraDevice::ServiceCallback::onRepeatingRequestError(int64_t lastFrameNumber)
Mutex::Autolock _l(dev->mDeviceLock);
int repeatingSequenceId = dev->mRepeatingSequenceId;
dev->mRepeatingSequenceId = REQUEST_ID_NONE;
if (stoppedSequenceId == repeatingSequenceId) {
dev->mRepeatingSequenceId = REQUEST_ID_NONE;
}
dev->checkRepeatingSequenceCompleteLocked(repeatingSequenceId, lastFrameNumber);

@ -75,7 +75,8 @@ class CameraDevice final : public RefBase {
const CaptureResultExtras& resultExtras) override;
binder::Status onPrepared(int streamId) override;
binder::Status onRequestQueueEmpty() override;
binder::Status onRepeatingRequestError(int64_t lastFrameNumber) override;
binder::Status onRepeatingRequestError(int64_t lastFrameNumber,
int32_t stoppedSequenceId) override;
private:
const wp<CameraDevice> mDevice;
};

@ -217,8 +217,10 @@ public:
return binder::Status::ok();
}
virtual binder::Status onRepeatingRequestError(int64_t lastFrameNumber) {
virtual binder::Status onRepeatingRequestError(
int64_t lastFrameNumber, int32_t stoppedSequenceId) {
(void) lastFrameNumber;
(void) stoppedSequenceId;
Mutex::Autolock l(mLock);
mLastStatus = REPEATING_REQUEST_ERROR;
mStatusesHit.push_back(mLastStatus);

@ -1354,7 +1354,7 @@ void CameraDeviceClient::notifyRepeatingRequestError(long lastFrameNumber) {
sp<hardware::camera2::ICameraDeviceCallbacks> remoteCb = getRemoteCallback();
if (remoteCb != 0) {
remoteCb->onRepeatingRequestError(lastFrameNumber);
remoteCb->onRepeatingRequestError(lastFrameNumber, mStreamingRequestId);
}
Mutex::Autolock idLock(mStreamingRequestIdLock);

Loading…
Cancel
Save