Camera: Release online and offline resources

Clear the cached previous request in case of
successful offline switch. The request can
potentially continue to have valid references
to offline streams.
Clear the online camera device reference after
composite streams switch to offline mode.
In this case, all internal offline streams must
be released by the offline session.

Bug: 149346795
Test: Camera CTS
Change-Id: If29308dd0f402ab492e304e0475005b2a9801e74
gugelfrei
Emilian Peev 4 years ago
parent 5e3b767908
commit c0fe54c642

@ -59,6 +59,10 @@ status_t CameraOfflineSessionClient::initialize(sp<CameraProviderManager>, const
return res;
}
for (size_t i = 0; i < mCompositeStreamMap.size(); i++) {
mCompositeStreamMap.valueAt(i)->switchToOffline();
}
return OK;
}

@ -200,5 +200,10 @@ void CompositeStream::notifyError(int64_t frameNumber) {
}
}
void CompositeStream::switchToOffline() {
Mutex::Autolock l(mMutex);
mDevice.clear();
}
}; // namespace camera3
}; // namespace android

@ -48,6 +48,9 @@ public:
status_t deleteStream();
// Switch to offline mode and release any online resources.
void switchToOffline();
// Create and register all internal camera streams.
virtual status_t createInternalStreams(const std::vector<sp<Surface>>& consumers,
bool hasDeferredConsumer, uint32_t width, uint32_t height, int format,

@ -619,14 +619,15 @@ status_t DepthCompositeStream::deleteInternalStreams() {
strerror(-ret), ret);
}
sp<CameraDeviceBase> device = mDevice.promote();
if (!device.get()) {
ALOGE("%s: Invalid camera device!", __FUNCTION__);
return NO_INIT;
}
if (mDepthStreamId >= 0) {
ret = device->deleteStream(mDepthStreamId);
// Camera devices may not be valid after switching to offline mode.
// In this case, all offline streams including internal composite streams
// are managed and released by the offline session.
sp<CameraDeviceBase> device = mDevice.promote();
if (device.get() != nullptr) {
ret = device->deleteStream(mDepthStreamId);
}
mDepthStreamId = -1;
}

@ -209,13 +209,14 @@ status_t HeicCompositeStream::deleteInternalStreams() {
deinitCodec();
if (mAppSegmentStreamId >= 0) {
// Camera devices may not be valid after switching to offline mode.
// In this case, all offline streams including internal composite streams
// are managed and released by the offline session.
sp<CameraDeviceBase> device = mDevice.promote();
if (!device.get()) {
ALOGE("%s: Invalid camera device!", __FUNCTION__);
return NO_INIT;
if (device.get() != nullptr) {
res = device->deleteStream(mAppSegmentStreamId);
}
res = device->deleteStream(mAppSegmentStreamId);
mAppSegmentStreamId = -1;
}

@ -4758,6 +4758,11 @@ void Camera3Device::RequestThread::signalPipelineDrain(const std::vector<int>& s
mStreamIdsToBeDrained = streamIds;
}
void Camera3Device::RequestThread::clearPreviousRequest() {
Mutex::Autolock l(mRequestLock);
mPrevRequest.clear();
}
status_t Camera3Device::RequestThread::switchToOffline(
const std::vector<int32_t>& streamsToKeep,
/*out*/hardware::camera::device::V3_6::CameraOfflineSessionInfo* offlineSessionInfo,
@ -5917,6 +5922,7 @@ status_t Camera3Device::switchToOffline(
internalUpdateStatusLocked(STATUS_UNCONFIGURED);
mOperatingMode = NO_MODE;
mIsConstrainedHighSpeedConfiguration = false;
mRequestThread->clearPreviousRequest();
return OK;
// TO be done by CameraDeviceClient/Camera3OfflineSession

@ -837,6 +837,8 @@ class Camera3Device :
/*out*/sp<hardware::camera::device::V3_6::ICameraOfflineSession>* offlineSession,
/*out*/camera3::BufferRecords* bufferRecords);
void clearPreviousRequest();
status_t setRotateAndCropAutoBehavior(
camera_metadata_enum_android_scaler_rotate_and_crop_t rotateAndCropValue);

Loading…
Cancel
Save