aboutsummaryrefslogtreecommitdiffstats
path: root/Alc/backends
diff options
context:
space:
mode:
authorChris Robinson <[email protected]>2018-11-09 02:57:39 -0800
committerChris Robinson <[email protected]>2018-11-09 03:15:57 -0800
commit781ca7c58b9aac363afffb75b017e4dcffebb0ad (patch)
tree088c96bdb0467c950c1ac48988d342dc27bafb6b /Alc/backends
parentb327a50a15a6b0a9991fe59fa5dc775f195b7994 (diff)
Convert the loopback backend to C++
Diffstat (limited to 'Alc/backends')
-rw-r--r--Alc/backends/loopback.cpp (renamed from Alc/backends/loopback.c)37
1 files changed, 22 insertions, 15 deletions
diff --git a/Alc/backends/loopback.c b/Alc/backends/loopback.cpp
index e9940086..dd012ae5 100644
--- a/Alc/backends/loopback.c
+++ b/Alc/backends/loopback.cpp
@@ -20,20 +20,17 @@
#include "config.h"
-#include <stdlib.h>
-
#include "alMain.h"
#include "alu.h"
#include "backends/base.h"
-typedef struct ALCloopback {
- DERIVE_FROM_TYPE(ALCbackend);
-} ALCloopback;
+struct ALCloopback final : public ALCbackend {
+};
static void ALCloopback_Construct(ALCloopback *self, ALCdevice *device);
-static DECLARE_FORWARD(ALCloopback, ALCbackend, void, Destruct)
+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);
@@ -49,10 +46,17 @@ DEFINE_ALCBACKEND_VTABLE(ALCloopback);
static 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)
+{
+ ALCbackend_Destruct(STATIC_CAST(ALCbackend, self));
+ self->~ALCloopback();
+}
+
static ALCenum ALCloopback_open(ALCloopback *self, const ALCchar *name)
{
@@ -78,10 +82,9 @@ static void ALCloopback_stop(ALCloopback* UNUSED(self))
}
-typedef struct ALCloopbackFactory {
- DERIVE_FROM_TYPE(ALCbackendFactory);
-} ALCloopbackFactory;
-#define ALCNULLBACKENDFACTORY_INITIALIZER { { GET_VTABLE2(ALCloopbackFactory, ALCbackendFactory) } }
+struct ALCloopbackFactory final : public ALCbackendFactory {
+ ALCloopbackFactory() noexcept;
+};
ALCbackendFactory *ALCloopbackFactory_getFactory(void);
static ALCboolean ALCloopbackFactory_init(ALCloopbackFactory *self);
@@ -91,12 +94,10 @@ static void ALCloopbackFactory_probe(ALCloopbackFactory *self, enum DevProbe typ
static ALCbackend* ALCloopbackFactory_createBackend(ALCloopbackFactory *self, ALCdevice *device, ALCbackend_Type type);
DEFINE_ALCBACKENDFACTORY_VTABLE(ALCloopbackFactory);
+ALCloopbackFactory::ALCloopbackFactory() noexcept
+ : ALCbackendFactory{GET_VTABLE2(ALCloopbackFactory, ALCbackendFactory)}
+{ }
-ALCbackendFactory *ALCloopbackFactory_getFactory(void)
-{
- static ALCloopbackFactory factory = ALCNULLBACKENDFACTORY_INITIALIZER;
- return STATIC_CAST(ALCbackendFactory, &factory);
-}
static ALCboolean ALCloopbackFactory_init(ALCloopbackFactory* UNUSED(self))
{
@@ -126,3 +127,9 @@ static ALCbackend* ALCloopbackFactory_createBackend(ALCloopbackFactory* UNUSED(s
return NULL;
}
+
+ALCbackendFactory *ALCloopbackFactory_getFactory(void)
+{
+ static ALCloopbackFactory factory{};
+ return STATIC_CAST(ALCbackendFactory, &factory);
+}