diff options
-rw-r--r-- | Alc/backends/null.cpp (renamed from Alc/backends/null.c) | 36 | ||||
-rw-r--r-- | CMakeLists.txt | 2 |
2 files changed, 25 insertions, 13 deletions
diff --git a/Alc/backends/null.c b/Alc/backends/null.cpp index d1c110e8..2e1c6ac9 100644 --- a/Alc/backends/null.c +++ b/Alc/backends/null.cpp @@ -33,17 +33,21 @@ #include "backends/base.h" -typedef struct ALCnullBackend { - DERIVE_FROM_TYPE(ALCbackend); +namespace { +constexpr ALCchar nullDevice[] = "No Output"; + +} // namespace + +struct ALCnullBackend final : public ALCbackend { ATOMIC(int) killNow; althrd_t thread; -} ALCnullBackend; +}; static int ALCnullBackend_mixerProc(void *ptr); static void ALCnullBackend_Construct(ALCnullBackend *self, ALCdevice *device); -static DECLARE_FORWARD(ALCnullBackend, ALCbackend, void, Destruct) +static void ALCnullBackend_Destruct(ALCnullBackend *self); static ALCenum ALCnullBackend_open(ALCnullBackend *self, const ALCchar *name); static ALCboolean ALCnullBackend_reset(ALCnullBackend *self); static ALCboolean ALCnullBackend_start(ALCnullBackend *self); @@ -58,17 +62,21 @@ DECLARE_DEFAULT_ALLOCATORS(ALCnullBackend) DEFINE_ALCBACKEND_VTABLE(ALCnullBackend); -static const ALCchar nullDevice[] = "No Output"; - - static void ALCnullBackend_Construct(ALCnullBackend *self, ALCdevice *device) { + new (self) ALCnullBackend{}; ALCbackend_Construct(STATIC_CAST(ALCbackend, self), device); SET_VTABLE2(ALCnullBackend, ALCbackend, self); ATOMIC_INIT(&self->killNow, AL_TRUE); } +static void ALCnullBackend_Destruct(ALCnullBackend *self) +{ + ALCbackend_Destruct(STATIC_CAST(ALCbackend, self)); + self->~ALCnullBackend(); +} + static int ALCnullBackend_mixerProc(void *ptr) { @@ -161,10 +169,9 @@ static void ALCnullBackend_stop(ALCnullBackend *self) } -typedef struct ALCnullBackendFactory { - DERIVE_FROM_TYPE(ALCbackendFactory); -} ALCnullBackendFactory; -#define ALCNULLBACKENDFACTORY_INITIALIZER { { GET_VTABLE2(ALCnullBackendFactory, ALCbackendFactory) } } +struct ALCnullBackendFactory final : public ALCbackendFactory { + ALCnullBackendFactory() noexcept; +}; ALCbackendFactory *ALCnullBackendFactory_getFactory(void); @@ -175,10 +182,15 @@ static void ALCnullBackendFactory_probe(ALCnullBackendFactory *self, enum DevPro static ALCbackend* ALCnullBackendFactory_createBackend(ALCnullBackendFactory *self, ALCdevice *device, ALCbackend_Type type); DEFINE_ALCBACKENDFACTORY_VTABLE(ALCnullBackendFactory); +ALCnullBackendFactory::ALCnullBackendFactory() noexcept + : ALCbackendFactory{GET_VTABLE2(ALCnullBackendFactory, ALCbackendFactory)} +{ +} + ALCbackendFactory *ALCnullBackendFactory_getFactory(void) { - static ALCnullBackendFactory factory = ALCNULLBACKENDFACTORY_INITIALIZER; + static ALCnullBackendFactory factory{}; return STATIC_CAST(ALCbackendFactory, &factory); } diff --git a/CMakeLists.txt b/CMakeLists.txt index b51c0367..3731e82e 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1032,7 +1032,7 @@ SET(ALC_OBJS ${ALC_OBJS} Alc/backends/base.h # Default backends, always available Alc/backends/loopback.cpp - Alc/backends/null.c + Alc/backends/null.cpp ) # Check ALSA backend |