Loading libs/gui/BufferQueueConsumer.cpp +82 −65 Original line number Diff line number Diff line Loading @@ -42,6 +42,8 @@ #include <system/window.h> #include <com_android_graphics_libgui_flags.h> namespace android { // Macros for include BufferQueueCore information in log messages Loading Loading @@ -370,6 +372,8 @@ status_t BufferQueueConsumer::attachBuffer(int* outSlot, return BAD_VALUE; } sp<IProducerListener> listener; { std::lock_guard<std::mutex> lock(mCore->mMutex); if (mCore->mSharedBufferMode) { Loading Loading @@ -414,6 +418,12 @@ status_t BufferQueueConsumer::attachBuffer(int* outSlot, return NO_MEMORY; } #if COM_ANDROID_GRAPHICS_LIBGUI_FLAGS(BQ_CONSUMER_ATTACH_CALLBACK) if (mCore->mBufferAttachedCbEnabled) { listener = mCore->mConnectedProducerListener; } #endif mCore->mActiveBuffers.insert(found); *outSlot = found; ATRACE_BUFFER_INDEX(*outSlot); Loading Loading @@ -443,6 +453,13 @@ status_t BufferQueueConsumer::attachBuffer(int* outSlot, mSlots[*outSlot].mAcquireCalled = false; VALIDATE_CONSISTENCY(); } #if COM_ANDROID_GRAPHICS_LIBGUI_FLAGS(BQ_CONSUMER_ATTACH_CALLBACK) if (listener != nullptr) { listener->onBufferAttached(); } #endif return NO_ERROR; } Loading libs/gui/BufferQueueCore.cpp +1 −0 Original line number Diff line number Diff line Loading @@ -96,6 +96,7 @@ BufferQueueCore::BufferQueueCore() mLinkedToDeath(), mConnectedProducerListener(), mBufferReleasedCbEnabled(false), mBufferAttachedCbEnabled(false), mSlots(), mQueue(), mFreeSlots(), Loading libs/gui/BufferQueueProducer.cpp +3 −0 Original line number Diff line number Diff line Loading @@ -1324,6 +1324,9 @@ status_t BufferQueueProducer::connect(const sp<IProducerListener>& listener, #endif mCore->mConnectedProducerListener = listener; mCore->mBufferReleasedCbEnabled = listener->needsReleaseNotify(); #if COM_ANDROID_GRAPHICS_LIBGUI_FLAGS(BQ_CONSUMER_ATTACH_CALLBACK) mCore->mBufferAttachedCbEnabled = listener->needsAttachNotify(); #endif } break; default: Loading libs/gui/IProducerListener.cpp +56 −0 Original line number Diff line number Diff line Loading @@ -25,6 +25,9 @@ enum { ON_BUFFER_RELEASED = IBinder::FIRST_CALL_TRANSACTION, NEEDS_RELEASE_NOTIFY, ON_BUFFERS_DISCARDED, ON_BUFFER_DETACHED, ON_BUFFER_ATTACHED, NEEDS_ATTACH_NOTIFY, }; class BpProducerListener : public BpInterface<IProducerListener> Loading Loading @@ -64,6 +67,38 @@ public: data.writeInt32Vector(discardedSlots); remote()->transact(ON_BUFFERS_DISCARDED, data, &reply, IBinder::FLAG_ONEWAY); } #if COM_ANDROID_GRAPHICS_LIBGUI_FLAGS(BQ_CONSUMER_ATTACH_CALLBACK) virtual void onBufferDetached(int slot) { Parcel data, reply; data.writeInterfaceToken(IProducerListener::getInterfaceDescriptor()); data.writeInt32(slot); remote()->transact(ON_BUFFER_DETACHED, data, &reply, IBinder::FLAG_ONEWAY); } virtual void onBufferAttached() { Parcel data, reply; data.writeInterfaceToken(IProducerListener::getInterfaceDescriptor()); remote()->transact(ON_BUFFER_ATTACHED, data, &reply, IBinder::FLAG_ONEWAY); } virtual bool needsAttachNotify() { bool result; Parcel data, reply; data.writeInterfaceToken(IProducerListener::getInterfaceDescriptor()); status_t err = remote()->transact(NEEDS_ATTACH_NOTIFY, data, &reply); if (err != NO_ERROR) { ALOGE("IProducerListener: binder call \'needsAttachNotify\' failed"); return true; } err = reply.readBool(&result); if (err != NO_ERROR) { ALOGE("IProducerListener: malformed binder reply"); return true; } return result; } #endif }; // Out-of-line virtual method definition to trigger vtable emission in this Loading Loading @@ -115,6 +150,27 @@ status_t BnProducerListener::onTransact(uint32_t code, const Parcel& data, onBuffersDiscarded(discardedSlots); return NO_ERROR; } #if COM_ANDROID_GRAPHICS_LIBGUI_FLAGS(BQ_CONSUMER_ATTACH_CALLBACK) case ON_BUFFER_DETACHED: { CHECK_INTERFACE(IProducerListener, data, reply); int slot; status_t result = data.readInt32(&slot); if (result != NO_ERROR) { ALOGE("ON_BUFFER_DETACHED failed to read slot: %d", result); return result; } onBufferDetached(slot); return NO_ERROR; } case ON_BUFFER_ATTACHED: CHECK_INTERFACE(IProducerListener, data, reply); onBufferAttached(); return NO_ERROR; case NEEDS_ATTACH_NOTIFY: CHECK_INTERFACE(IProducerListener, data, reply); reply->writeBool(needsAttachNotify()); return NO_ERROR; #endif } return BBinder::onTransact(code, data, reply, flags); } Loading libs/gui/include/gui/BufferQueueCore.h +4 −0 Original line number Diff line number Diff line Loading @@ -189,6 +189,10 @@ private: // callback is registered by the listener. When set to false, // mConnectedProducerListener will not trigger onBufferReleased() callback. bool mBufferReleasedCbEnabled; // mBufferAttachedCbEnabled is used to indicate whether onBufferAttached() // callback is registered by the listener. When set to false, // mConnectedProducerListener will not trigger onBufferAttached() callback. bool mBufferAttachedCbEnabled; // mSlots is an array of buffer slots that must be mirrored on the producer // side. This allows buffer ownership to be transferred between the producer Loading Loading
libs/gui/BufferQueueConsumer.cpp +82 −65 Original line number Diff line number Diff line Loading @@ -42,6 +42,8 @@ #include <system/window.h> #include <com_android_graphics_libgui_flags.h> namespace android { // Macros for include BufferQueueCore information in log messages Loading Loading @@ -370,6 +372,8 @@ status_t BufferQueueConsumer::attachBuffer(int* outSlot, return BAD_VALUE; } sp<IProducerListener> listener; { std::lock_guard<std::mutex> lock(mCore->mMutex); if (mCore->mSharedBufferMode) { Loading Loading @@ -414,6 +418,12 @@ status_t BufferQueueConsumer::attachBuffer(int* outSlot, return NO_MEMORY; } #if COM_ANDROID_GRAPHICS_LIBGUI_FLAGS(BQ_CONSUMER_ATTACH_CALLBACK) if (mCore->mBufferAttachedCbEnabled) { listener = mCore->mConnectedProducerListener; } #endif mCore->mActiveBuffers.insert(found); *outSlot = found; ATRACE_BUFFER_INDEX(*outSlot); Loading Loading @@ -443,6 +453,13 @@ status_t BufferQueueConsumer::attachBuffer(int* outSlot, mSlots[*outSlot].mAcquireCalled = false; VALIDATE_CONSISTENCY(); } #if COM_ANDROID_GRAPHICS_LIBGUI_FLAGS(BQ_CONSUMER_ATTACH_CALLBACK) if (listener != nullptr) { listener->onBufferAttached(); } #endif return NO_ERROR; } Loading
libs/gui/BufferQueueCore.cpp +1 −0 Original line number Diff line number Diff line Loading @@ -96,6 +96,7 @@ BufferQueueCore::BufferQueueCore() mLinkedToDeath(), mConnectedProducerListener(), mBufferReleasedCbEnabled(false), mBufferAttachedCbEnabled(false), mSlots(), mQueue(), mFreeSlots(), Loading
libs/gui/BufferQueueProducer.cpp +3 −0 Original line number Diff line number Diff line Loading @@ -1324,6 +1324,9 @@ status_t BufferQueueProducer::connect(const sp<IProducerListener>& listener, #endif mCore->mConnectedProducerListener = listener; mCore->mBufferReleasedCbEnabled = listener->needsReleaseNotify(); #if COM_ANDROID_GRAPHICS_LIBGUI_FLAGS(BQ_CONSUMER_ATTACH_CALLBACK) mCore->mBufferAttachedCbEnabled = listener->needsAttachNotify(); #endif } break; default: Loading
libs/gui/IProducerListener.cpp +56 −0 Original line number Diff line number Diff line Loading @@ -25,6 +25,9 @@ enum { ON_BUFFER_RELEASED = IBinder::FIRST_CALL_TRANSACTION, NEEDS_RELEASE_NOTIFY, ON_BUFFERS_DISCARDED, ON_BUFFER_DETACHED, ON_BUFFER_ATTACHED, NEEDS_ATTACH_NOTIFY, }; class BpProducerListener : public BpInterface<IProducerListener> Loading Loading @@ -64,6 +67,38 @@ public: data.writeInt32Vector(discardedSlots); remote()->transact(ON_BUFFERS_DISCARDED, data, &reply, IBinder::FLAG_ONEWAY); } #if COM_ANDROID_GRAPHICS_LIBGUI_FLAGS(BQ_CONSUMER_ATTACH_CALLBACK) virtual void onBufferDetached(int slot) { Parcel data, reply; data.writeInterfaceToken(IProducerListener::getInterfaceDescriptor()); data.writeInt32(slot); remote()->transact(ON_BUFFER_DETACHED, data, &reply, IBinder::FLAG_ONEWAY); } virtual void onBufferAttached() { Parcel data, reply; data.writeInterfaceToken(IProducerListener::getInterfaceDescriptor()); remote()->transact(ON_BUFFER_ATTACHED, data, &reply, IBinder::FLAG_ONEWAY); } virtual bool needsAttachNotify() { bool result; Parcel data, reply; data.writeInterfaceToken(IProducerListener::getInterfaceDescriptor()); status_t err = remote()->transact(NEEDS_ATTACH_NOTIFY, data, &reply); if (err != NO_ERROR) { ALOGE("IProducerListener: binder call \'needsAttachNotify\' failed"); return true; } err = reply.readBool(&result); if (err != NO_ERROR) { ALOGE("IProducerListener: malformed binder reply"); return true; } return result; } #endif }; // Out-of-line virtual method definition to trigger vtable emission in this Loading Loading @@ -115,6 +150,27 @@ status_t BnProducerListener::onTransact(uint32_t code, const Parcel& data, onBuffersDiscarded(discardedSlots); return NO_ERROR; } #if COM_ANDROID_GRAPHICS_LIBGUI_FLAGS(BQ_CONSUMER_ATTACH_CALLBACK) case ON_BUFFER_DETACHED: { CHECK_INTERFACE(IProducerListener, data, reply); int slot; status_t result = data.readInt32(&slot); if (result != NO_ERROR) { ALOGE("ON_BUFFER_DETACHED failed to read slot: %d", result); return result; } onBufferDetached(slot); return NO_ERROR; } case ON_BUFFER_ATTACHED: CHECK_INTERFACE(IProducerListener, data, reply); onBufferAttached(); return NO_ERROR; case NEEDS_ATTACH_NOTIFY: CHECK_INTERFACE(IProducerListener, data, reply); reply->writeBool(needsAttachNotify()); return NO_ERROR; #endif } return BBinder::onTransact(code, data, reply, flags); } Loading
libs/gui/include/gui/BufferQueueCore.h +4 −0 Original line number Diff line number Diff line Loading @@ -189,6 +189,10 @@ private: // callback is registered by the listener. When set to false, // mConnectedProducerListener will not trigger onBufferReleased() callback. bool mBufferReleasedCbEnabled; // mBufferAttachedCbEnabled is used to indicate whether onBufferAttached() // callback is registered by the listener. When set to false, // mConnectedProducerListener will not trigger onBufferAttached() callback. bool mBufferAttachedCbEnabled; // mSlots is an array of buffer slots that must be mirrored on the producer // side. This allows buffer ownership to be transferred between the producer Loading