aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--Alc/alc.cpp7
-rw-r--r--Alc/backends/sndio.cpp46
-rw-r--r--Alc/backends/sndio.h20
-rw-r--r--CMakeLists.txt2
4 files changed, 38 insertions, 37 deletions
diff --git a/Alc/alc.cpp b/Alc/alc.cpp
index 89385888..8a16eb28 100644
--- a/Alc/alc.cpp
+++ b/Alc/alc.cpp
@@ -80,6 +80,9 @@
#ifdef HAVE_SOLARIS
#include "backends/solaris.h"
#endif
+#ifdef HAVE_SNDIO
+#include "backends/sndio.h"
+#endif
#ifdef HAVE_SDL2
#include "backends/sdl2.h"
#endif
@@ -120,9 +123,11 @@ struct BackendInfo BackendList[] = {
#ifdef HAVE_SOLARIS
{ "solaris", SolarisBackendFactory::getFactory },
#endif
+#ifdef HAVE_SNDIO
+ { "sndio", SndIOBackendFactory::getFactory },
+#endif
#if 0
- { "sndio", SndioBackendFactory_getFactory },
{ "oss", ALCossBackendFactory_getFactory },
{ "qsa", ALCqsaBackendFactory_getFactory },
{ "dsound", ALCdsoundBackendFactory_getFactory },
diff --git a/Alc/backends/sndio.cpp b/Alc/backends/sndio.cpp
index f1e678cf..691bdcde 100644
--- a/Alc/backends/sndio.cpp
+++ b/Alc/backends/sndio.cpp
@@ -20,6 +20,8 @@
#include "config.h"
+#include "backends/sndio.h"
+
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
@@ -29,8 +31,6 @@
#include "threads.h"
#include "ringbuffer.h"
-#include "backends/base.h"
-
#include <sndio.h>
@@ -537,43 +537,19 @@ static ALCuint SndioCapture_availableSamples(SndioCapture *self)
}
-struct SndioBackendFactory final : public ALCbackendFactory {
- SndioBackendFactory() noexcept;
-};
-
-ALCbackendFactory *SndioBackendFactory_getFactory(void);
-
-static ALCboolean SndioBackendFactory_init(SndioBackendFactory *self);
-static DECLARE_FORWARD(SndioBackendFactory, ALCbackendFactory, void, deinit)
-static ALCboolean SndioBackendFactory_querySupport(SndioBackendFactory *self, ALCbackend_Type type);
-static void SndioBackendFactory_probe(SndioBackendFactory *self, enum DevProbe type, std::string *outnames);
-static ALCbackend* SndioBackendFactory_createBackend(SndioBackendFactory *self, ALCdevice *device, ALCbackend_Type type);
-DEFINE_ALCBACKENDFACTORY_VTABLE(SndioBackendFactory);
-
-SndioBackendFactory::SndioBackendFactory() noexcept
- : ALCbackendFactory{GET_VTABLE2(SndioBackendFactory, ALCbackendFactory)}
-{ }
-
-ALCbackendFactory *SndioBackendFactory_getFactory(void)
+BackendFactory &SndIOBackendFactory::getFactory()
{
- static SndioBackendFactory factory{};
- return STATIC_CAST(ALCbackendFactory, &factory);
+ static SndIOBackendFactory factory{};
+ return factory;
}
-static ALCboolean SndioBackendFactory_init(SndioBackendFactory* UNUSED(self))
-{
- /* No dynamic loading */
- return ALC_TRUE;
-}
+bool SndIOBackendFactory::init()
+{ return true; }
-static ALCboolean SndioBackendFactory_querySupport(SndioBackendFactory* UNUSED(self), ALCbackend_Type type)
-{
- if(type == ALCbackend_Playback || type == ALCbackend_Capture)
- return ALC_TRUE;
- return ALC_FALSE;
-}
+bool SndIOBackendFactory::querySupport(ALCbackend_Type type)
+{ return (type == ALCbackend_Playback || type == ALCbackend_Capture); }
-static void SndioBackendFactory_probe(SndioBackendFactory* UNUSED(self), enum DevProbe type, std::string *outnames)
+void SndIOBackendFactory::probe(enum DevProbe type, std::string *outnames)
{
switch(type)
{
@@ -585,7 +561,7 @@ static void SndioBackendFactory_probe(SndioBackendFactory* UNUSED(self), enum De
}
}
-static ALCbackend* SndioBackendFactory_createBackend(SndioBackendFactory* UNUSED(self), ALCdevice *device, ALCbackend_Type type)
+ALCbackend *SndIOBackendFactory::createBackend(ALCdevice *device, ALCbackend_Type type)
{
if(type == ALCbackend_Playback)
{
diff --git a/Alc/backends/sndio.h b/Alc/backends/sndio.h
new file mode 100644
index 00000000..38cd2767
--- /dev/null
+++ b/Alc/backends/sndio.h
@@ -0,0 +1,20 @@
+#ifndef BACKENDS_SNDIO_H
+#define BACKENDS_SNDIO_H
+
+#include "backends/base.h"
+
+struct SndIOBackendFactory 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_SNDIO_H */
diff --git a/CMakeLists.txt b/CMakeLists.txt
index 551d30fe..6355752d 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -1056,7 +1056,7 @@ IF(SOUNDIO_FOUND)
IF(ALSOFT_BACKEND_SNDIO)
SET(HAVE_SNDIO 1)
SET(BACKENDS "${BACKENDS} SndIO (linked),")
- SET(ALC_OBJS ${ALC_OBJS} Alc/backends/sndio.cpp)
+ SET(ALC_OBJS ${ALC_OBJS} Alc/backends/sndio.cpp Alc/backends/sndio.h)
SET(EXTRA_LIBS ${SOUNDIO_LIBRARIES} ${EXTRA_LIBS})
SET(INC_PATHS ${INC_PATHS} ${SOUNDIO_INCLUDE_DIRS})
ENDIF()