aboutsummaryrefslogtreecommitdiffstats
path: root/Alc/backends
diff options
context:
space:
mode:
authorChris Robinson <[email protected]>2018-11-09 03:46:30 -0800
committerChris Robinson <[email protected]>2018-11-09 03:46:30 -0800
commite8679e72140438b7fb9d2fe672914b056d1a3171 (patch)
tree257df3aa18d01362c8192fdf5f33896c6057cf06 /Alc/backends
parent781ca7c58b9aac363afffb75b017e4dcffebb0ad (diff)
Convert the null backend to C++
Diffstat (limited to 'Alc/backends')
-rw-r--r--Alc/backends/null.cpp (renamed from Alc/backends/null.c)36
1 files changed, 24 insertions, 12 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);
}