2013-10-27 16:37:40 -07:00
|
|
|
#ifndef AL_BACKENDS_BASE_H
|
|
|
|
#define AL_BACKENDS_BASE_H
|
|
|
|
|
|
|
|
#include "alMain.h"
|
2018-09-07 22:02:37 -07:00
|
|
|
#include "alstring.h"
|
2013-10-27 16:37:40 -07:00
|
|
|
|
2018-03-09 17:24:03 -08:00
|
|
|
#ifdef __cplusplus
|
|
|
|
|
2018-11-15 03:49:59 -08:00
|
|
|
#include <mutex>
|
|
|
|
|
|
|
|
struct ClockLatency {
|
2016-05-28 00:43:14 -07:00
|
|
|
ALint64 ClockTime;
|
|
|
|
ALint64 Latency;
|
2018-11-15 03:49:59 -08:00
|
|
|
};
|
2016-05-28 00:43:14 -07:00
|
|
|
|
|
|
|
/* Helper to get the current clock time from the device's ClockBase, and
|
|
|
|
* SamplesDone converted from the sample rate.
|
|
|
|
*/
|
|
|
|
inline ALuint64 GetDeviceClockTime(ALCdevice *device)
|
|
|
|
{
|
|
|
|
return device->ClockBase + (device->SamplesDone * DEVICE_CLOCK_RES /
|
|
|
|
device->Frequency);
|
|
|
|
}
|
|
|
|
|
2018-11-15 02:36:05 -08:00
|
|
|
void ALCdevice_Lock(ALCdevice *device);
|
|
|
|
void ALCdevice_Unlock(ALCdevice *device);
|
|
|
|
|
|
|
|
ClockLatency GetClockLatency(ALCdevice *device);
|
|
|
|
|
2016-05-28 00:43:14 -07:00
|
|
|
|
2013-10-27 16:37:40 -07:00
|
|
|
struct ALCbackendVtable;
|
|
|
|
|
2018-11-15 02:36:05 -08:00
|
|
|
struct ALCbackend {
|
2013-10-27 16:37:40 -07:00
|
|
|
const struct ALCbackendVtable *vtbl;
|
|
|
|
|
|
|
|
ALCdevice *mDevice;
|
2013-10-28 12:05:33 -07:00
|
|
|
|
2018-11-15 03:49:59 -08:00
|
|
|
std::recursive_mutex mMutex;
|
2018-11-15 02:36:05 -08:00
|
|
|
};
|
2013-10-27 16:37:40 -07:00
|
|
|
|
2013-10-28 12:05:33 -07:00
|
|
|
void ALCbackend_Construct(ALCbackend *self, ALCdevice *device);
|
|
|
|
void ALCbackend_Destruct(ALCbackend *self);
|
2013-10-29 15:07:13 -07:00
|
|
|
ALCboolean ALCbackend_reset(ALCbackend *self);
|
|
|
|
ALCenum ALCbackend_captureSamples(ALCbackend *self, void *buffer, ALCuint samples);
|
|
|
|
ALCuint ALCbackend_availableSamples(ALCbackend *self);
|
2016-05-28 00:43:14 -07:00
|
|
|
ClockLatency ALCbackend_getClockLatency(ALCbackend *self);
|
2013-10-28 05:10:28 -07:00
|
|
|
void ALCbackend_lock(ALCbackend *self);
|
|
|
|
void ALCbackend_unlock(ALCbackend *self);
|
|
|
|
|
2013-10-27 16:37:40 -07:00
|
|
|
struct ALCbackendVtable {
|
2013-10-28 22:29:59 -07:00
|
|
|
void (*const Destruct)(ALCbackend*);
|
2013-10-27 16:37:40 -07:00
|
|
|
|
|
|
|
ALCenum (*const open)(ALCbackend*, const ALCchar*);
|
|
|
|
|
2013-11-02 16:58:26 -07:00
|
|
|
ALCboolean (*const reset)(ALCbackend*);
|
|
|
|
ALCboolean (*const start)(ALCbackend*);
|
|
|
|
void (*const stop)(ALCbackend*);
|
2013-10-27 16:37:40 -07:00
|
|
|
|
2013-11-02 16:58:26 -07:00
|
|
|
ALCenum (*const captureSamples)(ALCbackend*, void*, ALCuint);
|
|
|
|
ALCuint (*const availableSamples)(ALCbackend*);
|
2013-10-28 13:51:55 -07:00
|
|
|
|
2016-05-28 00:43:14 -07:00
|
|
|
ClockLatency (*const getClockLatency)(ALCbackend*);
|
2013-10-27 16:37:40 -07:00
|
|
|
|
2013-11-02 16:58:26 -07:00
|
|
|
void (*const lock)(ALCbackend*);
|
|
|
|
void (*const unlock)(ALCbackend*);
|
2013-10-28 05:10:28 -07:00
|
|
|
|
2014-03-22 00:28:55 -07:00
|
|
|
void (*const Delete)(void*);
|
2013-10-27 16:37:40 -07:00
|
|
|
};
|
|
|
|
|
|
|
|
#define DEFINE_ALCBACKEND_VTABLE(T) \
|
2013-10-29 20:08:03 -07:00
|
|
|
DECLARE_THUNK(T, ALCbackend, void, Destruct) \
|
|
|
|
DECLARE_THUNK1(T, ALCbackend, ALCenum, open, const ALCchar*) \
|
|
|
|
DECLARE_THUNK(T, ALCbackend, ALCboolean, reset) \
|
|
|
|
DECLARE_THUNK(T, ALCbackend, ALCboolean, start) \
|
|
|
|
DECLARE_THUNK(T, ALCbackend, void, stop) \
|
|
|
|
DECLARE_THUNK2(T, ALCbackend, ALCenum, captureSamples, void*, ALCuint) \
|
|
|
|
DECLARE_THUNK(T, ALCbackend, ALCuint, availableSamples) \
|
2016-05-28 00:43:14 -07:00
|
|
|
DECLARE_THUNK(T, ALCbackend, ClockLatency, getClockLatency) \
|
2013-10-29 20:08:03 -07:00
|
|
|
DECLARE_THUNK(T, ALCbackend, void, lock) \
|
|
|
|
DECLARE_THUNK(T, ALCbackend, void, unlock) \
|
2014-03-22 00:28:55 -07:00
|
|
|
static void T##_ALCbackend_Delete(void *ptr) \
|
2014-04-19 02:38:32 -07:00
|
|
|
{ T##_Delete(STATIC_UPCAST(T, ALCbackend, (ALCbackend*)ptr)); } \
|
2013-10-27 16:37:40 -07:00
|
|
|
\
|
2014-04-23 03:52:05 -07:00
|
|
|
static const struct ALCbackendVtable T##_ALCbackend_vtable = { \
|
2013-10-27 16:37:40 -07:00
|
|
|
T##_ALCbackend_Destruct, \
|
|
|
|
\
|
|
|
|
T##_ALCbackend_open, \
|
|
|
|
T##_ALCbackend_reset, \
|
|
|
|
T##_ALCbackend_start, \
|
|
|
|
T##_ALCbackend_stop, \
|
2013-10-28 13:51:55 -07:00
|
|
|
T##_ALCbackend_captureSamples, \
|
|
|
|
T##_ALCbackend_availableSamples, \
|
2016-05-28 00:43:14 -07:00
|
|
|
T##_ALCbackend_getClockLatency, \
|
2013-10-28 05:10:28 -07:00
|
|
|
T##_ALCbackend_lock, \
|
|
|
|
T##_ALCbackend_unlock, \
|
2013-10-27 16:37:40 -07:00
|
|
|
\
|
|
|
|
T##_ALCbackend_Delete, \
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2018-11-15 02:36:05 -08:00
|
|
|
enum ALCbackend_Type {
|
2013-10-28 14:38:55 -07:00
|
|
|
ALCbackend_Playback,
|
2013-11-04 10:51:22 -08:00
|
|
|
ALCbackend_Capture,
|
|
|
|
ALCbackend_Loopback
|
2018-11-15 02:36:05 -08:00
|
|
|
};
|
2013-10-28 07:27:35 -07:00
|
|
|
|
|
|
|
|
|
|
|
struct ALCbackendFactoryVtable;
|
|
|
|
|
2018-11-15 02:36:05 -08:00
|
|
|
struct ALCbackendFactory {
|
2013-10-28 07:27:35 -07:00
|
|
|
const struct ALCbackendFactoryVtable *vtbl;
|
2018-11-15 02:36:05 -08:00
|
|
|
};
|
2013-10-28 07:27:35 -07:00
|
|
|
|
2013-11-02 15:42:45 -07:00
|
|
|
void ALCbackendFactory_deinit(ALCbackendFactory *self);
|
|
|
|
|
2013-10-28 07:27:35 -07:00
|
|
|
struct ALCbackendFactoryVtable {
|
|
|
|
ALCboolean (*const init)(ALCbackendFactory *self);
|
|
|
|
void (*const deinit)(ALCbackendFactory *self);
|
|
|
|
|
2013-10-28 17:23:19 -07:00
|
|
|
ALCboolean (*const querySupport)(ALCbackendFactory *self, ALCbackend_Type type);
|
2013-10-28 07:27:35 -07:00
|
|
|
|
2018-09-07 22:02:37 -07:00
|
|
|
void (*const probe)(ALCbackendFactory *self, enum DevProbe type, al_string *outnames);
|
2013-10-28 07:27:35 -07:00
|
|
|
|
2013-10-28 22:03:54 -07:00
|
|
|
ALCbackend* (*const createBackend)(ALCbackendFactory *self, ALCdevice *device, ALCbackend_Type type);
|
2013-10-28 07:27:35 -07:00
|
|
|
};
|
|
|
|
|
|
|
|
#define DEFINE_ALCBACKENDFACTORY_VTABLE(T) \
|
2013-10-29 20:08:03 -07:00
|
|
|
DECLARE_THUNK(T, ALCbackendFactory, ALCboolean, init) \
|
|
|
|
DECLARE_THUNK(T, ALCbackendFactory, void, deinit) \
|
|
|
|
DECLARE_THUNK1(T, ALCbackendFactory, ALCboolean, querySupport, ALCbackend_Type) \
|
2018-09-07 22:02:37 -07:00
|
|
|
DECLARE_THUNK2(T, ALCbackendFactory, void, probe, enum DevProbe, al_string*) \
|
2013-10-29 20:08:03 -07:00
|
|
|
DECLARE_THUNK2(T, ALCbackendFactory, ALCbackend*, createBackend, ALCdevice*, ALCbackend_Type) \
|
2013-10-28 07:27:35 -07:00
|
|
|
\
|
|
|
|
static const struct ALCbackendFactoryVtable T##_ALCbackendFactory_vtable = { \
|
|
|
|
T##_ALCbackendFactory_init, \
|
|
|
|
T##_ALCbackendFactory_deinit, \
|
2013-10-28 17:23:19 -07:00
|
|
|
T##_ALCbackendFactory_querySupport, \
|
2013-10-28 07:27:35 -07:00
|
|
|
T##_ALCbackendFactory_probe, \
|
|
|
|
T##_ALCbackendFactory_createBackend, \
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2013-10-29 14:44:07 -07:00
|
|
|
ALCbackendFactory *ALCpulseBackendFactory_getFactory(void);
|
2013-11-02 15:42:45 -07:00
|
|
|
ALCbackendFactory *ALCalsaBackendFactory_getFactory(void);
|
2017-04-09 11:21:02 -07:00
|
|
|
ALCbackendFactory *ALCcoreAudioBackendFactory_getFactory(void);
|
2013-11-02 15:42:45 -07:00
|
|
|
ALCbackendFactory *ALCossBackendFactory_getFactory(void);
|
2014-12-21 15:51:16 -08:00
|
|
|
ALCbackendFactory *ALCjackBackendFactory_getFactory(void);
|
2015-05-17 03:12:34 -07:00
|
|
|
ALCbackendFactory *ALCsolarisBackendFactory_getFactory(void);
|
2018-09-07 18:45:24 -07:00
|
|
|
ALCbackendFactory *SndioBackendFactory_getFactory(void);
|
2017-06-18 03:07:02 -07:00
|
|
|
ALCbackendFactory *ALCqsaBackendFactory_getFactory(void);
|
2018-03-09 18:56:24 -08:00
|
|
|
ALCbackendFactory *ALCwasapiBackendFactory_getFactory(void);
|
2014-04-19 22:54:21 -07:00
|
|
|
ALCbackendFactory *ALCdsoundBackendFactory_getFactory(void);
|
2014-09-08 06:46:20 -07:00
|
|
|
ALCbackendFactory *ALCwinmmBackendFactory_getFactory(void);
|
2015-10-22 10:46:36 -07:00
|
|
|
ALCbackendFactory *ALCportBackendFactory_getFactory(void);
|
2017-02-07 06:25:11 -08:00
|
|
|
ALCbackendFactory *ALCopenslBackendFactory_getFactory(void);
|
2013-10-28 08:29:19 -07:00
|
|
|
ALCbackendFactory *ALCnullBackendFactory_getFactory(void);
|
2014-08-24 22:20:02 -07:00
|
|
|
ALCbackendFactory *ALCwaveBackendFactory_getFactory(void);
|
2018-03-07 20:53:56 +01:00
|
|
|
ALCbackendFactory *ALCsdl2BackendFactory_getFactory(void);
|
2013-10-29 10:38:55 -07:00
|
|
|
ALCbackendFactory *ALCloopbackFactory_getFactory(void);
|
2013-10-28 08:29:19 -07:00
|
|
|
|
2018-11-15 02:36:05 -08:00
|
|
|
#endif /* __cplusplus */
|
2013-10-27 16:37:40 -07:00
|
|
|
#endif /* AL_BACKENDS_BASE_H */
|