Loading media/module/codecserviceregistrant/Android.bp +2 −0 Original line number Diff line number Diff line Loading @@ -55,6 +55,8 @@ cc_library { "com.android.media.swcodec", ], export_include_dirs: ["include"], srcs: [ "CodecServiceRegistrant.cpp", ], Loading media/module/codecserviceregistrant/CodecServiceRegistrant.cpp +15 −8 Original line number Diff line number Diff line Loading @@ -40,7 +40,7 @@ #include <codec2/aidl/ComponentStore.h> #include <codec2/aidl/ParamTypes.h> #include <media/CodecServiceRegistrant.h> #include <codecserviceregistrant/CodecServiceRegistrant.h> namespace /* unnamed */ { Loading Loading @@ -775,13 +775,12 @@ static android::sp<c2_hidl_V1_0::IComponentStore> getDeclaredHidlSwcodec( return nullptr; } extern "C" void RegisterCodecServices() { /** * This function encapsulates the core logic required to register codec services, * separated from threadpool management to avoid timeouts when called by the fuzzer. */ static void RegisterCodecServicesWithExistingThreadpool() { const bool aidlSelected = c2_aidl::utils::IsSelected(); constexpr int kThreadCount = 64; ABinderProcess_setThreadPoolMaxThreadCount(kThreadCount); ABinderProcess_startThreadPool(); ::android::hardware::configureRpcThreadpool(kThreadCount, false); LOG(INFO) << "Creating software Codec2 service..."; std::shared_ptr<C2ComponentStore> store = android::GetCodec2PlatformComponentStore(); Loading Loading @@ -880,8 +879,16 @@ extern "C" void RegisterCodecServices() { if (registered) { LOG(INFO) << "Software Codec2 service created and registered."; } } extern "C" void RegisterCodecServices() { constexpr int kThreadCount = 64; ABinderProcess_setThreadPoolMaxThreadCount(kThreadCount); ABinderProcess_startThreadPool(); ::android::hardware::configureRpcThreadpool(kThreadCount, false); RegisterCodecServicesWithExistingThreadpool(); ABinderProcess_joinThreadPool(); ::android::hardware::joinRpcThreadpool(); } media/module/codecserviceregistrant/fuzzer/codecServiceRegistrant_fuzzer.cpp +6 −3 Original line number Diff line number Diff line Loading @@ -13,6 +13,9 @@ * See the License for the specific language governing permissions and * limitations under the License. */ #include <codecserviceregistrant/CodecServiceRegistrant.h> #include "../CodecServiceRegistrant.cpp" #include "fuzzer/FuzzedDataProvider.h" #include <C2Config.h> Loading Loading @@ -166,9 +169,9 @@ void CodecServiceRegistrantFuzzer::invokeH2C2ComponentStore() { void CodecServiceRegistrantFuzzer::process(const uint8_t *data, size_t size) { mFDP = new FuzzedDataProvider(data, size); invokeH2C2ComponentStore(); /** RegisterCodecServices is called here to improve code coverage */ /** as currently it is not called by codecServiceRegistrant */ RegisterCodecServices(); /** RegisterCodecServicesWithExistingThreadpool() is called here to improve * code coverage as currently it is not called in codecServiceRegistrant.cpp */ RegisterCodecServicesWithExistingThreadpool(); delete mFDP; } Loading media/libmedia/include/media/CodecServiceRegistrant.h→media/module/codecserviceregistrant/include/codecserviceregistrant/CodecServiceRegistrant.h +7 −0 Original line number Diff line number Diff line Loading @@ -18,6 +18,13 @@ #define CODEC_SERVICE_REGISTRANT_H_ /** * This function starts the threadpool, calls the registration logic * encapsulated in RegisterCodecServicesWithExistingThreadpool(), and * then stops the threadpool. */ extern "C" void RegisterCodecServices(); typedef void (*RegisterCodecServicesFunc)(); #endif // CODEC_SERVICE_REGISTRANT_H_ Loading
media/module/codecserviceregistrant/Android.bp +2 −0 Original line number Diff line number Diff line Loading @@ -55,6 +55,8 @@ cc_library { "com.android.media.swcodec", ], export_include_dirs: ["include"], srcs: [ "CodecServiceRegistrant.cpp", ], Loading
media/module/codecserviceregistrant/CodecServiceRegistrant.cpp +15 −8 Original line number Diff line number Diff line Loading @@ -40,7 +40,7 @@ #include <codec2/aidl/ComponentStore.h> #include <codec2/aidl/ParamTypes.h> #include <media/CodecServiceRegistrant.h> #include <codecserviceregistrant/CodecServiceRegistrant.h> namespace /* unnamed */ { Loading Loading @@ -775,13 +775,12 @@ static android::sp<c2_hidl_V1_0::IComponentStore> getDeclaredHidlSwcodec( return nullptr; } extern "C" void RegisterCodecServices() { /** * This function encapsulates the core logic required to register codec services, * separated from threadpool management to avoid timeouts when called by the fuzzer. */ static void RegisterCodecServicesWithExistingThreadpool() { const bool aidlSelected = c2_aidl::utils::IsSelected(); constexpr int kThreadCount = 64; ABinderProcess_setThreadPoolMaxThreadCount(kThreadCount); ABinderProcess_startThreadPool(); ::android::hardware::configureRpcThreadpool(kThreadCount, false); LOG(INFO) << "Creating software Codec2 service..."; std::shared_ptr<C2ComponentStore> store = android::GetCodec2PlatformComponentStore(); Loading Loading @@ -880,8 +879,16 @@ extern "C" void RegisterCodecServices() { if (registered) { LOG(INFO) << "Software Codec2 service created and registered."; } } extern "C" void RegisterCodecServices() { constexpr int kThreadCount = 64; ABinderProcess_setThreadPoolMaxThreadCount(kThreadCount); ABinderProcess_startThreadPool(); ::android::hardware::configureRpcThreadpool(kThreadCount, false); RegisterCodecServicesWithExistingThreadpool(); ABinderProcess_joinThreadPool(); ::android::hardware::joinRpcThreadpool(); }
media/module/codecserviceregistrant/fuzzer/codecServiceRegistrant_fuzzer.cpp +6 −3 Original line number Diff line number Diff line Loading @@ -13,6 +13,9 @@ * See the License for the specific language governing permissions and * limitations under the License. */ #include <codecserviceregistrant/CodecServiceRegistrant.h> #include "../CodecServiceRegistrant.cpp" #include "fuzzer/FuzzedDataProvider.h" #include <C2Config.h> Loading Loading @@ -166,9 +169,9 @@ void CodecServiceRegistrantFuzzer::invokeH2C2ComponentStore() { void CodecServiceRegistrantFuzzer::process(const uint8_t *data, size_t size) { mFDP = new FuzzedDataProvider(data, size); invokeH2C2ComponentStore(); /** RegisterCodecServices is called here to improve code coverage */ /** as currently it is not called by codecServiceRegistrant */ RegisterCodecServices(); /** RegisterCodecServicesWithExistingThreadpool() is called here to improve * code coverage as currently it is not called in codecServiceRegistrant.cpp */ RegisterCodecServicesWithExistingThreadpool(); delete mFDP; } Loading
media/libmedia/include/media/CodecServiceRegistrant.h→media/module/codecserviceregistrant/include/codecserviceregistrant/CodecServiceRegistrant.h +7 −0 Original line number Diff line number Diff line Loading @@ -18,6 +18,13 @@ #define CODEC_SERVICE_REGISTRANT_H_ /** * This function starts the threadpool, calls the registration logic * encapsulated in RegisterCodecServicesWithExistingThreadpool(), and * then stops the threadpool. */ extern "C" void RegisterCodecServices(); typedef void (*RegisterCodecServicesFunc)(); #endif // CODEC_SERVICE_REGISTRANT_H_