aboutsummaryrefslogtreecommitdiffstats
path: root/Alc
diff options
context:
space:
mode:
authorChris Robinson <[email protected]>2018-11-15 22:15:10 -0800
committerChris Robinson <[email protected]>2018-11-15 22:15:10 -0800
commitd73d01548d992f6f683f6685ff8f4767e8843ad9 (patch)
treedb48d897927fd2d48de1b3c163593561d369c6f1 /Alc
parent2a839e5762fa6bd4b0399e2f588ce0805e92b618 (diff)
Convert the SDL2 backend factory
Diffstat (limited to 'Alc')
-rw-r--r--Alc/alc.cpp8
-rw-r--r--Alc/backends/sdl2.cpp47
-rw-r--r--Alc/backends/sdl2.h20
3 files changed, 38 insertions, 37 deletions
diff --git a/Alc/alc.cpp b/Alc/alc.cpp
index d83b545f..63f60e80 100644
--- a/Alc/alc.cpp
+++ b/Alc/alc.cpp
@@ -77,6 +77,9 @@
#ifdef HAVE_OPENSL
#include "backends/opensl.h"
#endif
+#ifdef HAVE_SDL2
+#include "backends/sdl2.h"
+#endif
#ifdef HAVE_WAVE
#include "backends/wave.h"
#endif
@@ -121,9 +124,10 @@ struct BackendInfo BackendList[] = {
{ "dsound", ALCdsoundBackendFactory_getFactory },
{ "winmm", ALCwinmmBackendFactory_getFactory },
{ "port", ALCportBackendFactory_getFactory },
- { "opensl", ALCopenslBackendFactory_getFactory },
- { "sdl2", ALCsdl2BackendFactory_getFactory },
#endif /* 0 */
+#ifdef HAVE_SDL2
+ { "sdl2", SDL2BackendFactory::getFactory },
+#endif
{ "null", NullBackendFactory::getFactory },
#ifdef HAVE_WAVE
diff --git a/Alc/backends/sdl2.cpp b/Alc/backends/sdl2.cpp
index c918b57c..e1234c1b 100644
--- a/Alc/backends/sdl2.cpp
+++ b/Alc/backends/sdl2.cpp
@@ -20,6 +20,8 @@
#include "config.h"
+#include "backends/sdl2.h"
+
#include <stdlib.h>
#include <SDL2/SDL.h>
@@ -30,8 +32,6 @@
#include "threads.h"
#include "compat.h"
-#include "backends/base.h"
-
#ifdef _WIN32
#define DEVNAME_PREFIX "OpenAL Soft on "
@@ -214,51 +214,28 @@ static void ALCsdl2Backend_unlock(ALCsdl2Backend *self)
}
-struct ALCsdl2BackendFactory final : public ALCbackendFactory {
- ALCsdl2BackendFactory() noexcept;
-};
-
-ALCbackendFactory *ALCsdl2BackendFactory_getFactory(void);
-
-static ALCboolean ALCsdl2BackendFactory_init(ALCsdl2BackendFactory *self);
-static void ALCsdl2BackendFactory_deinit(ALCsdl2BackendFactory *self);
-static ALCboolean ALCsdl2BackendFactory_querySupport(ALCsdl2BackendFactory *self, ALCbackend_Type type);
-static void ALCsdl2BackendFactory_probe(ALCsdl2BackendFactory *self, enum DevProbe type, std::string *outnames);
-static ALCbackend* ALCsdl2BackendFactory_createBackend(ALCsdl2BackendFactory *self, ALCdevice *device, ALCbackend_Type type);
-DEFINE_ALCBACKENDFACTORY_VTABLE(ALCsdl2BackendFactory);
-
-
-ALCsdl2BackendFactory::ALCsdl2BackendFactory() noexcept
- : ALCbackendFactory{GET_VTABLE2(ALCsdl2BackendFactory, ALCbackendFactory)}
-{ }
-
-ALCbackendFactory *ALCsdl2BackendFactory_getFactory(void)
+BackendFactory &SDL2BackendFactory::getFactory()
{
- static ALCsdl2BackendFactory factory{};
- return STATIC_CAST(ALCbackendFactory, &factory);
+ static SDL2BackendFactory factory{};
+ return factory;
}
-
-static ALCboolean ALCsdl2BackendFactory_init(ALCsdl2BackendFactory* UNUSED(self))
+bool SDL2BackendFactory::init()
{
- if(SDL_InitSubSystem(SDL_INIT_AUDIO) == 0)
- return AL_TRUE;
- return ALC_FALSE;
+ return (SDL_InitSubSystem(SDL_INIT_AUDIO) == 0);
}
-static void ALCsdl2BackendFactory_deinit(ALCsdl2BackendFactory* UNUSED(self))
+void SDL2BackendFactory::deinit()
{
SDL_QuitSubSystem(SDL_INIT_AUDIO);
}
-static ALCboolean ALCsdl2BackendFactory_querySupport(ALCsdl2BackendFactory* UNUSED(self), ALCbackend_Type type)
+bool SDL2BackendFactory::querySupport(ALCbackend_Type type)
{
- if(type == ALCbackend_Playback)
- return ALC_TRUE;
- return ALC_FALSE;
+ return (type == ALCbackend_Playback);
}
-static void ALCsdl2BackendFactory_probe(ALCsdl2BackendFactory* UNUSED(self), enum DevProbe type, std::string *outnames)
+void SDL2BackendFactory::probe(enum DevProbe type, std::string *outnames)
{
if(type != ALL_DEVICE_PROBE)
return;
@@ -276,7 +253,7 @@ static void ALCsdl2BackendFactory_probe(ALCsdl2BackendFactory* UNUSED(self), enu
}
}
-static ALCbackend* ALCsdl2BackendFactory_createBackend(ALCsdl2BackendFactory* UNUSED(self), ALCdevice *device, ALCbackend_Type type)
+ALCbackend *SDL2BackendFactory::createBackend(ALCdevice *device, ALCbackend_Type type)
{
if(type == ALCbackend_Playback)
{
diff --git a/Alc/backends/sdl2.h b/Alc/backends/sdl2.h
new file mode 100644
index 00000000..7f383447
--- /dev/null
+++ b/Alc/backends/sdl2.h
@@ -0,0 +1,20 @@
+#ifndef BACKENDS_SDL2_H
+#define BACKENDS_SDL2_H
+
+#include "backends/base.h"
+
+struct SDL2BackendFactory 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_SDL2_H */