diff options
author | Chris Robinson <[email protected]> | 2018-11-15 23:10:06 -0800 |
---|---|---|
committer | Chris Robinson <[email protected]> | 2018-11-15 23:10:06 -0800 |
commit | 5dc1956e18007fe910039487ef5d847bbb72ede0 (patch) | |
tree | a72a5bf20142581d1b99e005c8918a0576d5f157 /Alc/backends | |
parent | c78b42fb4e49a431e8c0b7b7ff8da0102e1aeb5d (diff) |
Convert the QSA backend factory
Diffstat (limited to 'Alc/backends')
-rw-r--r-- | Alc/backends/qsa.cpp | 48 | ||||
-rw-r--r-- | Alc/backends/qsa.h | 20 |
2 files changed, 33 insertions, 35 deletions
diff --git a/Alc/backends/qsa.cpp b/Alc/backends/qsa.cpp index 3a99d71e..da4e6b64 100644 --- a/Alc/backends/qsa.cpp +++ b/Alc/backends/qsa.cpp @@ -20,6 +20,8 @@ #include "config.h" +#include "backends/qsa.h" + #include <stdlib.h> #include <stdio.h> #include <sched.h> @@ -33,8 +35,6 @@ #include "alu.h" #include "threads.h" -#include "backends/base.h" - namespace { @@ -163,8 +163,6 @@ void deviceList(int type, vector_DevMap *devmap) } } -} // namespace - /* Wrappers to use an old-style backend with the new interface. */ struct PlaybackWrapper final : public ALCbackend { @@ -991,29 +989,13 @@ static ALCuint CaptureWrapper_availableSamples(CaptureWrapper *self) return qsa_available_samples(self); } +} // namespace -struct ALCqsaBackendFactory final : public ALCbackendFactory { - ALCqsaBackendFactory() noexcept; -}; - -static ALCboolean ALCqsaBackendFactory_init(ALCqsaBackendFactory* UNUSED(self)); -static void ALCqsaBackendFactory_deinit(ALCqsaBackendFactory* UNUSED(self)); -static ALCboolean ALCqsaBackendFactory_querySupport(ALCqsaBackendFactory* UNUSED(self), ALCbackend_Type type); -static void ALCqsaBackendFactory_probe(ALCqsaBackendFactory* UNUSED(self), enum DevProbe type, std::string *outnames); -static ALCbackend* ALCqsaBackendFactory_createBackend(ALCqsaBackendFactory* UNUSED(self), ALCdevice *device, ALCbackend_Type type); -DEFINE_ALCBACKENDFACTORY_VTABLE(ALCqsaBackendFactory); - -ALCqsaBackendFactory::ALCqsaBackendFactory() noexcept - : ALCbackendFactory{GET_VTABLE2(ALCqsaBackendFactory, ALCbackendFactory)} -{ } +bool QSABackendFactory::init() +{ return true; } -static ALCboolean ALCqsaBackendFactory_init(ALCqsaBackendFactory* UNUSED(self)) -{ - return ALC_TRUE; -} - -static void ALCqsaBackendFactory_deinit(ALCqsaBackendFactory* UNUSED(self)) +void QSABackendFactory::deinit() { #define FREE_NAME(iter) free((iter)->name) VECTOR_FOR_EACH(DevMap, DeviceNameMap, FREE_NAME); @@ -1024,14 +1006,10 @@ static void ALCqsaBackendFactory_deinit(ALCqsaBackendFactory* UNUSED(self)) #undef FREE_NAME } -static ALCboolean ALCqsaBackendFactory_querySupport(ALCqsaBackendFactory* UNUSED(self), ALCbackend_Type type) -{ - if(type == ALCbackend_Playback || type == ALCbackend_Capture) - return ALC_TRUE; - return ALC_FALSE; -} +bool QSABackendFactory::querySupport(ALCbackend_Type type) +{ return (type == ALCbackend_Playback || type == ALCbackend_Capture); } -static void ALCqsaBackendFactory_probe(ALCqsaBackendFactory* UNUSED(self), enum DevProbe type, std::string *outnames) +void QSABackendFactory::probe(enum DevProbe type, std::string *outnames) { switch (type) { @@ -1053,7 +1031,7 @@ static void ALCqsaBackendFactory_probe(ALCqsaBackendFactory* UNUSED(self), enum } } -static ALCbackend* ALCqsaBackendFactory_createBackend(ALCqsaBackendFactory* UNUSED(self), ALCdevice *device, ALCbackend_Type type) +ALCbackend *QSABackendFactory::createBackend(ALCdevice *device, ALCbackend_Type type) { if(type == ALCbackend_Playback) { @@ -1073,8 +1051,8 @@ static ALCbackend* ALCqsaBackendFactory_createBackend(ALCqsaBackendFactory* UNUS return NULL; } -ALCbackendFactory *ALCqsaBackendFactory_getFactory(void) +BackendFactory &QSABackendFactory::getFactory() { - static ALCqsaBackendFactory factory{}; - return STATIC_CAST(ALCbackendFactory, &factory); + static QSABackendFactory factory{}; + return factory; } diff --git a/Alc/backends/qsa.h b/Alc/backends/qsa.h new file mode 100644 index 00000000..c4941392 --- /dev/null +++ b/Alc/backends/qsa.h @@ -0,0 +1,20 @@ +#ifndef BACKENDS_QSA_H +#define BACKENDS_QSA_H + +#include "backends/base.h" + +struct QSABackendFactory 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_QSA_H */ |