Use a unique backend type for loopback

This commit is contained in:
Chris Robinson 2013-11-04 10:51:22 -08:00
parent 9760a592b2
commit 94aeb5f52e
3 changed files with 49 additions and 49 deletions

View File

@ -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);

View File

@ -82,7 +82,8 @@ DECLARE_ALCBACKEND_VTABLE(T) = { \
typedef enum ALCbackend_Type {
ALCbackend_Playback,
ALCbackend_Capture
ALCbackend_Capture,
ALCbackend_Loopback
} ALCbackend_Type;

View File

@ -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);
}