Backed out changeset 6289b18d2127 (bug 1015932)
authorCarsten "Tomcat" Book <cbook@mozilla.com>
Mon, 28 Jul 2014 11:51:58 +0200
changeset 196377 027452afde9df86134afa028a556f4d5920f51a0
parent 196376 c03c2e8e2a21e58180c38f9b34c3a7624b446414
child 196378 8b9f3cc69cbf86830c1afed39e91a6b799d0f730
push id1
push userroot
push dateMon, 20 Oct 2014 17:29:22 +0000
bugs1015932
milestone34.0a1
backs out6289b18d21278feece663cd0795119aeeb081576
Backed out changeset 6289b18d2127 (bug 1015932)
content/media/systemservices/OpenSLESProvider.cpp
content/media/systemservices/OpenSLESProvider.h
media/libcubeb/src/cubeb-sles.h
media/libcubeb/src/cubeb_opensl.c
media/webrtc/trunk/webrtc/modules/audio_device/android/opensles_input.cc
media/webrtc/trunk/webrtc/modules/audio_device/android/opensles_output.cc
--- a/content/media/systemservices/OpenSLESProvider.cpp
+++ b/content/media/systemservices/OpenSLESProvider.cpp
@@ -25,17 +25,16 @@ PRLogModuleInfo *gOpenSLESProviderLog;
 #endif
 
 namespace mozilla {
 
 OpenSLESProvider::OpenSLESProvider()
   : mLock("OpenSLESProvider.mLock"),
     mSLEngine(nullptr),
     mSLEngineUsers(0),
-    mIsRealized(false),
     mOpenSLESLib(nullptr)
 {
 #if defined(PR_LOGGING)
   if (!gOpenSLESProviderLog)
     gOpenSLESProviderLog = PR_NewLogModule("OpenSLESProvider");
   LOG(("OpenSLESProvider being initialized"));
 #endif
 }
@@ -53,27 +52,27 @@ OpenSLESProvider& OpenSLESProvider::getI
 {
   // 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)
+int 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)
+int 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));
@@ -87,19 +86,19 @@ SLresult OpenSLESProvider::GetEngine(SLO
       LOG(("Returning new engine"));
     } else {
       LOG(("Error getting engine: %d", res));
     }
     return res;
   }
 }
 
-SLresult OpenSLESProvider::ConstructEngine(SLObjectItf * aObjectm,
-                                           SLuint32 aOptionCount,
-                                           const SLEngineOption *aOptions)
+int 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;
@@ -139,61 +138,26 @@ void OpenSLESProvider::DestroyEngine(SLO
 
   (*(*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: %d", 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)
+int 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);
+  return mozilla::OpenSLESProvider::Destroy(aObjectm);
 }
 
 }
-
--- a/content/media/systemservices/OpenSLESProvider.h
+++ b/content/media/systemservices/OpenSLESProvider.h
@@ -8,61 +8,55 @@
 
 #include <SLES/OpenSLES.h>
 #include <mozilla/Types.h>
 
 #ifdef __cplusplus
 extern "C" {
 #endif
 extern MOZ_EXPORT
-SLresult mozilla_get_sles_engine(SLObjectItf * aObjectm,
-                                 SLuint32 aOptionCount,
-                                 const SLEngineOption *aOptions);
+int 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 PRLogModuleInfo *gOpenSLESProviderLog;
 
 namespace mozilla {
 
 class OpenSLESProvider {
 public:
-    static SLresult Get(SLObjectItf * aObjectm,
+    static int 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);
+    int GetEngine(SLObjectItf * aObjectm,
+                  SLuint32 aOptionCount,
+                  const SLEngineOption *aOptions);
+    int ConstructEngine(SLObjectItf * aObjectm,
+                        SLuint32 aOptionCount,
+                        const SLEngineOption *aOptions);
     void DestroyEngine(SLObjectItf * aObjectm);
 
     // Protect all our internal variables
     mozilla::Mutex mLock;
     SLObjectItf mSLEngine;
     int mSLEngineUsers;
-    bool mIsRealized;
     void *mOpenSLESLib;
 };
 
 } //namespace
 #endif // cplusplus
 
 #endif /* _OPENSLESPROVIDER_H_ */
--- a/media/libcubeb/src/cubeb-sles.h
+++ b/media/libcubeb/src/cubeb-sles.h
@@ -9,18 +9,12 @@ static SLresult cubeb_get_sles_engine(
   const SLEngineOption    *pEngineOptions,
   SLuint32                numInterfaces,
   const SLInterfaceID     *pInterfaceIds,
   const SLboolean         * pInterfaceRequired) {
   return mozilla_get_sles_engine(pEngine, numOptions, pEngineOptions);
 }
 
 static void cubeb_destroy_sles_engine(SLObjectItf *self) {
-  mozilla_destroy_sles_engine(self);
-}
-
-/* Only synchronous operation is supported, as if the second
-   parameter was FALSE. */
-static SLresult cubeb_realize_sles_engine(SLObjectItf self) {
-  return mozilla_realize_sles_engine(self);
+ mozilla_destroy_sles_engine(self);
 }
 
 #endif
--- a/media/libcubeb/src/cubeb_opensl.c
+++ b/media/libcubeb/src/cubeb_opensl.c
@@ -266,17 +266,17 @@ opensl_init(cubeb ** context, char const
   SLresult res;
   res = cubeb_get_sles_engine(&ctx->engObj, 1, opt, 0, NULL, NULL);
 
   if (res != SL_RESULT_SUCCESS) {
     opensl_destroy(ctx);
     return CUBEB_ERROR;
   }
 
-  res = cubeb_realize_sles_engine(ctx->engObj);
+  res = (*ctx->engObj)->Realize(ctx->engObj, SL_BOOLEAN_FALSE);
   if (res != SL_RESULT_SUCCESS) {
     opensl_destroy(ctx);
     return CUBEB_ERROR;
   }
 
   res = (*ctx->engObj)->GetInterface(ctx->engObj, SL_IID_ENGINE, &ctx->eng);
   if (res != SL_RESULT_SUCCESS) {
     opensl_destroy(ctx);
--- a/media/webrtc/trunk/webrtc/modules/audio_device/android/opensles_input.cc
+++ b/media/webrtc/trunk/webrtc/modules/audio_device/android/opensles_input.cc
@@ -119,23 +119,19 @@ int32_t OpenSlesInput::Init() {
   // Set up OpenSL engine.
 #ifndef MOZILLA_INTERNAL_API
   OPENSL_RETURN_ON_FAILURE(f_slCreateEngine(&sles_engine_, 1, kOption, 0,
                                             NULL, NULL),
                            -1);
 #else
   OPENSL_RETURN_ON_FAILURE(mozilla_get_sles_engine(&sles_engine_, 1, kOption), -1);
 #endif
-#ifndef MOZILLA_INTERNAL_API
   OPENSL_RETURN_ON_FAILURE((*sles_engine_)->Realize(sles_engine_,
                                                     SL_BOOLEAN_FALSE),
                            -1);
-#else
-  OPENSL_RETURN_ON_FAILURE(mozilla_realize_sles_engine(sles_engine_), -1);
-#endif
   OPENSL_RETURN_ON_FAILURE((*sles_engine_)->GetInterface(sles_engine_,
                                                          SL_IID_ENGINE_,
                                                          &sles_engine_itf_),
                            -1);
 
   if (InitSampleRate() != 0) {
     return -1;
   }
--- a/media/webrtc/trunk/webrtc/modules/audio_device/android/opensles_output.cc
+++ b/media/webrtc/trunk/webrtc/modules/audio_device/android/opensles_output.cc
@@ -119,23 +119,19 @@ int32_t OpenSlesOutput::Init() {
   // Set up OpenSl engine.
 #ifndef MOZILLA_INTERNAL_API
   OPENSL_RETURN_ON_FAILURE(f_slCreateEngine(&sles_engine_, 1, kOption, 0,
                                             NULL, NULL),
                            -1);
 #else
   OPENSL_RETURN_ON_FAILURE(mozilla_get_sles_engine(&sles_engine_, 1, kOption), -1);
 #endif
-#ifndef MOZILLA_INTERNAL_API
   OPENSL_RETURN_ON_FAILURE((*sles_engine_)->Realize(sles_engine_,
                                                     SL_BOOLEAN_FALSE),
                            -1);
-#else
-  OPENSL_RETURN_ON_FAILURE(mozilla_realize_sles_engine(sles_engine_), -1);
-#endif
   OPENSL_RETURN_ON_FAILURE((*sles_engine_)->GetInterface(sles_engine_,
                                                          SL_IID_ENGINE_,
                                                          &sles_engine_itf_),
                            -1);
   // Set up OpenSl output mix.
   OPENSL_RETURN_ON_FAILURE(
       (*sles_engine_itf_)->CreateOutputMix(sles_engine_itf_,
                                            &sles_output_mixer_,