aboutsummaryrefslogtreecommitdiffstats
path: root/Alc/backends/base.h
diff options
context:
space:
mode:
Diffstat (limited to 'Alc/backends/base.h')
-rw-r--r--Alc/backends/base.h79
1 files changed, 15 insertions, 64 deletions
diff --git a/Alc/backends/base.h b/Alc/backends/base.h
index 4380540f..b9ea3b61 100644
--- a/Alc/backends/base.h
+++ b/Alc/backends/base.h
@@ -6,7 +6,6 @@
#include <mutex>
#include "alMain.h"
-#include "polymorphism.h"
struct ClockLatency {
@@ -32,77 +31,29 @@ void ALCdevice_Unlock(ALCdevice *device);
ClockLatency GetClockLatency(ALCdevice *device);
+struct BackendBase {
+ virtual ALCenum open(const ALCchar *name) = 0;
-struct ALCbackendVtable;
+ virtual ALCboolean reset();
+ virtual ALCboolean start() = 0;
+ virtual void stop() = 0;
-struct ALCbackend {
- const ALCbackendVtable *vtbl;
+ virtual ALCenum captureSamples(void *buffer, ALCuint samples);
+ virtual ALCuint availableSamples();
- ALCdevice *mDevice;
-
- std::recursive_mutex mMutex;
-
- ALCbackend(ALCdevice *device) noexcept;
- virtual ~ALCbackend();
-};
-
-ALCboolean ALCbackend_reset(ALCbackend *self);
-ALCenum ALCbackend_captureSamples(ALCbackend *self, void *buffer, ALCuint samples);
-ALCuint ALCbackend_availableSamples(ALCbackend *self);
-ClockLatency ALCbackend_getClockLatency(ALCbackend *self);
-void ALCbackend_lock(ALCbackend *self);
-void ALCbackend_unlock(ALCbackend *self);
-
-struct ALCbackendVtable {
- void (*const Destruct)(ALCbackend*);
+ virtual ClockLatency getClockLatency();
- ALCenum (*const open)(ALCbackend*, const ALCchar*);
+ virtual void lock() noexcept;
+ virtual void unlock() noexcept;
- ALCboolean (*const reset)(ALCbackend*);
- ALCboolean (*const start)(ALCbackend*);
- void (*const stop)(ALCbackend*);
-
- ALCenum (*const captureSamples)(ALCbackend*, void*, ALCuint);
- ALCuint (*const availableSamples)(ALCbackend*);
-
- ClockLatency (*const getClockLatency)(ALCbackend*);
+ ALCdevice *mDevice;
- void (*const lock)(ALCbackend*);
- void (*const unlock)(ALCbackend*);
+ std::recursive_mutex mMutex;
- void (*const Delete)(void*);
+ BackendBase(ALCdevice *device) noexcept;
+ virtual ~BackendBase();
};
-#define DEFINE_ALCBACKEND_VTABLE(T) \
-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) \
-DECLARE_THUNK(T, ALCbackend, ClockLatency, getClockLatency) \
-DECLARE_THUNK(T, ALCbackend, void, lock) \
-DECLARE_THUNK(T, ALCbackend, void, unlock) \
-static void T##_ALCbackend_Delete(void *ptr) \
-{ T##_Delete(static_cast<T*>(static_cast<ALCbackend*>(ptr))); } \
- \
-static const ALCbackendVtable T##_ALCbackend_vtable = { \
- T##_ALCbackend_Destruct, \
- \
- T##_ALCbackend_open, \
- T##_ALCbackend_reset, \
- T##_ALCbackend_start, \
- T##_ALCbackend_stop, \
- T##_ALCbackend_captureSamples, \
- T##_ALCbackend_availableSamples, \
- T##_ALCbackend_getClockLatency, \
- T##_ALCbackend_lock, \
- T##_ALCbackend_unlock, \
- \
- T##_ALCbackend_Delete, \
-}
-
enum ALCbackend_Type {
ALCbackend_Playback,
@@ -119,7 +70,7 @@ struct BackendFactory {
virtual void probe(DevProbe type, std::string *outnames) = 0;
- virtual ALCbackend *createBackend(ALCdevice *device, ALCbackend_Type type) = 0;
+ virtual BackendBase *createBackend(ALCdevice *device, ALCbackend_Type type) = 0;
};
#endif /* ALC_BACKENDS_BASE_H */