From dc7ed39fa73c89cc3fe60f57a057252a6080adf3 Mon Sep 17 00:00:00 2001 From: Chris Robinson Date: Mon, 28 Oct 2013 07:27:35 -0700 Subject: Add a backend factory base type --- Alc/backends/base.h | 43 +++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 43 insertions(+) diff --git a/Alc/backends/base.h b/Alc/backends/base.h index 2cde8ccb..7c1b918b 100644 --- a/Alc/backends/base.h +++ b/Alc/backends/base.h @@ -72,4 +72,47 @@ static const struct ALCbackendVtable T##_ALCbackend_vtable = { \ } +typedef enum ALCbackend_Type { + ALCbackend_Playback +} ALCbackend_Type; + + +struct ALCbackendFactoryVtable; + +typedef struct ALCbackendFactory { + const struct ALCbackendFactoryVtable *vtbl; +} ALCbackendFactory; + +struct ALCbackendFactoryVtable { + ALCboolean (*const init)(ALCbackendFactory *self); + void (*const deinit)(ALCbackendFactory *self); + + ALCboolean (*const support)(ALCbackendFactory *self, ALCbackend_Type type); + + void (*const probe)(ALCbackendFactory *self, enum DevProbe type); + + ALCbackend* (*const createBackend)(ALCbackendFactory *self, ALCdevice *device); +}; + +#define DEFINE_ALCBACKENDFACTORY_VTABLE(T) \ +static ALCboolean T##_ALCbackendFactory_init(ALCbackendFactory *obj) \ +{ return T##_init(STATIC_UPCAST(T, ALCbackendFactory, obj)); } \ +static void T##_ALCbackendFactory_deinit(ALCbackendFactory *obj) \ +{ T##_deinit(STATIC_UPCAST(T, ALCbackendFactory, obj)); } \ +static ALCboolean T##_ALCbackendFactory_support(ALCbackendFactory *obj, ALCbackend_Type a) \ +{ return T##_support(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 const struct ALCbackendFactoryVtable T##_ALCbackendFactory_vtable = { \ + T##_ALCbackendFactory_init, \ + T##_ALCbackendFactory_deinit, \ + T##_ALCbackendFactory_support, \ + T##_ALCbackendFactory_probe, \ + T##_ALCbackendFactory_createBackend, \ +} + + #endif /* AL_BACKENDS_BASE_H */ -- cgit v1.2.3