diff options
author | Zhijun He <zhijunhe@google.com> | 2013-10-11 18:27:26 -0700 |
---|---|---|
committer | Android Git Automerger <android-git-automerger@android.com> | 2013-10-11 18:27:26 -0700 |
commit | 1810a287ecc81c243983051f9b1e32ff92ef1365 (patch) | |
tree | 46b17dad49e09e239dfcc399b64dbbfa2ff1a137 | |
parent | 92d275536ce3a7f1055627ac087b0f3a9957ad68 (diff) | |
parent | 15ad2470b2f2ac34473eb568b606ad75e8e63ac6 (diff) | |
download | frameworks_av-1810a287ecc81c243983051f9b1e32ff92ef1365.zip frameworks_av-1810a287ecc81c243983051f9b1e32ff92ef1365.tar.gz frameworks_av-1810a287ecc81c243983051f9b1e32ff92ef1365.tar.bz2 |
am 15ad2470: Camera: Fix deadlock in Camera3OutputStream
* commit '15ad2470b2f2ac34473eb568b606ad75e8e63ac6':
Camera: Fix deadlock in Camera3OutputStream
-rw-r--r-- | services/camera/libcameraservice/device3/Camera3OutputStream.cpp | 17 |
1 files changed, 16 insertions, 1 deletions
diff --git a/services/camera/libcameraservice/device3/Camera3OutputStream.cpp b/services/camera/libcameraservice/device3/Camera3OutputStream.cpp index 41328fc..682755d 100644 --- a/services/camera/libcameraservice/device3/Camera3OutputStream.cpp +++ b/services/camera/libcameraservice/device3/Camera3OutputStream.cpp @@ -92,7 +92,22 @@ status_t Camera3OutputStream::getBufferLocked(camera3_stream_buffer *buffer) { ANativeWindowBuffer* anb; int fenceFd; - res = mConsumer->dequeueBuffer(mConsumer.get(), &anb, &fenceFd); + /** + * Release the lock briefly to avoid deadlock for below scenario: + * Thread 1: StreamingProcessor::startStream -> Camera3Stream::isConfiguring(). + * This thread acquired StreamingProcessor lock and try to lock Camera3Stream lock. + * Thread 2: Camera3Stream::returnBuffer->StreamingProcessor::onFrameAvailable(). + * This thread acquired Camera3Stream lock and bufferQueue lock, and try to lock + * StreamingProcessor lock. + * Thread 3: Camera3Stream::getBuffer(). This thread acquired Camera3Stream lock + * and try to lock bufferQueue lock. + * Then there is circular locking dependency. + */ + sp<ANativeWindow> currentConsumer = mConsumer; + mLock.unlock(); + + res = currentConsumer->dequeueBuffer(currentConsumer.get(), &anb, &fenceFd); + mLock.lock(); if (res != OK) { ALOGE("%s: Stream %d: Can't dequeue next output buffer: %s (%d)", __FUNCTION__, mId, strerror(-res), res); |