camera3: Don't try to disconnect stream native windows more than once
This fixes the multiple-disconnect-from-BufferQueue bug.
(In logs)
BufferQueue: [SurfaceView] disconnect: connected to another api (cur=0, req=4)
Bug: 9114681
Change-Id: I21ae1c5bd993701eea13648aa9994979a24eb210
diff --git a/services/camera/libcameraservice/Camera3Device.cpp b/services/camera/libcameraservice/Camera3Device.cpp
index 1d38993..0b5e9c4 100644
--- a/services/camera/libcameraservice/Camera3Device.cpp
+++ b/services/camera/libcameraservice/Camera3Device.cpp
@@ -677,6 +677,8 @@
Mutex::Autolock l(mLock);
status_t res;
+ ALOGV("%s: Camera %d: Deleting stream %d", __FUNCTION__, mId, id);
+
// CameraDevice semantics require device to already be idle before
// deleteStream is called, unlike for createStream.
if (mStatus != STATUS_IDLE) {
diff --git a/services/camera/libcameraservice/camera3/Camera3IOStreamBase.cpp b/services/camera/libcameraservice/camera3/Camera3IOStreamBase.cpp
index abc28fe..0850566 100644
--- a/services/camera/libcameraservice/camera3/Camera3IOStreamBase.cpp
+++ b/services/camera/libcameraservice/camera3/Camera3IOStreamBase.cpp
@@ -159,7 +159,9 @@
break;
default:
// No connection, nothing to do
- return OK;
+ ALOGV("%s: Stream %d: Already disconnected",
+ __FUNCTION__, mId);
+ return -ENOTCONN;
}
if (mDequeuedBufferCount > 0) {
diff --git a/services/camera/libcameraservice/camera3/Camera3Stream.cpp b/services/camera/libcameraservice/camera3/Camera3Stream.cpp
index 9c9c258..f05658a 100644
--- a/services/camera/libcameraservice/camera3/Camera3Stream.cpp
+++ b/services/camera/libcameraservice/camera3/Camera3Stream.cpp
@@ -258,7 +258,15 @@
status_t Camera3Stream::disconnect() {
ATRACE_CALL();
Mutex::Autolock l(mLock);
- return disconnectLocked();
+ ALOGV("%s: Stream %d: Disconnecting...", __FUNCTION__, mId);
+ status_t res = disconnectLocked();
+
+ if (res == -ENOTCONN) {
+ // "Already disconnected" -- not an error
+ return OK;
+ } else {
+ return res;
+ }
}
status_t Camera3Stream::registerBuffersLocked(camera3_device *hal3Device) {
diff --git a/services/camera/libcameraservice/camera3/Camera3Stream.h b/services/camera/libcameraservice/camera3/Camera3Stream.h
index 4b3b346..69d81e4 100644
--- a/services/camera/libcameraservice/camera3/Camera3Stream.h
+++ b/services/camera/libcameraservice/camera3/Camera3Stream.h
@@ -251,6 +251,7 @@
virtual status_t returnInputBufferLocked(
const camera3_stream_buffer &buffer);
virtual bool hasOutstandingBuffersLocked() const = 0;
+ // Can return -ENOTCONN when we are already disconnected (not an error)
virtual status_t disconnectLocked() = 0;
// Configure the buffer queue interface to the other end of the stream,