diff --git a/libs/gui/BufferQueue.cpp b/libs/gui/BufferQueue.cpp index 87d66e2b7..c165a6820 100644 --- a/libs/gui/BufferQueue.cpp +++ b/libs/gui/BufferQueue.cpp @@ -668,11 +668,15 @@ status_t BufferQueue::connect(const sp& token, mConnectedApi = api; output->inflate(mDefaultWidth, mDefaultHeight, mTransformHint, mQueue.size()); - // set-up a death notification so that we can disconnect automatically - // when/if the remote producer dies. - // This will fail with INVALID_OPERATION if the "token" is local to our process. - if (token->linkToDeath(static_cast(this)) == NO_ERROR) { - mConnectedProducerToken = token; + // set-up a death notification so that we can disconnect + // automatically when/if the remote producer dies. + if (token != NULL && token->remoteBinder() != NULL) { + status_t err = token->linkToDeath(static_cast(this)); + if (err == NO_ERROR) { + mConnectedProducerToken = token; + } else { + ALOGE("linkToDeath failed: %s (%d)", strerror(-err), err); + } } } break;