From 94aeb5f52e656e021ce626ef523fb4a29cce117f Mon Sep 17 00:00:00 2001 From: Chris Robinson Date: Mon, 4 Nov 2013 10:51:22 -0800 Subject: [PATCH] Use a unique backend type for loopback --- Alc/ALc.c | 2 +- Alc/backends/base.h | 3 +- Alc/backends/loopback.c | 93 ++++++++++++++++++++--------------------- 3 files changed, 49 insertions(+), 49 deletions(-) diff --git a/Alc/ALc.c b/Alc/ALc.c index 6ee2b997..95b262b6 100644 --- a/Alc/ALc.c +++ b/Alc/ALc.c @@ -3318,7 +3318,7 @@ ALC_API ALCdevice* ALC_APIENTRY alcLoopbackOpenDeviceSOFT(const ALCchar *deviceN InitUIntMap(&device->FilterMap, ~0); factory = ALCloopbackFactory_getFactory(); - device->Backend = V(factory,createBackend)(device, ALCbackend_Playback); + device->Backend = V(factory,createBackend)(device, ALCbackend_Loopback); if(!device->Backend) { al_free(device); diff --git a/Alc/backends/base.h b/Alc/backends/base.h index 607ca6e8..1bbc1fb0 100644 --- a/Alc/backends/base.h +++ b/Alc/backends/base.h @@ -82,7 +82,8 @@ DECLARE_ALCBACKEND_VTABLE(T) = { \ typedef enum ALCbackend_Type { ALCbackend_Playback, - ALCbackend_Capture + ALCbackend_Capture, + ALCbackend_Loopback } ALCbackend_Type; diff --git a/Alc/backends/loopback.c b/Alc/backends/loopback.c index e400fcf2..cd5b1a1e 100644 --- a/Alc/backends/loopback.c +++ b/Alc/backends/loopback.c @@ -31,12 +31,21 @@ typedef struct ALCloopback { DERIVE_FROM_TYPE(ALCbackend); } ALCloopback; -DECLARE_ALCBACKEND_VTABLE(ALCloopback); +static void ALCloopback_Construct(ALCloopback *self, ALCdevice *device); static DECLARE_FORWARD(ALCloopback, ALCbackend, void, Destruct) +static ALCenum ALCloopback_open(ALCloopback *self, const ALCchar *name); +static void ALCloopback_close(ALCloopback *self); +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, ALint64, getLatency) static DECLARE_FORWARD(ALCloopback, ALCbackend, void, lock) static DECLARE_FORWARD(ALCloopback, ALCbackend, void, unlock) +static void ALCloopback_Delete(ALCloopback *self); +DEFINE_ALCBACKEND_VTABLE(ALCloopback); static void ALCloopback_Construct(ALCloopback *self, ALCdevice *device) @@ -73,64 +82,24 @@ static void ALCloopback_stop(ALCloopback* UNUSED(self)) { } -ALCenum ALCloopback_captureSamples(ALCloopback* UNUSED(self), void* UNUSED(buffer), ALCuint UNUSED(samples)) -{ - return ALC_INVALID_VALUE; -} - -ALCuint ALCloopback_availableSamples(ALCloopback* UNUSED(self)) -{ - return 0; -} - static void ALCloopback_Delete(ALCloopback *self) { free(self); } -DEFINE_ALCBACKEND_VTABLE(ALCloopback); - typedef struct ALCloopbackFactory { DERIVE_FROM_TYPE(ALCbackendFactory); } ALCloopbackFactory; #define ALCNULLBACKENDFACTORY_INITIALIZER { { GET_VTABLE2(ALCloopbackFactory, ALCbackendFactory) } } -ALCboolean ALCloopbackFactory_init(ALCloopbackFactory* UNUSED(self)) -{ - return ALC_TRUE; -} - -void ALCloopbackFactory_deinit(ALCloopbackFactory* UNUSED(self)) -{ -} - -ALCboolean ALCloopbackFactory_querySupport(ALCloopbackFactory* UNUSED(self), ALCbackend_Type type) -{ - if(type == ALCbackend_Playback) - return ALC_TRUE; - return ALC_FALSE; -} - -void ALCloopbackFactory_probe(ALCloopbackFactory* UNUSED(self), enum DevProbe UNUSED(type)) -{ -} - -ALCbackend* ALCloopbackFactory_createBackend(ALCloopbackFactory* UNUSED(self), ALCdevice *device, ALCbackend_Type type) -{ - ALCloopback *backend; - - assert(type == ALCbackend_Playback); - - backend = calloc(1, sizeof(*backend)); - if(!backend) return NULL; - - ALCloopback_Construct(backend, device); - - return STATIC_CAST(ALCbackend, backend); -} - +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); +static ALCbackend* ALCloopbackFactory_createBackend(ALCloopbackFactory *self, ALCdevice *device, ALCbackend_Type type); DEFINE_ALCBACKENDFACTORY_VTABLE(ALCloopbackFactory); @@ -139,3 +108,33 @@ ALCbackendFactory *ALCloopbackFactory_getFactory(void) static ALCloopbackFactory factory = ALCNULLBACKENDFACTORY_INITIALIZER; return STATIC_CAST(ALCbackendFactory, &factory); } + +static ALCboolean ALCloopbackFactory_init(ALCloopbackFactory* UNUSED(self)) +{ + return ALC_TRUE; +} + +static ALCboolean ALCloopbackFactory_querySupport(ALCloopbackFactory* UNUSED(self), ALCbackend_Type type) +{ + if(type == ALCbackend_Loopback) + return ALC_TRUE; + return ALC_FALSE; +} + +static void ALCloopbackFactory_probe(ALCloopbackFactory* UNUSED(self), enum DevProbe UNUSED(type)) +{ +} + +static ALCbackend* ALCloopbackFactory_createBackend(ALCloopbackFactory* UNUSED(self), ALCdevice *device, ALCbackend_Type type) +{ + ALCloopback *backend; + + assert(type == ALCbackend_Loopback); + + backend = calloc(1, sizeof(*backend)); + if(!backend) return NULL; + + ALCloopback_Construct(backend, device); + + return STATIC_CAST(ALCbackend, backend); +}