diff options
author | Chris Robinson <[email protected]> | 2018-11-15 22:36:49 -0800 |
---|---|---|
committer | Chris Robinson <[email protected]> | 2018-11-15 22:36:49 -0800 |
commit | 7884cec02b62605cbc046f2311bf3f3b35e20777 (patch) | |
tree | 6665addab5a2de4d7e617aa13abceef80c4f750c /Alc | |
parent | 271cfcf8e31d06dca259a436251b70f5ffa882be (diff) |
Convert the SndIO backend factory
Diffstat (limited to 'Alc')
-rw-r--r-- | Alc/alc.cpp | 7 | ||||
-rw-r--r-- | Alc/backends/sndio.cpp | 46 | ||||
-rw-r--r-- | Alc/backends/sndio.h | 20 |
3 files changed, 37 insertions, 36 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 */ |