From ae009083696b291a6fada63972dcad26041f28df Mon Sep 17 00:00:00 2001 From: Sungtak Lee Date: Wed, 17 Jan 2024 21:35:23 +0000 Subject: [PATCH] media.bufferpool2: Support receiver side initated buffer transfer Bug: 254050314 Change-Id: I4c1b49e3bb99b8dbdccc44e5e1562833a585d454 --- .../media/bufferpool2/IClientManager.aidl | 1 + .../media/bufferpool2/IClientManager.aidl | 20 ++++++++++++++++++- .../bufferpool/aidl/default/ClientManager.cpp | 8 ++++++++ .../include/bufferpool2/ClientManager.h | 5 +++++ 4 files changed, 33 insertions(+), 1 deletion(-) diff --git a/media/bufferpool/aidl/aidl_api/android.hardware.media.bufferpool2/current/android/hardware/media/bufferpool2/IClientManager.aidl b/media/bufferpool/aidl/aidl_api/android.hardware.media.bufferpool2/current/android/hardware/media/bufferpool2/IClientManager.aidl index 5899a403a6..298cb13ec3 100644 --- a/media/bufferpool/aidl/aidl_api/android.hardware.media.bufferpool2/current/android/hardware/media/bufferpool2/IClientManager.aidl +++ b/media/bufferpool/aidl/aidl_api/android.hardware.media.bufferpool2/current/android/hardware/media/bufferpool2/IClientManager.aidl @@ -35,6 +35,7 @@ package android.hardware.media.bufferpool2; @VintfStability interface IClientManager { android.hardware.media.bufferpool2.IClientManager.Registration registerSender(in android.hardware.media.bufferpool2.IAccessor bufferPool); + android.hardware.media.bufferpool2.IClientManager.Registration registerPassiveSender(in android.hardware.media.bufferpool2.IAccessor bufferPool); @VintfStability parcelable Registration { long connectionId; diff --git a/media/bufferpool/aidl/android/hardware/media/bufferpool2/IClientManager.aidl b/media/bufferpool/aidl/android/hardware/media/bufferpool2/IClientManager.aidl index a3054cb131..2bc77bcd68 100644 --- a/media/bufferpool/aidl/android/hardware/media/bufferpool2/IClientManager.aidl +++ b/media/bufferpool/aidl/android/hardware/media/bufferpool2/IClientManager.aidl @@ -40,7 +40,8 @@ interface IClientManager { /** * Sets up a buffer receiving communication node for the specified * buffer pool. A manager must create a IConnection to the buffer - * pool if it does not already have a connection. + * pool if it does not already have a connection. To transfer buffers + * using the interface, the sender must initiates transfer. * * @param bufferPool a buffer pool which is specified with the IAccessor. * The specified buffer pool is the owner of received buffers. @@ -52,4 +53,21 @@ interface IClientManager { * ResultStatus::CRITICAL_ERROR - Other errors. */ Registration registerSender(in IAccessor bufferPool); + + /** + * Sets up a buffer receiving communication node for the specified + * buffer pool. A manager must create a IConnection to the buffer + * pool if it does not already have a connection. To transfer buffers + * using the interface, the receiver must initiates transfer(on demand). + * + * @param bufferPool a buffer pool which is specified with the IAccessor. + * The specified buffer pool is the owner of received buffers. + * @return the Id of the communication node to the buffer pool. + * This id is used in FMQ to notify IAccessor that a buffer has been + * sent to that connection during transfers. + * @throws ServiceSpecificException with one of the following values: + * ResultStatus::NO_MEMORY - Memory allocation failure occurred. + * ResultStatus::CRITICAL_ERROR - Other errors. + */ + Registration registerPassiveSender(in IAccessor bufferPool); } diff --git a/media/bufferpool/aidl/default/ClientManager.cpp b/media/bufferpool/aidl/default/ClientManager.cpp index de1db50cd1..138790d650 100644 --- a/media/bufferpool/aidl/default/ClientManager.cpp +++ b/media/bufferpool/aidl/default/ClientManager.cpp @@ -422,6 +422,14 @@ void ClientManager::Impl::cleanUp(bool clearCache) { return ::ndk::ScopedAStatus::ok(); } +::ndk::ScopedAStatus ClientManager::registerPassiveSender( + const std::shared_ptr& in_bufferPool, Registration* _aidl_return) { + // TODO + (void) in_bufferPool; + (void) _aidl_return; + return ::ndk::ScopedAStatus::fromServiceSpecificError(ResultStatus::NOT_FOUND); +} + // Methods for local use. std::shared_ptr ClientManager::sInstance; std::mutex ClientManager::sInstanceLock; diff --git a/media/bufferpool/aidl/default/include/bufferpool2/ClientManager.h b/media/bufferpool/aidl/default/include/bufferpool2/ClientManager.h index bff75ba597..4b0916f3b8 100644 --- a/media/bufferpool/aidl/default/include/bufferpool2/ClientManager.h +++ b/media/bufferpool/aidl/default/include/bufferpool2/ClientManager.h @@ -34,6 +34,11 @@ struct ClientManager : public BnClientManager { ::aidl::android::hardware::media::bufferpool2::IClientManager::Registration* _aidl_return) override; + ::ndk::ScopedAStatus registerPassiveSender( + const std::shared_ptr& in_bufferPool, + ::aidl::android::hardware::media::bufferpool2::IClientManager::Registration* _aidl_return) + override; + /** Gets an instance. */ static std::shared_ptr getInstance();