aboutsummaryrefslogtreecommitdiffstats
path: root/Alc
diff options
context:
space:
mode:
Diffstat (limited to 'Alc')
-rw-r--r--Alc/ALc.c10
-rw-r--r--Alc/backends/alsa.c31
-rw-r--r--Alc/backends/base.h6
-rw-r--r--Alc/backends/null.c4
4 files changed, 38 insertions, 13 deletions
diff --git a/Alc/ALc.c b/Alc/ALc.c
index 4aaf765a..efbc4be5 100644
--- a/Alc/ALc.c
+++ b/Alc/ALc.c
@@ -2890,7 +2890,7 @@ ALC_API ALCdevice* ALC_APIENTRY alcOpenDevice(const ALCchar *deviceName)
else
{
ALCbackendFactory *factory = PlaybackBackend.getFactory();
- device->Backend = VCALL(factory,createBackend)(device);
+ device->Backend = VCALL(factory,createBackend)(device, ALCbackend_Playback);
}
if(!device->Backend)
{
@@ -3152,7 +3152,13 @@ ALC_API ALCdevice* ALC_APIENTRY alcCaptureOpenDevice(const ALCchar *deviceName,
device->DeviceName = NULL;
- device->Backend = create_backend_wrapper(device, ALCbackend_Capture);
+ if(!CaptureBackend.getFactory)
+ device->Backend = create_backend_wrapper(device, ALCbackend_Capture);
+ else
+ {
+ ALCbackendFactory *factory = CaptureBackend.getFactory();
+ device->Backend = VCALL(factory,createBackend)(device, ALCbackend_Capture);
+ }
if(!device->Backend)
{
al_free(device);
diff --git a/Alc/backends/alsa.c b/Alc/backends/alsa.c
index c811bdfc..0bed0d4b 100644
--- a/Alc/backends/alsa.c
+++ b/Alc/backends/alsa.c
@@ -1466,17 +1466,34 @@ void ALCalsaBackendFactory_probe(ALCalsaBackendFactory* UNUSED(self), enum DevPr
}
}
-ALCbackend* ALCalsaBackendFactory_createBackend(ALCalsaBackendFactory* UNUSED(self), ALCdevice *device)
+ALCbackend* ALCalsaBackendFactory_createBackend(ALCalsaBackendFactory* UNUSED(self), ALCdevice *device, ALCbackend_Type type)
{
- ALCplaybackAlsa *backend;
+ if(type == ALCbackend_Playback)
+ {
+ ALCplaybackAlsa *backend;
+
+ backend = calloc(1, sizeof(*backend));
+ if(!backend) return NULL;
+ SET_VTABLE2(ALCplaybackAlsa, ALCbackend, backend);
+
+ ALCplaybackAlsa_Construct(backend, device);
+
+ return STATIC_CAST(ALCbackend, backend);
+ }
+ if(type == ALCbackend_Capture)
+ {
+ ALCcaptureAlsa *backend;
- backend = calloc(1, sizeof(*backend));
- if(!backend) return NULL;
- SET_VTABLE2(ALCplaybackAlsa, ALCbackend, backend);
+ backend = calloc(1, sizeof(*backend));
+ if(!backend) return NULL;
+ SET_VTABLE2(ALCcaptureAlsa, ALCbackend, backend);
- ALCplaybackAlsa_Construct(backend, device);
+ ALCcaptureAlsa_Construct(backend, device);
+
+ return STATIC_CAST(ALCbackend, backend);
+ }
- return STATIC_CAST(ALCbackend, backend);
+ return NULL;
}
DEFINE_ALCBACKENDFACTORY_VTABLE(ALCalsaBackendFactory);
diff --git a/Alc/backends/base.h b/Alc/backends/base.h
index f1da721d..d05ec0f5 100644
--- a/Alc/backends/base.h
+++ b/Alc/backends/base.h
@@ -106,7 +106,7 @@ struct ALCbackendFactoryVtable {
void (*const probe)(ALCbackendFactory *self, enum DevProbe type);
- ALCbackend* (*const createBackend)(ALCbackendFactory *self, ALCdevice *device);
+ ALCbackend* (*const createBackend)(ALCbackendFactory *self, ALCdevice *device, ALCbackend_Type type);
};
#define DEFINE_ALCBACKENDFACTORY_VTABLE(T) \
@@ -118,8 +118,8 @@ static ALCboolean T##_ALCbackendFactory_querySupport(ALCbackendFactory *obj, ALC
{ return T##_querySupport(STATIC_UPCAST(T, ALCbackendFactory, obj), a); } \
static void T##_ALCbackendFactory_probe(ALCbackendFactory *obj, enum DevProbe a) \
{ T##_probe(STATIC_UPCAST(T, ALCbackendFactory, obj), a); } \
-static ALCbackend* T##_ALCbackendFactory_createBackend(ALCbackendFactory *obj, ALCdevice *a) \
-{ return T##_createBackend(STATIC_UPCAST(T, ALCbackendFactory, obj), a); } \
+static ALCbackend* T##_ALCbackendFactory_createBackend(ALCbackendFactory *obj, ALCdevice *a, ALCbackend_Type b) \
+{ return T##_createBackend(STATIC_UPCAST(T, ALCbackendFactory, obj), a, b); } \
\
static const struct ALCbackendFactoryVtable T##_ALCbackendFactory_vtable = { \
T##_ALCbackendFactory_init, \
diff --git a/Alc/backends/null.c b/Alc/backends/null.c
index 9e762190..c5b178de 100644
--- a/Alc/backends/null.c
+++ b/Alc/backends/null.c
@@ -206,10 +206,12 @@ void ALCnullBackendFactory_probe(ALCnullBackendFactory* UNUSED(self), enum DevPr
}
}
-ALCbackend* ALCnullBackendFactory_createBackend(ALCnullBackendFactory* UNUSED(self), ALCdevice *device)
+ALCbackend* ALCnullBackendFactory_createBackend(ALCnullBackendFactory* UNUSED(self), ALCdevice *device, ALCbackend_Type type)
{
ALCnullBackend *backend;
+ assert(type == ALCbackend_Playback);
+
backend = calloc(1, sizeof(*backend));
if(!backend) return NULL;
SET_VTABLE2(ALCnullBackend, ALCbackend, backend);