Loading services/camera/libcameraservice/device3/Camera3Device.cpp +37 −22 Original line number Diff line number Diff line Loading @@ -2152,7 +2152,10 @@ status_t Camera3Device::setConsumerSurfaces(int streamId, CLOGE("Stream %d is unknown", streamId); return idx; } sp<Camera3OutputStreamInterface> stream = mOutputStreams[idx]; // isConsumerConfigurationDeferred will be off after setConsumers bool isDeferred = stream->isConsumerConfigurationDeferred(); status_t res = stream->setConsumers(consumers); if (res != OK) { CLOGE("Stream %d set consumer failed (error %d %s) ", streamId, res, strerror(-res)); Loading @@ -2168,7 +2171,7 @@ status_t Camera3Device::setConsumerSurfaces(int streamId, surfaceIds->push_back(id); } if (stream->isConsumerConfigurationDeferred()) { if (isDeferred) { if (!stream->isConfiguring()) { CLOGE("Stream %d was already fully configured.", streamId); return INVALID_OPERATION; Loading Loading @@ -2246,7 +2249,6 @@ status_t Camera3Device::dropStreamBuffers(bool dropping, int streamId) { sp<Camera3Device::CaptureRequest> Camera3Device::createCaptureRequest( const PhysicalCameraSettingsList &request, const SurfaceMap &surfaceMap) { ATRACE_CALL(); status_t res; sp<CaptureRequest> newRequest = new CaptureRequest; newRequest->mSettingsList = request; Loading @@ -2260,17 +2262,12 @@ sp<Camera3Device::CaptureRequest> Camera3Device::createCaptureRequest( inputStreams.data.u8[0]); return NULL; } // Lazy completion of stream configuration (allocation/registration) // on first use if (mInputStream->isConfiguring()) { res = mInputStream->finishConfiguration(); if (res != OK) { SET_ERR_L("Unable to finish configuring input stream %d:" " %s (%d)", mInputStream->getId(), strerror(-res), res); SET_ERR_L("%s: input stream %d is not configured!", __FUNCTION__, mInputStream->getId()); return NULL; } } // Check if stream prepare is blocking requests. if (mInputStream->isBlockedByPrepare()) { CLOGE("Request references an input stream that's being prepared!"); Loading Loading @@ -2312,16 +2309,10 @@ sp<Camera3Device::CaptureRequest> Camera3Device::createCaptureRequest( newRequest->mOutputSurfaces[i] = surfaces; } // Lazy completion of stream configuration (allocation/registration) // on first use if (stream->isConfiguring()) { res = stream->finishConfiguration(); if (res != OK) { SET_ERR_L("Unable to finish configuring stream %d: %s (%d)", stream->getId(), strerror(-res), res); SET_ERR_L("%s: stream %d is not configured!", __FUNCTION__, stream->getId()); return NULL; } } // Check if stream prepare is blocking requests. if (stream->isBlockedByPrepare()) { CLOGE("Request references an output stream that's being prepared!"); Loading Loading @@ -2538,7 +2529,8 @@ status_t Camera3Device::configureStreamsLocked(int operatingMode, // faster if (mInputStream != NULL && mInputStream->isConfiguring()) { res = mInputStream->finishConfiguration(); bool streamReConfigured = false; res = mInputStream->finishConfiguration(&streamReConfigured); if (res != OK) { CLOGE("Can't finish configuring input stream %d: %s (%d)", mInputStream->getId(), strerror(-res), res); Loading @@ -2548,13 +2540,17 @@ status_t Camera3Device::configureStreamsLocked(int operatingMode, } return BAD_VALUE; } if (streamReConfigured) { mInterface->onStreamReConfigured(mInputStream->getId()); } } for (size_t i = 0; i < mOutputStreams.size(); i++) { sp<Camera3OutputStreamInterface> outputStream = mOutputStreams.editValueAt(i); if (outputStream->isConfiguring() && !outputStream->isConsumerConfigurationDeferred()) { res = outputStream->finishConfiguration(); bool streamReConfigured = false; res = outputStream->finishConfiguration(&streamReConfigured); if (res != OK) { CLOGE("Can't finish configuring output stream %d: %s (%d)", outputStream->getId(), strerror(-res), res); Loading @@ -2564,6 +2560,9 @@ status_t Camera3Device::configureStreamsLocked(int operatingMode, } return BAD_VALUE; } if (streamReConfigured) { mInterface->onStreamReConfigured(outputStream->getId()); } } } Loading Loading @@ -4105,6 +4104,22 @@ void Camera3Device::HalInterface::onBufferFreed( mFreedBuffers.push_back(std::make_pair(streamId, bufferId)); } void Camera3Device::HalInterface::onStreamReConfigured(int streamId) { std::lock_guard<std::mutex> lock(mBufferIdMapLock); auto mapIt = mBufferIdMaps.find(streamId); if (mapIt == mBufferIdMaps.end()) { ALOGE("%s: streamId %d not found!", __FUNCTION__, streamId); return; } BufferIdMap& bIdMap = mapIt->second; for (const auto& it : bIdMap) { uint64_t bufferId = it.second; mFreedBuffers.push_back(std::make_pair(streamId, bufferId)); } bIdMap.clear(); } /** * RequestThread inner class methods */ Loading services/camera/libcameraservice/device3/Camera3Device.h +2 −0 Original line number Diff line number Diff line Loading @@ -305,6 +305,8 @@ class Camera3Device : // buffers void getInflightBufferKeys(std::vector<std::pair<int32_t, int32_t>>* out); void onStreamReConfigured(int streamId); private: // Always valid sp<hardware::camera::device::V3_2::ICameraDeviceSession> mHidlSession; Loading services/camera/libcameraservice/device3/Camera3Stream.cpp +9 −2 Original line number Diff line number Diff line Loading @@ -286,8 +286,11 @@ bool Camera3Stream::isConfiguring() const { return (mState == STATE_IN_CONFIG) || (mState == STATE_IN_RECONFIG); } status_t Camera3Stream::finishConfiguration() { status_t Camera3Stream::finishConfiguration(/*out*/bool* streamReconfigured) { ATRACE_CALL(); if (streamReconfigured != nullptr) { *streamReconfigured = false; } Mutex::Autolock l(mLock); switch (mState) { case STATE_ERROR: Loading @@ -312,7 +315,7 @@ status_t Camera3Stream::finishConfiguration() { // Register for idle tracking sp<StatusTracker> statusTracker = mStatusTracker.promote(); if (statusTracker != 0) { if (statusTracker != 0 && mStatusId == StatusTracker::NO_STATUS_ID) { mStatusId = statusTracker->addComponent(); } Loading @@ -331,6 +334,7 @@ status_t Camera3Stream::finishConfiguration() { mPrepareBlockRequest = true; mStreamUnpreparable = false; bool reconfiguring = (mState == STATE_IN_RECONFIG); status_t res; res = configureQueueLocked(); // configureQueueLocked could return error in case of abandoned surface. Loading @@ -347,6 +351,9 @@ status_t Camera3Stream::finishConfiguration() { return res; } if (reconfiguring && streamReconfigured != nullptr) { *streamReconfigured = true; } mState = STATE_CONFIGURED; return res; Loading services/camera/libcameraservice/device3/Camera3Stream.h +3 −1 Original line number Diff line number Diff line Loading @@ -197,6 +197,8 @@ class Camera3Stream : * after this call, but can still be read until the destruction of the * stream. * * streamReconfigured: set to true when a stream is being reconfigured. * * Returns: * OK on a successful configuration * NO_INIT in case of a serious error from the HAL device Loading @@ -204,7 +206,7 @@ class Camera3Stream : * INVALID_OPERATION in case connecting to the consumer failed or consumer * doesn't exist yet. */ status_t finishConfiguration(); status_t finishConfiguration(/*out*/bool* streamReconfigured = nullptr); /** * Cancels the stream configuration process. This returns the stream to the Loading services/camera/libcameraservice/device3/Camera3StreamInterface.h +3 −1 Original line number Diff line number Diff line Loading @@ -128,13 +128,15 @@ class Camera3StreamInterface : public virtual RefBase { * modified after this call, but can still be read until the destruction of * the stream. * * streamReconfigured: set to true when a stream is being reconfigured. * * Returns: * OK on a successful configuration * NO_INIT in case of a serious error from the HAL device * NO_MEMORY in case of an error registering buffers * INVALID_OPERATION in case connecting to the consumer failed */ virtual status_t finishConfiguration() = 0; virtual status_t finishConfiguration(/*out*/bool* streamReconfigured = nullptr) = 0; /** * Cancels the stream configuration process. This returns the stream to the Loading Loading
services/camera/libcameraservice/device3/Camera3Device.cpp +37 −22 Original line number Diff line number Diff line Loading @@ -2152,7 +2152,10 @@ status_t Camera3Device::setConsumerSurfaces(int streamId, CLOGE("Stream %d is unknown", streamId); return idx; } sp<Camera3OutputStreamInterface> stream = mOutputStreams[idx]; // isConsumerConfigurationDeferred will be off after setConsumers bool isDeferred = stream->isConsumerConfigurationDeferred(); status_t res = stream->setConsumers(consumers); if (res != OK) { CLOGE("Stream %d set consumer failed (error %d %s) ", streamId, res, strerror(-res)); Loading @@ -2168,7 +2171,7 @@ status_t Camera3Device::setConsumerSurfaces(int streamId, surfaceIds->push_back(id); } if (stream->isConsumerConfigurationDeferred()) { if (isDeferred) { if (!stream->isConfiguring()) { CLOGE("Stream %d was already fully configured.", streamId); return INVALID_OPERATION; Loading Loading @@ -2246,7 +2249,6 @@ status_t Camera3Device::dropStreamBuffers(bool dropping, int streamId) { sp<Camera3Device::CaptureRequest> Camera3Device::createCaptureRequest( const PhysicalCameraSettingsList &request, const SurfaceMap &surfaceMap) { ATRACE_CALL(); status_t res; sp<CaptureRequest> newRequest = new CaptureRequest; newRequest->mSettingsList = request; Loading @@ -2260,17 +2262,12 @@ sp<Camera3Device::CaptureRequest> Camera3Device::createCaptureRequest( inputStreams.data.u8[0]); return NULL; } // Lazy completion of stream configuration (allocation/registration) // on first use if (mInputStream->isConfiguring()) { res = mInputStream->finishConfiguration(); if (res != OK) { SET_ERR_L("Unable to finish configuring input stream %d:" " %s (%d)", mInputStream->getId(), strerror(-res), res); SET_ERR_L("%s: input stream %d is not configured!", __FUNCTION__, mInputStream->getId()); return NULL; } } // Check if stream prepare is blocking requests. if (mInputStream->isBlockedByPrepare()) { CLOGE("Request references an input stream that's being prepared!"); Loading Loading @@ -2312,16 +2309,10 @@ sp<Camera3Device::CaptureRequest> Camera3Device::createCaptureRequest( newRequest->mOutputSurfaces[i] = surfaces; } // Lazy completion of stream configuration (allocation/registration) // on first use if (stream->isConfiguring()) { res = stream->finishConfiguration(); if (res != OK) { SET_ERR_L("Unable to finish configuring stream %d: %s (%d)", stream->getId(), strerror(-res), res); SET_ERR_L("%s: stream %d is not configured!", __FUNCTION__, stream->getId()); return NULL; } } // Check if stream prepare is blocking requests. if (stream->isBlockedByPrepare()) { CLOGE("Request references an output stream that's being prepared!"); Loading Loading @@ -2538,7 +2529,8 @@ status_t Camera3Device::configureStreamsLocked(int operatingMode, // faster if (mInputStream != NULL && mInputStream->isConfiguring()) { res = mInputStream->finishConfiguration(); bool streamReConfigured = false; res = mInputStream->finishConfiguration(&streamReConfigured); if (res != OK) { CLOGE("Can't finish configuring input stream %d: %s (%d)", mInputStream->getId(), strerror(-res), res); Loading @@ -2548,13 +2540,17 @@ status_t Camera3Device::configureStreamsLocked(int operatingMode, } return BAD_VALUE; } if (streamReConfigured) { mInterface->onStreamReConfigured(mInputStream->getId()); } } for (size_t i = 0; i < mOutputStreams.size(); i++) { sp<Camera3OutputStreamInterface> outputStream = mOutputStreams.editValueAt(i); if (outputStream->isConfiguring() && !outputStream->isConsumerConfigurationDeferred()) { res = outputStream->finishConfiguration(); bool streamReConfigured = false; res = outputStream->finishConfiguration(&streamReConfigured); if (res != OK) { CLOGE("Can't finish configuring output stream %d: %s (%d)", outputStream->getId(), strerror(-res), res); Loading @@ -2564,6 +2560,9 @@ status_t Camera3Device::configureStreamsLocked(int operatingMode, } return BAD_VALUE; } if (streamReConfigured) { mInterface->onStreamReConfigured(outputStream->getId()); } } } Loading Loading @@ -4105,6 +4104,22 @@ void Camera3Device::HalInterface::onBufferFreed( mFreedBuffers.push_back(std::make_pair(streamId, bufferId)); } void Camera3Device::HalInterface::onStreamReConfigured(int streamId) { std::lock_guard<std::mutex> lock(mBufferIdMapLock); auto mapIt = mBufferIdMaps.find(streamId); if (mapIt == mBufferIdMaps.end()) { ALOGE("%s: streamId %d not found!", __FUNCTION__, streamId); return; } BufferIdMap& bIdMap = mapIt->second; for (const auto& it : bIdMap) { uint64_t bufferId = it.second; mFreedBuffers.push_back(std::make_pair(streamId, bufferId)); } bIdMap.clear(); } /** * RequestThread inner class methods */ Loading
services/camera/libcameraservice/device3/Camera3Device.h +2 −0 Original line number Diff line number Diff line Loading @@ -305,6 +305,8 @@ class Camera3Device : // buffers void getInflightBufferKeys(std::vector<std::pair<int32_t, int32_t>>* out); void onStreamReConfigured(int streamId); private: // Always valid sp<hardware::camera::device::V3_2::ICameraDeviceSession> mHidlSession; Loading
services/camera/libcameraservice/device3/Camera3Stream.cpp +9 −2 Original line number Diff line number Diff line Loading @@ -286,8 +286,11 @@ bool Camera3Stream::isConfiguring() const { return (mState == STATE_IN_CONFIG) || (mState == STATE_IN_RECONFIG); } status_t Camera3Stream::finishConfiguration() { status_t Camera3Stream::finishConfiguration(/*out*/bool* streamReconfigured) { ATRACE_CALL(); if (streamReconfigured != nullptr) { *streamReconfigured = false; } Mutex::Autolock l(mLock); switch (mState) { case STATE_ERROR: Loading @@ -312,7 +315,7 @@ status_t Camera3Stream::finishConfiguration() { // Register for idle tracking sp<StatusTracker> statusTracker = mStatusTracker.promote(); if (statusTracker != 0) { if (statusTracker != 0 && mStatusId == StatusTracker::NO_STATUS_ID) { mStatusId = statusTracker->addComponent(); } Loading @@ -331,6 +334,7 @@ status_t Camera3Stream::finishConfiguration() { mPrepareBlockRequest = true; mStreamUnpreparable = false; bool reconfiguring = (mState == STATE_IN_RECONFIG); status_t res; res = configureQueueLocked(); // configureQueueLocked could return error in case of abandoned surface. Loading @@ -347,6 +351,9 @@ status_t Camera3Stream::finishConfiguration() { return res; } if (reconfiguring && streamReconfigured != nullptr) { *streamReconfigured = true; } mState = STATE_CONFIGURED; return res; Loading
services/camera/libcameraservice/device3/Camera3Stream.h +3 −1 Original line number Diff line number Diff line Loading @@ -197,6 +197,8 @@ class Camera3Stream : * after this call, but can still be read until the destruction of the * stream. * * streamReconfigured: set to true when a stream is being reconfigured. * * Returns: * OK on a successful configuration * NO_INIT in case of a serious error from the HAL device Loading @@ -204,7 +206,7 @@ class Camera3Stream : * INVALID_OPERATION in case connecting to the consumer failed or consumer * doesn't exist yet. */ status_t finishConfiguration(); status_t finishConfiguration(/*out*/bool* streamReconfigured = nullptr); /** * Cancels the stream configuration process. This returns the stream to the Loading
services/camera/libcameraservice/device3/Camera3StreamInterface.h +3 −1 Original line number Diff line number Diff line Loading @@ -128,13 +128,15 @@ class Camera3StreamInterface : public virtual RefBase { * modified after this call, but can still be read until the destruction of * the stream. * * streamReconfigured: set to true when a stream is being reconfigured. * * Returns: * OK on a successful configuration * NO_INIT in case of a serious error from the HAL device * NO_MEMORY in case of an error registering buffers * INVALID_OPERATION in case connecting to the consumer failed */ virtual status_t finishConfiguration() = 0; virtual status_t finishConfiguration(/*out*/bool* streamReconfigured = nullptr) = 0; /** * Cancels the stream configuration process. This returns the stream to the Loading