1 #ifndef AL_BACKENDS_BASE_H
2 #define AL_BACKENDS_BASE_H
8 struct ALCbackendVtable
;
10 typedef struct ALCbackend
{
11 const struct ALCbackendVtable
*vtbl
;
18 void ALCbackend_Construct(ALCbackend
*self
, ALCdevice
*device
);
19 void ALCbackend_Destruct(ALCbackend
*self
);
20 ALCboolean
ALCbackend_reset(ALCbackend
*self
);
21 ALCenum
ALCbackend_captureSamples(ALCbackend
*self
, void *buffer
, ALCuint samples
);
22 ALCuint
ALCbackend_availableSamples(ALCbackend
*self
);
23 ALint64
ALCbackend_getLatency(ALCbackend
*self
);
24 void ALCbackend_lock(ALCbackend
*self
);
25 void ALCbackend_unlock(ALCbackend
*self
);
27 struct ALCbackendVtable
{
28 void (*const Destruct
)(ALCbackend
*);
30 ALCenum (*const open
)(ALCbackend
*, const ALCchar
*);
31 void (*const close
)(ALCbackend
*);
33 ALCboolean (*const reset
)(ALCbackend
*);
34 ALCboolean (*const start
)(ALCbackend
*);
35 void (*const stop
)(ALCbackend
*);
37 ALCenum (*const captureSamples
)(ALCbackend
*, void*, ALCuint
);
38 ALCuint (*const availableSamples
)(ALCbackend
*);
40 ALint64 (*const getLatency
)(ALCbackend
*);
42 void (*const lock
)(ALCbackend
*);
43 void (*const unlock
)(ALCbackend
*);
45 void (*const Delete
)(void*);
48 #define DEFINE_ALCBACKEND_VTABLE(T) \
49 DECLARE_THUNK(T, ALCbackend, void, Destruct) \
50 DECLARE_THUNK1(T, ALCbackend, ALCenum, open, const ALCchar*) \
51 DECLARE_THUNK(T, ALCbackend, void, close) \
52 DECLARE_THUNK(T, ALCbackend, ALCboolean, reset) \
53 DECLARE_THUNK(T, ALCbackend, ALCboolean, start) \
54 DECLARE_THUNK(T, ALCbackend, void, stop) \
55 DECLARE_THUNK2(T, ALCbackend, ALCenum, captureSamples, void*, ALCuint) \
56 DECLARE_THUNK(T, ALCbackend, ALCuint, availableSamples) \
57 DECLARE_THUNK(T, ALCbackend, ALint64, getLatency) \
58 DECLARE_THUNK(T, ALCbackend, void, lock) \
59 DECLARE_THUNK(T, ALCbackend, void, unlock) \
60 static void T##_ALCbackend_Delete(void *ptr) \
61 { T##_Delete(STATIC_UPCAST(T, ALCbackend, (ALCbackend*)ptr)); } \
63 static const struct ALCbackendVtable T##_ALCbackend_vtable = { \
64 T##_ALCbackend_Destruct, \
66 T##_ALCbackend_open, \
67 T##_ALCbackend_close, \
68 T##_ALCbackend_reset, \
69 T##_ALCbackend_start, \
70 T##_ALCbackend_stop, \
71 T##_ALCbackend_captureSamples, \
72 T##_ALCbackend_availableSamples, \
73 T##_ALCbackend_getLatency, \
74 T##_ALCbackend_lock, \
75 T##_ALCbackend_unlock, \
77 T##_ALCbackend_Delete, \
81 typedef enum ALCbackend_Type
{
88 struct ALCbackendFactoryVtable
;
90 typedef struct ALCbackendFactory
{
91 const struct ALCbackendFactoryVtable
*vtbl
;
94 void ALCbackendFactory_deinit(ALCbackendFactory
*self
);
96 struct ALCbackendFactoryVtable
{
97 ALCboolean (*const init
)(ALCbackendFactory
*self
);
98 void (*const deinit
)(ALCbackendFactory
*self
);
100 ALCboolean (*const querySupport
)(ALCbackendFactory
*self
, ALCbackend_Type type
);
102 void (*const probe
)(ALCbackendFactory
*self
, enum DevProbe type
);
104 ALCbackend
* (*const createBackend
)(ALCbackendFactory
*self
, ALCdevice
*device
, ALCbackend_Type type
);
107 #define DEFINE_ALCBACKENDFACTORY_VTABLE(T) \
108 DECLARE_THUNK(T, ALCbackendFactory, ALCboolean, init) \
109 DECLARE_THUNK(T, ALCbackendFactory, void, deinit) \
110 DECLARE_THUNK1(T, ALCbackendFactory, ALCboolean, querySupport, ALCbackend_Type) \
111 DECLARE_THUNK1(T, ALCbackendFactory, void, probe, enum DevProbe) \
112 DECLARE_THUNK2(T, ALCbackendFactory, ALCbackend*, createBackend, ALCdevice*, ALCbackend_Type) \
114 static const struct ALCbackendFactoryVtable T##_ALCbackendFactory_vtable = { \
115 T##_ALCbackendFactory_init, \
116 T##_ALCbackendFactory_deinit, \
117 T##_ALCbackendFactory_querySupport, \
118 T##_ALCbackendFactory_probe, \
119 T##_ALCbackendFactory_createBackend, \
123 ALCbackendFactory
*ALCpulseBackendFactory_getFactory(void);
124 ALCbackendFactory
*ALCalsaBackendFactory_getFactory(void);
125 ALCbackendFactory
*ALCossBackendFactory_getFactory(void);
126 ALCbackendFactory
*ALCjackBackendFactory_getFactory(void);
127 ALCbackendFactory
*ALCsolarisBackendFactory_getFactory(void);
128 ALCbackendFactory
*ALCmmdevBackendFactory_getFactory(void);
129 ALCbackendFactory
*ALCdsoundBackendFactory_getFactory(void);
130 ALCbackendFactory
*ALCwinmmBackendFactory_getFactory(void);
131 ALCbackendFactory
*ALCportBackendFactory_getFactory(void);
132 ALCbackendFactory
*ALCnullBackendFactory_getFactory(void);
133 ALCbackendFactory
*ALCwaveBackendFactory_getFactory(void);
134 ALCbackendFactory
*ALCloopbackFactory_getFactory(void);
136 ALCbackend
*create_backend_wrapper(ALCdevice
*device
, const BackendFuncs
*funcs
, ALCbackend_Type type
);
138 #endif /* AL_BACKENDS_BASE_H */