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

Commit 698f0a75 authored by Emilian Peev's avatar Emilian Peev
Browse files

Camera: Clear available callback buffers during recording stop

Make sure we don't keep any stale available callback buffer
references after recording stops. This can lead to resource
leaks.

Bug: 36478361
Test: Complete Camera/Camera2 CTS tests
Change-Id: I9f72b784ba3ae1cf9f9b16064a13b7ba8a1d0394
parent 4aa3bd04
Loading
Loading
Loading
Loading
+15 −6
Original line number Original line Diff line number Diff line
@@ -478,6 +478,7 @@ void CameraClient::stopPreview() {
// stop recording mode
// stop recording mode
void CameraClient::stopRecording() {
void CameraClient::stopRecording() {
    LOG1("stopRecording (pid %d)", getCallingPid());
    LOG1("stopRecording (pid %d)", getCallingPid());
    {
        Mutex::Autolock lock(mLock);
        Mutex::Autolock lock(mLock);
        if (checkPidAndHardware() != NO_ERROR) return;
        if (checkPidAndHardware() != NO_ERROR) return;


@@ -488,6 +489,14 @@ void CameraClient::stopRecording() {
        mPreviewBuffer.clear();
        mPreviewBuffer.clear();
    }
    }


    {
        Mutex::Autolock l(mAvailableCallbackBuffersLock);
        if (!mAvailableCallbackBuffers.empty()) {
            mAvailableCallbackBuffers.clear();
        }
    }
}

// release a recording frame
// release a recording frame
void CameraClient::releaseRecordingFrame(const sp<IMemory>& mem) {
void CameraClient::releaseRecordingFrame(const sp<IMemory>& mem) {
    Mutex::Autolock lock(mLock);
    Mutex::Autolock lock(mLock);