From b7eeae5027e11a398f9e94223badaec15a732961 Mon Sep 17 00:00:00 2001 From: Paul Adenot Date: Thu, 22 Sep 2022 00:22:03 +0000 Subject: [PATCH] Bug 1791839 - Remove OpenSLESProvider.cpp, update cubeb vendoring manifest. r=kinetik Differential Revision: https://phabricator.services.mozilla.com/D157856 --- dom/media/systemservices/OpenSLESProvider.cpp | 174 ------------------ dom/media/systemservices/OpenSLESProvider.h | 63 ------- dom/media/systemservices/moz.build | 7 - media/libcubeb/moz.yaml | 2 - 4 files changed, 246 deletions(-) delete mode 100644 dom/media/systemservices/OpenSLESProvider.cpp delete mode 100644 dom/media/systemservices/OpenSLESProvider.h diff --git a/dom/media/systemservices/OpenSLESProvider.cpp b/dom/media/systemservices/OpenSLESProvider.cpp deleted file mode 100644 index 339fb44f86a4..000000000000 --- a/dom/media/systemservices/OpenSLESProvider.cpp +++ /dev/null @@ -1,174 +0,0 @@ -/* -*- Mode: C++; tab-width: 50; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ -/* This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this - * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ - -#include "OpenSLESProvider.h" -#include "mozilla/IntegerPrintfMacros.h" -#include "mozilla/Logging.h" -#include "nsDebug.h" - -#include -#include -#include - -// MOZ_LOG=OpenSLESProvider:5 -#undef LOG -#undef LOG_ENABLED -mozilla::LazyLogModule gOpenSLESProviderLog("OpenSLESProvider"); -#define LOG(args) MOZ_LOG(gOpenSLESProviderLog, mozilla::LogLevel::Debug, args) -#define LOG_ENABLED() \ - MOZ_LOG_TEST(gOpenSLESProviderLog, mozilla::LogLevel::Debug) - -namespace mozilla { - -OpenSLESProvider::OpenSLESProvider() - : mLock("OpenSLESProvider.mLock"), - mSLEngine(nullptr), - mSLEngineUsers(0), - mIsRealized(false), - mOpenSLESLib(nullptr) { - LOG(("OpenSLESProvider being initialized")); -} - -OpenSLESProvider::~OpenSLESProvider() { - if (mOpenSLESLib) { - LOG(("OpenSLES Engine was not properly Destroyed")); - (void)dlclose(mOpenSLESLib); - } -} - -/* static */ -OpenSLESProvider& OpenSLESProvider::getInstance() { - // This doesn't need a Mutex in C++11 or GCC 4.3+, see N2660 and - // https://gcc.gnu.org/projects/cxx0x.html - static OpenSLESProvider instance; - return instance; -} - -/* static */ -SLresult OpenSLESProvider::Get(SLObjectItf* aObjectm, SLuint32 aOptionCount, - const SLEngineOption* aOptions) { - OpenSLESProvider& provider = OpenSLESProvider::getInstance(); - return provider.GetEngine(aObjectm, aOptionCount, aOptions); -} - -SLresult OpenSLESProvider::GetEngine(SLObjectItf* aObjectm, - SLuint32 aOptionCount, - const SLEngineOption* aOptions) { - MutexAutoLock lock(mLock); - LOG(("Getting OpenSLES engine")); - // Bug 1042051: Validate options are the same - if (mSLEngine != nullptr) { - *aObjectm = mSLEngine; - mSLEngineUsers++; - LOG(("Returning existing engine, %d users", mSLEngineUsers)); - return SL_RESULT_SUCCESS; - } else { - SLresult res = ConstructEngine(aObjectm, aOptionCount, aOptions); - if (res == SL_RESULT_SUCCESS) { - // Bug 1042051: Store engine options - mSLEngine = *aObjectm; - mSLEngineUsers++; - LOG(("Returning new engine")); - } else { - LOG(("Error getting engine: %lu", static_cast(res))); - } - return res; - } -} - -SLresult OpenSLESProvider::ConstructEngine(SLObjectItf* aObjectm, - SLuint32 aOptionCount, - const SLEngineOption* aOptions) { - mLock.AssertCurrentThreadOwns(); - - if (!mOpenSLESLib) { - mOpenSLESLib = dlopen("libOpenSLES.so", RTLD_LAZY); - if (!mOpenSLESLib) { - LOG(("Failed to dlopen OpenSLES library")); - return SL_RESULT_MEMORY_FAILURE; - } - } - - typedef SLresult (*slCreateEngine_t)(SLObjectItf*, SLuint32, - const SLEngineOption*, SLuint32, - const SLInterfaceID*, const SLboolean*); - - slCreateEngine_t f_slCreateEngine = - (slCreateEngine_t)dlsym(mOpenSLESLib, "slCreateEngine"); - int result = - f_slCreateEngine(aObjectm, aOptionCount, aOptions, 0, NULL, NULL); - return result; -} - -/* static */ -void OpenSLESProvider::Destroy(SLObjectItf* aObjectm) { - OpenSLESProvider& provider = OpenSLESProvider::getInstance(); - provider.DestroyEngine(aObjectm); -} - -void OpenSLESProvider::DestroyEngine(SLObjectItf* aObjectm) { - MutexAutoLock lock(mLock); - NS_ASSERTION(mOpenSLESLib, "OpenSLES destroy called but library is not open"); - - mSLEngineUsers--; - LOG(("Freeing engine, %d users left", mSLEngineUsers)); - if (mSLEngineUsers) { - return; - } - - (*(*aObjectm))->Destroy(*aObjectm); - // This assumes SLObjectItf is a pointer, but given the previous line, - // that's a given. - *aObjectm = nullptr; - - (void)dlclose(mOpenSLESLib); - mOpenSLESLib = nullptr; - mIsRealized = false; -} - -/* static */ -SLresult OpenSLESProvider::Realize(SLObjectItf aObjectm) { - OpenSLESProvider& provider = OpenSLESProvider::getInstance(); - return provider.RealizeEngine(aObjectm); -} - -SLresult OpenSLESProvider::RealizeEngine(SLObjectItf aObjectm) { - MutexAutoLock lock(mLock); - NS_ASSERTION(mOpenSLESLib, "OpenSLES realize called but library is not open"); - NS_ASSERTION(aObjectm != nullptr, - "OpenSLES realize engine with empty ObjectItf"); - - if (mIsRealized) { - LOG(("Not realizing already realized engine")); - return SL_RESULT_SUCCESS; - } else { - SLresult res = (*aObjectm)->Realize(aObjectm, SL_BOOLEAN_FALSE); - if (res != SL_RESULT_SUCCESS) { - LOG(("Error realizing OpenSLES engine: %lu", - static_cast(res))); - } else { - LOG(("Realized OpenSLES engine")); - mIsRealized = true; - } - return res; - } -} - -} // namespace mozilla - -extern "C" { -SLresult mozilla_get_sles_engine(SLObjectItf* aObjectm, SLuint32 aOptionCount, - const SLEngineOption* aOptions) { - return mozilla::OpenSLESProvider::Get(aObjectm, aOptionCount, aOptions); -} - -void mozilla_destroy_sles_engine(SLObjectItf* aObjectm) { - mozilla::OpenSLESProvider::Destroy(aObjectm); -} - -SLresult mozilla_realize_sles_engine(SLObjectItf aObjectm) { - return mozilla::OpenSLESProvider::Realize(aObjectm); -} -} diff --git a/dom/media/systemservices/OpenSLESProvider.h b/dom/media/systemservices/OpenSLESProvider.h deleted file mode 100644 index 525ee79abc83..000000000000 --- a/dom/media/systemservices/OpenSLESProvider.h +++ /dev/null @@ -1,63 +0,0 @@ -/* -*- Mode: C++; tab-width: 50; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ -/* This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this - * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ - -#ifndef _OPENSLESPROVIDER_H_ -#define _OPENSLESPROVIDER_H_ - -#include -#include - -#ifdef __cplusplus -extern "C" { -#endif -extern MOZ_EXPORT SLresult -mozilla_get_sles_engine(SLObjectItf* aObjectm, SLuint32 aOptionCount, - const SLEngineOption* aOptions); -extern MOZ_EXPORT void mozilla_destroy_sles_engine(SLObjectItf* aObjectm); -/* Realize is always in synchronous mode. */ -extern MOZ_EXPORT SLresult mozilla_realize_sles_engine(SLObjectItf aObjectm); -#ifdef __cplusplus -} -#endif - -#ifdef __cplusplus -# include "mozilla/Mutex.h" - -extern mozilla::LazyLogModule gOpenSLESProviderLog; - -namespace mozilla { - -class OpenSLESProvider { - public: - static SLresult Get(SLObjectItf* aObjectm, SLuint32 aOptionCount, - const SLEngineOption* aOptions); - static void Destroy(SLObjectItf* aObjectm); - static SLresult Realize(SLObjectItf aObjectm); - - private: - OpenSLESProvider(); - ~OpenSLESProvider(); - OpenSLESProvider(OpenSLESProvider const&); // NO IMPLEMENTATION - void operator=(OpenSLESProvider const&); // NO IMPLEMENTATION - static OpenSLESProvider& getInstance(); - SLresult GetEngine(SLObjectItf* aObjectm, SLuint32 aOptionCount, - const SLEngineOption* aOptions); - SLresult ConstructEngine(SLObjectItf* aObjectm, SLuint32 aOptionCount, - const SLEngineOption* aOptions); - SLresult RealizeEngine(SLObjectItf aObjectm); - void DestroyEngine(SLObjectItf* aObjectm); - - // Protect all our internal variables - mozilla::Mutex mLock MOZ_UNANNOTATED; - SLObjectItf mSLEngine; - int mSLEngineUsers; - bool mIsRealized; - void* mOpenSLESLib; -}; - -} // namespace mozilla -#endif // cplusplus - -#endif /* _OPENSLESPROVIDER_H_ */ diff --git a/dom/media/systemservices/moz.build b/dom/media/systemservices/moz.build index 9a0c1dab2b9f..ca682272b836 100644 --- a/dom/media/systemservices/moz.build +++ b/dom/media/systemservices/moz.build @@ -56,13 +56,6 @@ if CONFIG["MOZ_WEBRTC"]: if CONFIG["OS_TARGET"] == "Android": DEFINES["WEBRTC_ANDROID"] = True - -if CONFIG["OS_TARGET"] == "Android": - EXPORTS += ["OpenSLESProvider.h"] - UNIFIED_SOURCES += [ - "OpenSLESProvider.cpp", - ] - if CONFIG["MOZ_WIDGET_TOOLKIT"] == "cocoa": UNIFIED_SOURCES += ["OSXRunLoopSingleton.cpp"] EXPORTS += ["OSXRunLoopSingleton.h"] diff --git a/media/libcubeb/moz.yaml b/media/libcubeb/moz.yaml index 9e8b63b53955..5f6f47950309 100644 --- a/media/libcubeb/moz.yaml +++ b/media/libcubeb/moz.yaml @@ -29,7 +29,6 @@ vendoring: - docs - scan-build-install.sh - src/cubeb-jni-instances.h - - src/cubeb-sles.h - src/cubeb_assert.h - src/cubeb_audiotrack.c - src/cubeb_kai.c @@ -43,7 +42,6 @@ vendoring: - include/cubeb_export.h - include/moz.build - src/cubeb-jni-instances.h - - src/cubeb-sles.h - src/cubeb_assert.h - src/cubeb_osx_run_loop.c - src/moz.build