From 60800208d31bc5a0770c3acb4f7df53c6bb1ac39 Mon Sep 17 00:00:00 2001 From: Zhijun He Date: Wed, 18 Jun 2014 11:43:02 -0700 Subject: Camera2/3: Don't release recording buffer when stream is active It is dangerous to release all recording buffers when recording stream is actively sending buffer to encoder. This change only releases all buffers when recording stream is idle and recording stream is about to start. Bug: 15667833 Change-Id: Ia4a84cac84a2062c13333467c66698273ffb0e23 --- .../libcameraservice/api1/client2/StreamingProcessor.cpp | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/services/camera/libcameraservice/api1/client2/StreamingProcessor.cpp b/services/camera/libcameraservice/api1/client2/StreamingProcessor.cpp index 2064e2c..99abced 100644 --- a/services/camera/libcameraservice/api1/client2/StreamingProcessor.cpp +++ b/services/camera/libcameraservice/api1/client2/StreamingProcessor.cpp @@ -430,10 +430,13 @@ status_t StreamingProcessor::startStream(StreamType type, Mutex::Autolock m(mMutex); - // If a recording stream is being started up, free up any - // outstanding buffers left from the previous recording session. - // There should never be any, so if there are, warn about it. - if (isStreamActive(outputStreams, mRecordingStreamId)) { + // If a recording stream is being started up and no recording + // stream is active yet, free up any outstanding buffers left + // from the previous recording session. There should never be + // any, so if there are, warn about it. + bool isRecordingStreamIdle = !isStreamActive(mActiveStreamIds, mRecordingStreamId); + bool startRecordingStream = isStreamActive(outputStreams, mRecordingStreamId); + if (startRecordingStream && isRecordingStreamIdle) { releaseAllRecordingFramesLocked(); } -- cgit v1.1