Loading services/camera/libcameraservice/api2/CameraDeviceClient.cpp +30 −11 Original line number Diff line number Diff line Loading @@ -206,6 +206,7 @@ binder::Status CameraDeviceClient::insertGbpLocked(const sp<IGraphicBufferProduc int compositeIdx; int idx = mStreamMap.indexOfKey(IInterface::asBinder(gbp)); Mutex::Autolock l(mCompositeLock); // Trying to submit request with surface that wasn't created if (idx == NAME_NOT_FOUND) { ALOGE("%s: Camera %s: Tried to submit a request with a surface that" Loading Loading @@ -640,6 +641,7 @@ binder::Status CameraDeviceClient::endConfigure(int operatingMode, offlineStreamIds->clear(); mDevice->getOfflineStreamIds(offlineStreamIds); Mutex::Autolock l(mCompositeLock); for (size_t i = 0; i < mCompositeStreamMap.size(); ++i) { err = mCompositeStreamMap.valueAt(i)->configureStream(); if (err != OK) { Loading Loading @@ -774,6 +776,7 @@ binder::Status CameraDeviceClient::deleteStream(int streamId) { } } Mutex::Autolock l(mCompositeLock); for (size_t i = 0; i < mCompositeStreamMap.size(); ++i) { if (streamId == mCompositeStreamMap.valueAt(i)->getStreamId()) { compositeIndex = i; Loading Loading @@ -812,6 +815,7 @@ binder::Status CameraDeviceClient::deleteStream(int streamId) { } if (compositeIndex != NAME_NOT_FOUND) { Mutex::Autolock l(mCompositeLock); status_t ret; if ((ret = mCompositeStreamMap.valueAt(compositeIndex)->deleteStream()) != OK) { Loading Loading @@ -935,6 +939,7 @@ binder::Status CameraDeviceClient::createStream( &streamId, physicalCameraId, streamInfo.sensorPixelModesUsed, &surfaceIds, outputConfiguration.getSurfaceSetID(), isShared, isMultiResolution); if (err == OK) { Mutex::Autolock l(mCompositeLock); mCompositeStreamMap.add(IInterface::asBinder(surfaces[0]->getIGraphicBufferProducer()), compositeStream); } Loading Loading @@ -1754,8 +1759,9 @@ binder::Status CameraDeviceClient::switchToOffline( return STATUS_ERROR(CameraService::ERROR_ILLEGAL_ARGUMENT, msg.string()); } Mutex::Autolock l(mCompositeLock); bool isCompositeStream = false; for (const auto& gbp : mConfiguredOutputs[streamId].getGraphicBufferProducers()) { for (const auto& gbp : mConfiguredOutputs.valueAt(index).getGraphicBufferProducers()) { sp<Surface> s = new Surface(gbp, false /*controlledByApp*/); isCompositeStream = camera3::DepthCompositeStream::isDepthCompositeStream(s) | camera3::HeicCompositeStream::isHeicCompositeStream(s); Loading Loading @@ -1804,6 +1810,7 @@ binder::Status CameraDeviceClient::switchToOffline( mConfiguredOutputs.clear(); mDeferredStreams.clear(); mStreamInfoMap.clear(); Mutex::Autolock l(mCompositeLock); mCompositeStreamMap.clear(); mInputStream = {false, 0, 0, 0, 0}; } else { Loading Loading @@ -1899,11 +1906,16 @@ void CameraDeviceClient::notifyError(int32_t errorCode, // Thread safe. Don't bother locking. sp<hardware::camera2::ICameraDeviceCallbacks> remoteCb = getRemoteCallback(); // Composites can have multiple internal streams. Error notifications coming from such internal // streams may need to remain within camera service. bool skipClientNotification = false; { // Access to the composite stream map must be synchronized Mutex::Autolock l(mCompositeLock); // Composites can have multiple internal streams. Error notifications coming from such // internal streams may need to remain within camera service. for (size_t i = 0; i < mCompositeStreamMap.size(); i++) { skipClientNotification |= mCompositeStreamMap.valueAt(i)->onError(errorCode, resultExtras); skipClientNotification |= mCompositeStreamMap.valueAt(i)->onError(errorCode, resultExtras); } } if ((remoteCb != 0) && (!skipClientNotification)) { Loading Loading @@ -1943,6 +1955,8 @@ void CameraDeviceClient::notifyShutter(const CaptureResultExtras& resultExtras, } Camera2ClientBase::notifyShutter(resultExtras, timestamp); // Access to the composite stream map must be synchronized Mutex::Autolock l(mCompositeLock); for (size_t i = 0; i < mCompositeStreamMap.size(); i++) { mCompositeStreamMap.valueAt(i)->onShutter(resultExtras, timestamp); } Loading Loading @@ -1992,6 +2006,8 @@ void CameraDeviceClient::detachDevice() { } } { Mutex::Autolock l(mCompositeLock); for (size_t i = 0; i < mCompositeStreamMap.size(); i++) { auto ret = mCompositeStreamMap.valueAt(i)->deleteInternalStreams(); if (ret != OK) { Loading @@ -2000,6 +2016,7 @@ void CameraDeviceClient::detachDevice() { } } mCompositeStreamMap.clear(); } Camera2ClientBase::detachDevice(); Loading @@ -2019,6 +2036,8 @@ void CameraDeviceClient::onResultAvailable(const CaptureResult& result) { result.mPhysicalMetadatas); } // Access to the composite stream map must be synchronized Mutex::Autolock l(mCompositeLock); for (size_t i = 0; i < mCompositeStreamMap.size(); i++) { mCompositeStreamMap.valueAt(i)->onResultAvailable(result); } Loading services/camera/libcameraservice/api2/CameraDeviceClient.h +2 −0 Original line number Diff line number Diff line Loading @@ -339,6 +339,8 @@ private: // set of high resolution camera id (logical / physical) std::unordered_set<std::string> mHighResolutionSensors; // Synchronize access to 'mCompositeStreamMap' Mutex mCompositeLock; KeyedVector<sp<IBinder>, sp<CompositeStream>> mCompositeStreamMap; sp<CameraProviderManager> mProviderManager; Loading Loading
services/camera/libcameraservice/api2/CameraDeviceClient.cpp +30 −11 Original line number Diff line number Diff line Loading @@ -206,6 +206,7 @@ binder::Status CameraDeviceClient::insertGbpLocked(const sp<IGraphicBufferProduc int compositeIdx; int idx = mStreamMap.indexOfKey(IInterface::asBinder(gbp)); Mutex::Autolock l(mCompositeLock); // Trying to submit request with surface that wasn't created if (idx == NAME_NOT_FOUND) { ALOGE("%s: Camera %s: Tried to submit a request with a surface that" Loading Loading @@ -640,6 +641,7 @@ binder::Status CameraDeviceClient::endConfigure(int operatingMode, offlineStreamIds->clear(); mDevice->getOfflineStreamIds(offlineStreamIds); Mutex::Autolock l(mCompositeLock); for (size_t i = 0; i < mCompositeStreamMap.size(); ++i) { err = mCompositeStreamMap.valueAt(i)->configureStream(); if (err != OK) { Loading Loading @@ -774,6 +776,7 @@ binder::Status CameraDeviceClient::deleteStream(int streamId) { } } Mutex::Autolock l(mCompositeLock); for (size_t i = 0; i < mCompositeStreamMap.size(); ++i) { if (streamId == mCompositeStreamMap.valueAt(i)->getStreamId()) { compositeIndex = i; Loading Loading @@ -812,6 +815,7 @@ binder::Status CameraDeviceClient::deleteStream(int streamId) { } if (compositeIndex != NAME_NOT_FOUND) { Mutex::Autolock l(mCompositeLock); status_t ret; if ((ret = mCompositeStreamMap.valueAt(compositeIndex)->deleteStream()) != OK) { Loading Loading @@ -935,6 +939,7 @@ binder::Status CameraDeviceClient::createStream( &streamId, physicalCameraId, streamInfo.sensorPixelModesUsed, &surfaceIds, outputConfiguration.getSurfaceSetID(), isShared, isMultiResolution); if (err == OK) { Mutex::Autolock l(mCompositeLock); mCompositeStreamMap.add(IInterface::asBinder(surfaces[0]->getIGraphicBufferProducer()), compositeStream); } Loading Loading @@ -1754,8 +1759,9 @@ binder::Status CameraDeviceClient::switchToOffline( return STATUS_ERROR(CameraService::ERROR_ILLEGAL_ARGUMENT, msg.string()); } Mutex::Autolock l(mCompositeLock); bool isCompositeStream = false; for (const auto& gbp : mConfiguredOutputs[streamId].getGraphicBufferProducers()) { for (const auto& gbp : mConfiguredOutputs.valueAt(index).getGraphicBufferProducers()) { sp<Surface> s = new Surface(gbp, false /*controlledByApp*/); isCompositeStream = camera3::DepthCompositeStream::isDepthCompositeStream(s) | camera3::HeicCompositeStream::isHeicCompositeStream(s); Loading Loading @@ -1804,6 +1810,7 @@ binder::Status CameraDeviceClient::switchToOffline( mConfiguredOutputs.clear(); mDeferredStreams.clear(); mStreamInfoMap.clear(); Mutex::Autolock l(mCompositeLock); mCompositeStreamMap.clear(); mInputStream = {false, 0, 0, 0, 0}; } else { Loading Loading @@ -1899,11 +1906,16 @@ void CameraDeviceClient::notifyError(int32_t errorCode, // Thread safe. Don't bother locking. sp<hardware::camera2::ICameraDeviceCallbacks> remoteCb = getRemoteCallback(); // Composites can have multiple internal streams. Error notifications coming from such internal // streams may need to remain within camera service. bool skipClientNotification = false; { // Access to the composite stream map must be synchronized Mutex::Autolock l(mCompositeLock); // Composites can have multiple internal streams. Error notifications coming from such // internal streams may need to remain within camera service. for (size_t i = 0; i < mCompositeStreamMap.size(); i++) { skipClientNotification |= mCompositeStreamMap.valueAt(i)->onError(errorCode, resultExtras); skipClientNotification |= mCompositeStreamMap.valueAt(i)->onError(errorCode, resultExtras); } } if ((remoteCb != 0) && (!skipClientNotification)) { Loading Loading @@ -1943,6 +1955,8 @@ void CameraDeviceClient::notifyShutter(const CaptureResultExtras& resultExtras, } Camera2ClientBase::notifyShutter(resultExtras, timestamp); // Access to the composite stream map must be synchronized Mutex::Autolock l(mCompositeLock); for (size_t i = 0; i < mCompositeStreamMap.size(); i++) { mCompositeStreamMap.valueAt(i)->onShutter(resultExtras, timestamp); } Loading Loading @@ -1992,6 +2006,8 @@ void CameraDeviceClient::detachDevice() { } } { Mutex::Autolock l(mCompositeLock); for (size_t i = 0; i < mCompositeStreamMap.size(); i++) { auto ret = mCompositeStreamMap.valueAt(i)->deleteInternalStreams(); if (ret != OK) { Loading @@ -2000,6 +2016,7 @@ void CameraDeviceClient::detachDevice() { } } mCompositeStreamMap.clear(); } Camera2ClientBase::detachDevice(); Loading @@ -2019,6 +2036,8 @@ void CameraDeviceClient::onResultAvailable(const CaptureResult& result) { result.mPhysicalMetadatas); } // Access to the composite stream map must be synchronized Mutex::Autolock l(mCompositeLock); for (size_t i = 0; i < mCompositeStreamMap.size(); i++) { mCompositeStreamMap.valueAt(i)->onResultAvailable(result); } Loading
services/camera/libcameraservice/api2/CameraDeviceClient.h +2 −0 Original line number Diff line number Diff line Loading @@ -339,6 +339,8 @@ private: // set of high resolution camera id (logical / physical) std::unordered_set<std::string> mHighResolutionSensors; // Synchronize access to 'mCompositeStreamMap' Mutex mCompositeLock; KeyedVector<sp<IBinder>, sp<CompositeStream>> mCompositeStreamMap; sp<CameraProviderManager> mProviderManager; Loading