aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorChris Robinson <[email protected]>2018-11-15 21:42:17 -0800
committerChris Robinson <[email protected]>2018-11-15 21:42:17 -0800
commitcc113ce6aba8970cb9c111695c71400b2b8d39c3 (patch)
treeedda0c854de39fafa2612878f4025654e25d4de0
parent9d43b548cc982d6ac90ccad82990f96622e74308 (diff)
Convert the OpenSL backend factory
-rw-r--r--Alc/alc.cpp6
-rw-r--r--Alc/backends/opensl.cpp48
-rw-r--r--Alc/backends/opensl.h20
-rw-r--r--CMakeLists.txt2
4 files changed, 40 insertions, 36 deletions
diff --git a/Alc/alc.cpp b/Alc/alc.cpp
index 0e61385a..c27dd2a0 100644
--- a/Alc/alc.cpp
+++ b/Alc/alc.cpp
@@ -71,6 +71,9 @@
#ifdef HAVE_COREAUDIO
#include "backends/coreaudio.h"
#endif
+#ifdef HAVE_OPENSL
+#include "backends/opensl.h"
+#endif
namespace {
@@ -96,6 +99,9 @@ struct BackendInfo BackendList[] = {
#ifdef HAVE_COREAUDIO
{ "core", CoreAudioBackendFactory::getFactory },
#endif
+#ifdef HAVE_OPENSL
+ { "opensl", OSLBackendFactory::getFactory },
+#endif
#if 0
{ "jack", ALCjackBackendFactory_getFactory },
{ "pulse", ALCpulseBackendFactory_getFactory },
diff --git a/Alc/backends/opensl.cpp b/Alc/backends/opensl.cpp
index 689c02af..e8a575c8 100644
--- a/Alc/backends/opensl.cpp
+++ b/Alc/backends/opensl.cpp
@@ -21,6 +21,8 @@
#include "config.h"
+#include "backends/opensl.h"
+
#include <stdlib.h>
#include <jni.h>
@@ -30,8 +32,6 @@
#include "threads.h"
#include "compat.h"
-#include "backends/base.h"
-
#include <SLES/OpenSLES.h>
#include <SLES/OpenSLES_Android.h>
#include <SLES/OpenSLES_AndroidConfiguration.h>
@@ -1011,27 +1011,12 @@ static ALCuint ALCopenslCapture_availableSamples(ALCopenslCapture *self)
}
-struct ALCopenslBackendFactory final : public ALCbackendFactory {
- ALCopenslBackendFactory() noexcept;
-};
+bool OSLBackendFactory::init() { return true; }
-static ALCboolean ALCopenslBackendFactory_init(ALCopenslBackendFactory* UNUSED(self))
-{
- return ALC_TRUE;
-}
+bool OSLBackendFactory::querySupport(ALCbackend_Type type)
+{ return (type == ALCbackend_Playback || type == ALCbackend_Capture); }
-static void ALCopenslBackendFactory_deinit(ALCopenslBackendFactory* UNUSED(self))
-{
-}
-
-static ALCboolean ALCopenslBackendFactory_querySupport(ALCopenslBackendFactory* UNUSED(self), ALCbackend_Type type)
-{
- if(type == ALCbackend_Playback || type == ALCbackend_Capture)
- return ALC_TRUE;
- return ALC_FALSE;
-}
-
-static void ALCopenslBackendFactory_probe(ALCopenslBackendFactory* UNUSED(self), enum DevProbe type, std::string *outnames)
+void OSLBackendFactory::probe(enum DevProbe type, std::string *outnames)
{
switch(type)
{
@@ -1043,35 +1028,28 @@ static void ALCopenslBackendFactory_probe(ALCopenslBackendFactory* UNUSED(self),
}
}
-static ALCbackend* ALCopenslBackendFactory_createBackend(ALCopenslBackendFactory* UNUSED(self), ALCdevice *device, ALCbackend_Type type)
+ALCbackend *OSLBackendFactory::createBackend(ALCdevice *device, ALCbackend_Type type)
{
if(type == ALCbackend_Playback)
{
ALCopenslPlayback *backend;
NEW_OBJ(backend, ALCopenslPlayback)(device);
- if(!backend) return NULL;
+ if(!backend) return nullptr;
return STATIC_CAST(ALCbackend, backend);
}
if(type == ALCbackend_Capture)
{
ALCopenslCapture *backend;
NEW_OBJ(backend, ALCopenslCapture)(device);
- if(!backend) return NULL;
+ if(!backend) return nullptr;
return STATIC_CAST(ALCbackend, backend);
}
- return NULL;
+ return nullptr;
}
-DEFINE_ALCBACKENDFACTORY_VTABLE(ALCopenslBackendFactory);
-
-
-ALCopenslBackendFactory::ALCopenslBackendFactory() noexcept
- : ALCbackendFactory{GET_VTABLE2(ALCopenslBackendFactory, ALCbackendFactory)}
-{ }
-
-ALCbackendFactory *ALCopenslBackendFactory_getFactory(void)
+BackendFactory &OSLBackendFactory::getFactory()
{
- static ALCopenslBackendFactory factory{};
- return STATIC_CAST(ALCbackendFactory, &factory);
+ static OSLBackendFactory factory{};
+ return factory;
}
diff --git a/Alc/backends/opensl.h b/Alc/backends/opensl.h
new file mode 100644
index 00000000..799d568f
--- /dev/null
+++ b/Alc/backends/opensl.h
@@ -0,0 +1,20 @@
+#ifndef BACKENDS_OSL_H
+#define BACKENDS_OSL_H
+
+#include "backends/base.h"
+
+struct OSLBackendFactory final : public BackendFactory {
+public:
+ bool init() override;
+ /*void deinit() override;*/
+
+ bool querySupport(ALCbackend_Type type) override;
+
+ void probe(enum DevProbe type, std::string *outnames) override;
+
+ ALCbackend *createBackend(ALCdevice *device, ALCbackend_Type type) override;
+
+ static BackendFactory &getFactory();
+};
+
+#endif /* BACKENDS_OSL_H */
diff --git a/CMakeLists.txt b/CMakeLists.txt
index 66a2dbe5..6942fa46 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -1235,7 +1235,7 @@ IF(HAVE_SLES_OPENSLES_ANDROID_H)
OPTION(ALSOFT_BACKEND_OPENSL "Enable OpenSL backend" ON)
IF(ALSOFT_BACKEND_OPENSL)
SET(HAVE_OPENSL 1)
- SET(ALC_OBJS ${ALC_OBJS} Alc/backends/opensl.cpp)
+ SET(ALC_OBJS ${ALC_OBJS} Alc/backends/opensl.cpp Alc/backends/opensl.h)
SET(BACKENDS "${BACKENDS} OpenSL,")
SET(EXTRA_LIBS OpenSLES ${EXTRA_LIBS})
ENDIF()