Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit c0fe54c6 authored by Emilian Peev's avatar Emilian Peev
Browse files

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
parent 5e3b7679
Loading
Loading
Loading
Loading
+4 −0
Original line number Diff line number Diff line
@@ -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;
}

+5 −0
Original line number Diff line number Diff line
@@ -200,5 +200,10 @@ void CompositeStream::notifyError(int64_t frameNumber) {
    }
}

void CompositeStream::switchToOffline() {
    Mutex::Autolock l(mMutex);
    mDevice.clear();
}

}; // namespace camera3
}; // namespace android
+3 −0
Original line number Diff line number Diff line
@@ -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,
+8 −7
Original line number Diff line number Diff line
@@ -619,14 +619,15 @@ status_t DepthCompositeStream::deleteInternalStreams() {
                strerror(-ret), ret);
    }

    if (mDepthStreamId >= 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) {
            ret = device->deleteStream(mDepthStreamId);
        }

    if (mDepthStreamId >= 0) {
        ret = device->deleteStream(mDepthStreamId);
        mDepthStreamId = -1;
    }

+5 −4
Original line number Diff line number Diff line
@@ -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;
    }

Loading