diff options
author | Chris Robinson <[email protected]> | 2014-04-23 03:52:05 -0700 |
---|---|---|
committer | Chris Robinson <[email protected]> | 2014-04-23 03:52:05 -0700 |
commit | 8fd224f84191b3d512f9ea0c44aa1104b23959d8 (patch) | |
tree | 2e5df0bb69426cd1f56d83f29020d5534d54a0f3 | |
parent | 420599f8e37c8657fd1568aca3bcd5d1d4711234 (diff) |
Avoid forward-declaring backend vtables
-rw-r--r-- | Alc/backends/alsa.c | 13 | ||||
-rw-r--r-- | Alc/backends/base.h | 5 | ||||
-rw-r--r-- | Alc/backends/null.c | 5 | ||||
-rw-r--r-- | Alc/backends/pulseaudio.c | 63 |
4 files changed, 44 insertions, 42 deletions
diff --git a/Alc/backends/alsa.c b/Alc/backends/alsa.c index 9d446208..53d8d8f0 100644 --- a/Alc/backends/alsa.c +++ b/Alc/backends/alsa.c @@ -398,7 +398,6 @@ typedef struct ALCplaybackAlsa { volatile int killNow; althrd_t thread; } ALCplaybackAlsa; -DECLARE_ALCBACKEND_VTABLE(ALCplaybackAlsa); static int ALCplaybackAlsa_mixerProc(void *ptr); static int ALCplaybackAlsa_mixerNoMMapProc(void *ptr); @@ -412,10 +411,13 @@ static ALCboolean ALCplaybackAlsa_start(ALCplaybackAlsa *self); static void ALCplaybackAlsa_stop(ALCplaybackAlsa *self); static DECLARE_FORWARD2(ALCplaybackAlsa, ALCbackend, ALCenum, captureSamples, void*, ALCuint) static DECLARE_FORWARD(ALCplaybackAlsa, ALCbackend, ALCuint, availableSamples) +static ALint64 ALCplaybackAlsa_getLatency(ALCplaybackAlsa *self); static DECLARE_FORWARD(ALCplaybackAlsa, ALCbackend, void, lock) static DECLARE_FORWARD(ALCplaybackAlsa, ALCbackend, void, unlock) DECLARE_DEFAULT_ALLOCATORS(ALCplaybackAlsa) +DEFINE_ALCBACKEND_VTABLE(ALCplaybackAlsa); + static void ALCplaybackAlsa_Construct(ALCplaybackAlsa *self, ALCdevice *device) { @@ -900,8 +902,6 @@ static ALint64 ALCplaybackAlsa_getLatency(ALCplaybackAlsa *self) return maxi64((ALint64)delay*1000000000/device->Frequency, 0); } -DEFINE_ALCBACKEND_VTABLE(ALCplaybackAlsa); - typedef struct ALCcaptureAlsa { DERIVE_FROM_TYPE(ALCbackend); @@ -916,7 +916,6 @@ typedef struct ALCcaptureAlsa { snd_pcm_sframes_t last_avail; } ALCcaptureAlsa; -DECLARE_ALCBACKEND_VTABLE(ALCcaptureAlsa); static void ALCcaptureAlsa_Construct(ALCcaptureAlsa *self, ALCdevice *device); static DECLARE_FORWARD(ALCcaptureAlsa, ALCbackend, void, Destruct) @@ -927,10 +926,13 @@ static ALCboolean ALCcaptureAlsa_start(ALCcaptureAlsa *self); static void ALCcaptureAlsa_stop(ALCcaptureAlsa *self); static ALCenum ALCcaptureAlsa_captureSamples(ALCcaptureAlsa *self, ALCvoid *buffer, ALCuint samples); static ALCuint ALCcaptureAlsa_availableSamples(ALCcaptureAlsa *self); +static ALint64 ALCcaptureAlsa_getLatency(ALCcaptureAlsa *self); static DECLARE_FORWARD(ALCcaptureAlsa, ALCbackend, void, lock) static DECLARE_FORWARD(ALCcaptureAlsa, ALCbackend, void, unlock) DECLARE_DEFAULT_ALLOCATORS(ALCcaptureAlsa) +DEFINE_ALCBACKEND_VTABLE(ALCcaptureAlsa); + static void ALCcaptureAlsa_Construct(ALCcaptureAlsa *self, ALCdevice *device) { @@ -1297,9 +1299,6 @@ static ALint64 ALCcaptureAlsa_getLatency(ALCcaptureAlsa *self) return maxi64((ALint64)delay*1000000000/device->Frequency, 0); } -DEFINE_ALCBACKEND_VTABLE(ALCcaptureAlsa); - - typedef struct ALCalsaBackendFactory { DERIVE_FROM_TYPE(ALCbackendFactory); diff --git a/Alc/backends/base.h b/Alc/backends/base.h index 31f46a1a..9db6e19d 100644 --- a/Alc/backends/base.h +++ b/Alc/backends/base.h @@ -45,9 +45,6 @@ struct ALCbackendVtable { void (*const Delete)(void*); }; -#define DECLARE_ALCBACKEND_VTABLE(T) \ -static const struct ALCbackendVtable T##_ALCbackend_vtable - #define DEFINE_ALCBACKEND_VTABLE(T) \ DECLARE_THUNK(T, ALCbackend, void, Destruct) \ DECLARE_THUNK1(T, ALCbackend, ALCenum, open, const ALCchar*) \ @@ -63,7 +60,7 @@ DECLARE_THUNK(T, ALCbackend, void, unlock) \ static void T##_ALCbackend_Delete(void *ptr) \ { T##_Delete(STATIC_UPCAST(T, ALCbackend, (ALCbackend*)ptr)); } \ \ -DECLARE_ALCBACKEND_VTABLE(T) = { \ +static const struct ALCbackendVtable T##_ALCbackend_vtable = { \ T##_ALCbackend_Destruct, \ \ T##_ALCbackend_open, \ diff --git a/Alc/backends/null.c b/Alc/backends/null.c index c5a4c15f..3f09c5d6 100644 --- a/Alc/backends/null.c +++ b/Alc/backends/null.c @@ -39,7 +39,6 @@ typedef struct ALCnullBackend { volatile int killNow; althrd_t thread; } ALCnullBackend; -DECLARE_ALCBACKEND_VTABLE(ALCnullBackend); static int ALCnullBackend_mixerProc(void *ptr); @@ -57,6 +56,8 @@ static DECLARE_FORWARD(ALCnullBackend, ALCbackend, void, lock) static DECLARE_FORWARD(ALCnullBackend, ALCbackend, void, unlock) DECLARE_DEFAULT_ALLOCATORS(ALCnullBackend) +DEFINE_ALCBACKEND_VTABLE(ALCnullBackend); + static const ALCchar nullDevice[] = "No Output"; @@ -161,8 +162,6 @@ static void ALCnullBackend_stop(ALCnullBackend *self) althrd_join(self->thread, &res); } -DEFINE_ALCBACKEND_VTABLE(ALCnullBackend); - typedef struct ALCnullBackendFactory { DERIVE_FROM_TYPE(ALCbackendFactory); diff --git a/Alc/backends/pulseaudio.c b/Alc/backends/pulseaudio.c index a90fb869..01c229f9 100644 --- a/Alc/backends/pulseaudio.c +++ b/Alc/backends/pulseaudio.c @@ -480,7 +480,6 @@ typedef struct ALCpulsePlayback { volatile ALboolean killNow; althrd_t thread; } ALCpulsePlayback; -DECLARE_ALCBACKEND_VTABLE(ALCpulsePlayback); static void ALCpulsePlayback_deviceCallback(pa_context *context, const pa_sink_info *info, int eol, void *pdata); static void ALCpulsePlayback_probeDevices(void); @@ -506,10 +505,13 @@ static ALCboolean ALCpulsePlayback_start(ALCpulsePlayback *self); static void ALCpulsePlayback_stop(ALCpulsePlayback *self); static DECLARE_FORWARD2(ALCpulsePlayback, ALCbackend, ALCenum, captureSamples, ALCvoid*, ALCuint) static DECLARE_FORWARD(ALCpulsePlayback, ALCbackend, ALCuint, availableSamples) +static ALint64 ALCpulsePlayback_getLatency(ALCpulsePlayback *self); static void ALCpulsePlayback_lock(ALCpulsePlayback *self); static void ALCpulsePlayback_unlock(ALCpulsePlayback *self); DECLARE_DEFAULT_ALLOCATORS(ALCpulsePlayback) +DEFINE_ALCBACKEND_VTABLE(ALCpulsePlayback); + static void ALCpulsePlayback_Construct(ALCpulsePlayback *self, ALCdevice *device) { @@ -1087,17 +1089,6 @@ static void ALCpulsePlayback_stop(ALCpulsePlayback *self) } -static void ALCpulsePlayback_lock(ALCpulsePlayback *self) -{ - pa_threaded_mainloop_lock(self->loop); -} - -static void ALCpulsePlayback_unlock(ALCpulsePlayback *self) -{ - pa_threaded_mainloop_unlock(self->loop); -} - - static ALint64 ALCpulsePlayback_getLatency(ALCpulsePlayback *self) { pa_usec_t latency = 0; @@ -1113,7 +1104,16 @@ static ALint64 ALCpulsePlayback_getLatency(ALCpulsePlayback *self) return (ALint64)minu64(latency, U64(0x7fffffffffffffff)/1000) * 1000; } -DEFINE_ALCBACKEND_VTABLE(ALCpulsePlayback); + +static void ALCpulsePlayback_lock(ALCpulsePlayback *self) +{ + pa_threaded_mainloop_lock(self->loop); +} + +static void ALCpulsePlayback_unlock(ALCpulsePlayback *self) +{ + pa_threaded_mainloop_unlock(self->loop); +} typedef struct ALCpulseCapture { @@ -1135,7 +1135,6 @@ typedef struct ALCpulseCapture { pa_stream *stream; pa_context *context; } ALCpulseCapture; -DECLARE_ALCBACKEND_VTABLE(ALCpulseCapture); static void ALCpulseCapture_deviceCallback(pa_context *context, const pa_source_info *info, int eol, void *pdata); static void ALCpulseCapture_probeDevices(void); @@ -1158,10 +1157,13 @@ static ALCboolean ALCpulseCapture_start(ALCpulseCapture *self); static void ALCpulseCapture_stop(ALCpulseCapture *self); static ALCenum ALCpulseCapture_captureSamples(ALCpulseCapture *self, ALCvoid *buffer, ALCuint samples); static ALCuint ALCpulseCapture_availableSamples(ALCpulseCapture *self); +static ALint64 ALCpulseCapture_getLatency(ALCpulseCapture *self); static void ALCpulseCapture_lock(ALCpulseCapture *self); static void ALCpulseCapture_unlock(ALCpulseCapture *self); DECLARE_DEFAULT_ALLOCATORS(ALCpulseCapture) +DEFINE_ALCBACKEND_VTABLE(ALCpulseCapture); + static void ALCpulseCapture_Construct(ALCpulseCapture *self, ALCdevice *device) { @@ -1570,17 +1572,6 @@ static ALCuint ALCpulseCapture_availableSamples(ALCpulseCapture *self) } -static void ALCpulseCapture_lock(ALCpulseCapture *self) -{ - pa_threaded_mainloop_lock(self->loop); -} - -static void ALCpulseCapture_unlock(ALCpulseCapture *self) -{ - pa_threaded_mainloop_unlock(self->loop); -} - - static ALint64 ALCpulseCapture_getLatency(ALCpulseCapture *self) { pa_usec_t latency = 0; @@ -1596,7 +1587,16 @@ static ALint64 ALCpulseCapture_getLatency(ALCpulseCapture *self) return (ALint64)minu64(latency, U64(0x7fffffffffffffff)/1000) * 1000; } -DEFINE_ALCBACKEND_VTABLE(ALCpulseCapture); + +static void ALCpulseCapture_lock(ALCpulseCapture *self) +{ + pa_threaded_mainloop_lock(self->loop); +} + +static void ALCpulseCapture_unlock(ALCpulseCapture *self) +{ + pa_threaded_mainloop_unlock(self->loop); +} typedef struct ALCpulseBackendFactory { @@ -1604,6 +1604,15 @@ typedef struct ALCpulseBackendFactory { } ALCpulseBackendFactory; #define ALCPULSEBACKENDFACTORY_INITIALIZER { { GET_VTABLE2(ALCpulseBackendFactory, ALCbackendFactory) } } +static ALCboolean ALCpulseBackendFactory_init(ALCpulseBackendFactory *self); +static void ALCpulseBackendFactory_deinit(ALCpulseBackendFactory *self); +static ALCboolean ALCpulseBackendFactory_querySupport(ALCpulseBackendFactory *self, ALCbackend_Type type); +static void ALCpulseBackendFactory_probe(ALCpulseBackendFactory *self, enum DevProbe type); +static ALCbackend* ALCpulseBackendFactory_createBackend(ALCpulseBackendFactory *self, ALCdevice *device, ALCbackend_Type type); + +DEFINE_ALCBACKENDFACTORY_VTABLE(ALCpulseBackendFactory); + + static ALCboolean ALCpulseBackendFactory_init(ALCpulseBackendFactory* UNUSED(self)) { ALCboolean ret = ALC_FALSE; @@ -1761,8 +1770,6 @@ static ALCbackend* ALCpulseBackendFactory_createBackend(ALCpulseBackendFactory* return NULL; } -DEFINE_ALCBACKENDFACTORY_VTABLE(ALCpulseBackendFactory); - #else /* PA_API_VERSION == 12 */ |