diff options
-rw-r--r-- | Alc/alc.cpp | 15 | ||||
-rw-r--r-- | Alc/backends/base.h | 1 | ||||
-rw-r--r-- | Alc/backends/loopback.cpp | 79 | ||||
-rw-r--r-- | Alc/backends/loopback.h | 20 | ||||
-rw-r--r-- | CMakeLists.txt | 1 |
5 files changed, 59 insertions, 57 deletions
diff --git a/Alc/alc.cpp b/Alc/alc.cpp index 04300d8a..0be0e575 100644 --- a/Alc/alc.cpp +++ b/Alc/alc.cpp @@ -58,6 +58,7 @@ #include "backends/base.h" #include "backends/null.h" +#include "backends/loopback.h" namespace { @@ -1127,10 +1128,7 @@ static void alc_initconfig(void) } BackendListSize = n; - { - ALCbackendFactory *factory = ALCloopbackFactory_getFactory(); - V0(factory,init)(); - } + LoopbackBackendFactory::getFactory().init(); if(!PlaybackBackend.name) WARN("No playback backend available!\n"); @@ -1217,10 +1215,7 @@ static void alc_deinit(void) for(i = 0;i < BackendListSize;i++) BackendList[i].getFactory().deinit(); - { - ALCbackendFactory *factory = ALCloopbackFactory_getFactory(); - V0(factory,deinit)(); - } + LoopbackBackendFactory::getFactory().deinit(); alc_deinit_safe(); } @@ -4452,8 +4447,8 @@ ALC_API ALCdevice* ALC_APIENTRY alcLoopbackOpenDeviceSOFT(const ALCchar *deviceN device->NumStereoSources = 1; device->NumMonoSources = device->SourcesMax - device->NumStereoSources; - ALCbackendFactory *factory = ALCloopbackFactory_getFactory(); - device->Backend = V(factory,createBackend)(device, ALCbackend_Loopback); + device->Backend = LoopbackBackendFactory::getFactory().createBackend( + device, ALCbackend_Loopback); if(!device->Backend) { al_free(device); diff --git a/Alc/backends/base.h b/Alc/backends/base.h index 5f7deb62..b87abb3f 100644 --- a/Alc/backends/base.h +++ b/Alc/backends/base.h @@ -155,7 +155,6 @@ ALCbackendFactory *ALCportBackendFactory_getFactory(void); ALCbackendFactory *ALCopenslBackendFactory_getFactory(void); ALCbackendFactory *ALCwaveBackendFactory_getFactory(void); ALCbackendFactory *ALCsdl2BackendFactory_getFactory(void); -ALCbackendFactory *ALCloopbackFactory_getFactory(void); struct BackendFactory { diff --git a/Alc/backends/loopback.cpp b/Alc/backends/loopback.cpp index 2eb4c935..85c0a26e 100644 --- a/Alc/backends/loopback.cpp +++ b/Alc/backends/loopback.cpp @@ -20,45 +20,47 @@ #include "config.h" +#include "backends/loopback.h" + #include "alMain.h" #include "alu.h" -#include "backends/base.h" +namespace { struct ALCloopback final : public ALCbackend { }; -static void ALCloopback_Construct(ALCloopback *self, ALCdevice *device); -static void ALCloopback_Destruct(ALCloopback *self); -static ALCenum ALCloopback_open(ALCloopback *self, const ALCchar *name); -static ALCboolean ALCloopback_reset(ALCloopback *self); -static ALCboolean ALCloopback_start(ALCloopback *self); -static void ALCloopback_stop(ALCloopback *self); -static DECLARE_FORWARD2(ALCloopback, ALCbackend, ALCenum, captureSamples, void*, ALCuint) -static DECLARE_FORWARD(ALCloopback, ALCbackend, ALCuint, availableSamples) -static DECLARE_FORWARD(ALCloopback, ALCbackend, ClockLatency, getClockLatency) -static DECLARE_FORWARD(ALCloopback, ALCbackend, void, lock) -static DECLARE_FORWARD(ALCloopback, ALCbackend, void, unlock) +void ALCloopback_Construct(ALCloopback *self, ALCdevice *device); +void ALCloopback_Destruct(ALCloopback *self); +ALCenum ALCloopback_open(ALCloopback *self, const ALCchar *name); +ALCboolean ALCloopback_reset(ALCloopback *self); +ALCboolean ALCloopback_start(ALCloopback *self); +void ALCloopback_stop(ALCloopback *self); +DECLARE_FORWARD2(ALCloopback, ALCbackend, ALCenum, captureSamples, void*, ALCuint) +DECLARE_FORWARD(ALCloopback, ALCbackend, ALCuint, availableSamples) +DECLARE_FORWARD(ALCloopback, ALCbackend, ClockLatency, getClockLatency) +DECLARE_FORWARD(ALCloopback, ALCbackend, void, lock) +DECLARE_FORWARD(ALCloopback, ALCbackend, void, unlock) DECLARE_DEFAULT_ALLOCATORS(ALCloopback) DEFINE_ALCBACKEND_VTABLE(ALCloopback); -static void ALCloopback_Construct(ALCloopback *self, ALCdevice *device) +void ALCloopback_Construct(ALCloopback *self, ALCdevice *device) { new (self) ALCloopback{}; ALCbackend_Construct(STATIC_CAST(ALCbackend, self), device); SET_VTABLE2(ALCloopback, ALCbackend, self); } -static void ALCloopback_Destruct(ALCloopback *self) +void ALCloopback_Destruct(ALCloopback *self) { ALCbackend_Destruct(STATIC_CAST(ALCbackend, self)); self->~ALCloopback(); } -static ALCenum ALCloopback_open(ALCloopback *self, const ALCchar *name) +ALCenum ALCloopback_open(ALCloopback *self, const ALCchar *name) { ALCdevice *device = STATIC_CAST(ALCbackend, self)->mDevice; @@ -67,70 +69,55 @@ static ALCenum ALCloopback_open(ALCloopback *self, const ALCchar *name) return ALC_NO_ERROR; } -static ALCboolean ALCloopback_reset(ALCloopback *self) +ALCboolean ALCloopback_reset(ALCloopback *self) { SetDefaultWFXChannelOrder(STATIC_CAST(ALCbackend, self)->mDevice); return ALC_TRUE; } -static ALCboolean ALCloopback_start(ALCloopback* UNUSED(self)) +ALCboolean ALCloopback_start(ALCloopback* UNUSED(self)) { return ALC_TRUE; } -static void ALCloopback_stop(ALCloopback* UNUSED(self)) +void ALCloopback_stop(ALCloopback* UNUSED(self)) { } - -struct ALCloopbackFactory final : public ALCbackendFactory { - ALCloopbackFactory() noexcept; -}; - -ALCbackendFactory *ALCloopbackFactory_getFactory(void); -static ALCboolean ALCloopbackFactory_init(ALCloopbackFactory *self); -static DECLARE_FORWARD(ALCloopbackFactory, ALCbackendFactory, void, deinit) -static ALCboolean ALCloopbackFactory_querySupport(ALCloopbackFactory *self, ALCbackend_Type type); -static void ALCloopbackFactory_probe(ALCloopbackFactory *self, enum DevProbe type, std::string *outnames); -static ALCbackend* ALCloopbackFactory_createBackend(ALCloopbackFactory *self, ALCdevice *device, ALCbackend_Type type); -DEFINE_ALCBACKENDFACTORY_VTABLE(ALCloopbackFactory); - -ALCloopbackFactory::ALCloopbackFactory() noexcept - : ALCbackendFactory{GET_VTABLE2(ALCloopbackFactory, ALCbackendFactory)} -{ } +} // namespace -static ALCboolean ALCloopbackFactory_init(ALCloopbackFactory* UNUSED(self)) +bool LoopbackBackendFactory::init() { - return ALC_TRUE; + return true; } -static ALCboolean ALCloopbackFactory_querySupport(ALCloopbackFactory* UNUSED(self), ALCbackend_Type type) +bool LoopbackBackendFactory::querySupport(ALCbackend_Type type) { if(type == ALCbackend_Loopback) - return ALC_TRUE; - return ALC_FALSE; + return true; + return false; } -static void ALCloopbackFactory_probe(ALCloopbackFactory* UNUSED(self), enum DevProbe UNUSED(type), std::string* UNUSED(outnames)) +void LoopbackBackendFactory::probe(enum DevProbe, std::string*) { } -static ALCbackend* ALCloopbackFactory_createBackend(ALCloopbackFactory* UNUSED(self), ALCdevice *device, ALCbackend_Type type) +ALCbackend *LoopbackBackendFactory::createBackend(ALCdevice *device, ALCbackend_Type type) { if(type == ALCbackend_Loopback) { ALCloopback *backend; NEW_OBJ(backend, ALCloopback)(device); - if(!backend) return NULL; + if(!backend) return nullptr; return STATIC_CAST(ALCbackend, backend); } - return NULL; + return nullptr; } -ALCbackendFactory *ALCloopbackFactory_getFactory(void) +BackendFactory &LoopbackBackendFactory::getFactory() { - static ALCloopbackFactory factory{}; - return STATIC_CAST(ALCbackendFactory, &factory); + static LoopbackBackendFactory factory{}; + return factory; } diff --git a/Alc/backends/loopback.h b/Alc/backends/loopback.h new file mode 100644 index 00000000..68f33a5c --- /dev/null +++ b/Alc/backends/loopback.h @@ -0,0 +1,20 @@ +#ifndef BACKENDS_LOOPBACK_H +#define BACKENDS_LOOPBACK_H + +#include "backends/base.h" + +struct LoopbackBackendFactory 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_LOOPBACK_H */ diff --git a/CMakeLists.txt b/CMakeLists.txt index d3718332..06f280f1 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -991,6 +991,7 @@ SET(ALC_OBJS ${ALC_OBJS} Alc/backends/base.h # Default backends, always available Alc/backends/loopback.cpp + Alc/backends/loopback.h Alc/backends/null.cpp Alc/backends/null.h ) |