diff options
author | Chris Robinson <[email protected]> | 2014-03-22 00:28:55 -0700 |
---|---|---|
committer | Chris Robinson <[email protected]> | 2014-03-22 00:28:55 -0700 |
commit | d8bfd12d313372830f0e0b34fafcaa244395cf3c (patch) | |
tree | 14f4a3fe6e30380d5aded77969c59bf74fc8ca94 | |
parent | 0a030c2bd91a0f7c94ce310ea4b03c6a923463b9 (diff) |
Use a void* for the backend Delete method param
-rw-r--r-- | Alc/backends/alsa.c | 19 | ||||
-rw-r--r-- | Alc/backends/base.c | 18 | ||||
-rw-r--r-- | Alc/backends/base.h | 5 | ||||
-rw-r--r-- | Alc/backends/loopback.c | 11 | ||||
-rw-r--r-- | Alc/backends/null.c | 11 | ||||
-rw-r--r-- | Alc/backends/oss.c | 21 | ||||
-rw-r--r-- | Alc/backends/pulseaudio.c | 20 |
7 files changed, 32 insertions, 73 deletions
diff --git a/Alc/backends/alsa.c b/Alc/backends/alsa.c index 874b31c3..51965cec 100644 --- a/Alc/backends/alsa.c +++ b/Alc/backends/alsa.c @@ -408,6 +408,7 @@ static DECLARE_FORWARD2(ALCplaybackAlsa, ALCbackend, ALCenum, captureSamples, vo static DECLARE_FORWARD(ALCplaybackAlsa, ALCbackend, ALCuint, availableSamples) static DECLARE_FORWARD(ALCplaybackAlsa, ALCbackend, void, lock) static DECLARE_FORWARD(ALCplaybackAlsa, ALCbackend, void, unlock) +DECLARE_DEFAULT_ALLOCATORS(ALCplaybackAlsa) static void ALCplaybackAlsa_Construct(ALCplaybackAlsa *self, ALCdevice *device) @@ -888,12 +889,6 @@ static ALint64 ALCplaybackAlsa_getLatency(ALCplaybackAlsa *self) return maxi64((ALint64)delay*1000000000/device->Frequency, 0); } - -static void ALCplaybackAlsa_Delete(ALCplaybackAlsa *self) -{ - free(self); -} - DEFINE_ALCBACKEND_VTABLE(ALCplaybackAlsa); @@ -923,6 +918,7 @@ static ALCenum ALCcaptureAlsa_captureSamples(ALCcaptureAlsa *self, ALCvoid *buff static ALCuint ALCcaptureAlsa_availableSamples(ALCcaptureAlsa *self); static DECLARE_FORWARD(ALCcaptureAlsa, ALCbackend, void, lock) static DECLARE_FORWARD(ALCcaptureAlsa, ALCbackend, void, unlock) +DECLARE_DEFAULT_ALLOCATORS(ALCcaptureAlsa) static void ALCcaptureAlsa_Construct(ALCcaptureAlsa *self, ALCdevice *device) @@ -1287,11 +1283,6 @@ static ALint64 ALCcaptureAlsa_getLatency(ALCcaptureAlsa *self) return maxi64((ALint64)delay*1000000000/device->Frequency, 0); } -static void ALCcaptureAlsa_Delete(ALCcaptureAlsa *self) -{ - free(self); -} - DEFINE_ALCBACKEND_VTABLE(ALCcaptureAlsa); @@ -1386,8 +1377,9 @@ static ALCbackend* ALCalsaBackendFactory_createBackend(ALCalsaBackendFactory* UN { ALCplaybackAlsa *backend; - backend = calloc(1, sizeof(*backend)); + backend = ALCplaybackAlsa_New(sizeof(*backend)); if(!backend) return NULL; + memset(backend, 0, sizeof(*backend)); ALCplaybackAlsa_Construct(backend, device); @@ -1397,8 +1389,9 @@ static ALCbackend* ALCalsaBackendFactory_createBackend(ALCalsaBackendFactory* UN { ALCcaptureAlsa *backend; - backend = calloc(1, sizeof(*backend)); + backend = ALCcaptureAlsa_New(sizeof(*backend)); if(!backend) return NULL; + memset(backend, 0, sizeof(*backend)); ALCcaptureAlsa_Construct(backend, device); diff --git a/Alc/backends/base.c b/Alc/backends/base.c index d841e8d6..8e59abdf 100644 --- a/Alc/backends/base.c +++ b/Alc/backends/base.c @@ -76,7 +76,7 @@ static DECLARE_FORWARD(PlaybackWrapper, ALCbackend, ALCuint, availableSamples) static ALint64 PlaybackWrapper_getLatency(PlaybackWrapper *self); static DECLARE_FORWARD(PlaybackWrapper, ALCbackend, void, lock) static DECLARE_FORWARD(PlaybackWrapper, ALCbackend, void, unlock) -static void PlaybackWrapper_Delete(PlaybackWrapper *self); +DECLARE_DEFAULT_ALLOCATORS(PlaybackWrapper) DEFINE_ALCBACKEND_VTABLE(PlaybackWrapper); static void PlaybackWrapper_Construct(PlaybackWrapper *self, ALCdevice *device, const BackendFuncs *funcs) @@ -123,11 +123,6 @@ static ALint64 PlaybackWrapper_getLatency(PlaybackWrapper *self) return self->Funcs->GetLatency(device); } -static void PlaybackWrapper_Delete(PlaybackWrapper *self) -{ - free(self); -} - typedef struct CaptureWrapper { DERIVE_FROM_TYPE(ALCbackend); @@ -147,7 +142,7 @@ static ALCuint CaptureWrapper_availableSamples(CaptureWrapper *self); static ALint64 CaptureWrapper_getLatency(CaptureWrapper *self); static DECLARE_FORWARD(CaptureWrapper, ALCbackend, void, lock) static DECLARE_FORWARD(CaptureWrapper, ALCbackend, void, unlock) -static void CaptureWrapper_Delete(CaptureWrapper *self); +DECLARE_DEFAULT_ALLOCATORS(CaptureWrapper) DEFINE_ALCBACKEND_VTABLE(CaptureWrapper); @@ -202,11 +197,6 @@ static ALint64 CaptureWrapper_getLatency(CaptureWrapper *self) return self->Funcs->GetLatency(device); } -static void CaptureWrapper_Delete(CaptureWrapper *self) -{ - free(self); -} - ALCbackend *create_backend_wrapper(ALCdevice *device, const BackendFuncs *funcs, ALCbackend_Type type) { @@ -214,7 +204,7 @@ ALCbackend *create_backend_wrapper(ALCdevice *device, const BackendFuncs *funcs, { PlaybackWrapper *backend; - backend = malloc(sizeof(*backend)); + backend = PlaybackWrapper_New(sizeof(*backend)); if(!backend) return NULL; PlaybackWrapper_Construct(backend, device, funcs); @@ -226,7 +216,7 @@ ALCbackend *create_backend_wrapper(ALCdevice *device, const BackendFuncs *funcs, { CaptureWrapper *backend; - backend = malloc(sizeof(*backend)); + backend = CaptureWrapper_New(sizeof(*backend)); if(!backend) return NULL; CaptureWrapper_Construct(backend, device, funcs); diff --git a/Alc/backends/base.h b/Alc/backends/base.h index 003a3692..de5809ca 100644 --- a/Alc/backends/base.h +++ b/Alc/backends/base.h @@ -42,7 +42,7 @@ struct ALCbackendVtable { void (*const lock)(ALCbackend*); void (*const unlock)(ALCbackend*); - void (*const Delete)(ALCbackend*); + void (*const Delete)(void*); }; #define DECLARE_ALCBACKEND_VTABLE(T) \ @@ -60,7 +60,8 @@ DECLARE_THUNK(T, ALCbackend, ALCuint, availableSamples) \ DECLARE_THUNK(T, ALCbackend, ALint64, getLatency) \ DECLARE_THUNK(T, ALCbackend, void, lock) \ DECLARE_THUNK(T, ALCbackend, void, unlock) \ -DECLARE_THUNK(T, ALCbackend, void, Delete) \ +static void T##_ALCbackend_Delete(void *ptr) \ +{ T##_Delete(STATIC_UPCAST(T, ALCbackend, ptr)); } \ \ DECLARE_ALCBACKEND_VTABLE(T) = { \ T##_ALCbackend_Destruct, \ diff --git a/Alc/backends/loopback.c b/Alc/backends/loopback.c index cd5b1a1e..053cfce4 100644 --- a/Alc/backends/loopback.c +++ b/Alc/backends/loopback.c @@ -44,7 +44,7 @@ static DECLARE_FORWARD(ALCloopback, ALCbackend, ALCuint, availableSamples) static DECLARE_FORWARD(ALCloopback, ALCbackend, ALint64, getLatency) static DECLARE_FORWARD(ALCloopback, ALCbackend, void, lock) static DECLARE_FORWARD(ALCloopback, ALCbackend, void, unlock) -static void ALCloopback_Delete(ALCloopback *self); +DECLARE_DEFAULT_ALLOCATORS(ALCloopback) DEFINE_ALCBACKEND_VTABLE(ALCloopback); @@ -83,12 +83,6 @@ static void ALCloopback_stop(ALCloopback* UNUSED(self)) } -static void ALCloopback_Delete(ALCloopback *self) -{ - free(self); -} - - typedef struct ALCloopbackFactory { DERIVE_FROM_TYPE(ALCbackendFactory); } ALCloopbackFactory; @@ -131,8 +125,9 @@ static ALCbackend* ALCloopbackFactory_createBackend(ALCloopbackFactory* UNUSED(s assert(type == ALCbackend_Loopback); - backend = calloc(1, sizeof(*backend)); + backend = ALCloopback_New(sizeof(*backend)); if(!backend) return NULL; + memset(backend, 0, sizeof(*backend)); ALCloopback_Construct(backend, device); diff --git a/Alc/backends/null.c b/Alc/backends/null.c index a7056369..59299dff 100644 --- a/Alc/backends/null.c +++ b/Alc/backends/null.c @@ -55,6 +55,8 @@ static DECLARE_FORWARD(ALCnullBackend, ALCbackend, ALCuint, availableSamples) static DECLARE_FORWARD(ALCnullBackend, ALCbackend, ALint64, getLatency) static DECLARE_FORWARD(ALCnullBackend, ALCbackend, void, lock) static DECLARE_FORWARD(ALCnullBackend, ALCbackend, void, unlock) +DECLARE_DEFAULT_ALLOCATORS(ALCnullBackend) + static const ALCchar nullDevice[] = "No Output"; @@ -152,12 +154,6 @@ static void ALCnullBackend_stop(ALCnullBackend *self) self->killNow = 0; } - -static void ALCnullBackend_Delete(ALCnullBackend *self) -{ - free(self); -} - DEFINE_ALCBACKEND_VTABLE(ALCnullBackend); @@ -213,8 +209,9 @@ static ALCbackend* ALCnullBackendFactory_createBackend(ALCnullBackendFactory* UN assert(type == ALCbackend_Playback); - backend = calloc(1, sizeof(*backend)); + backend = ALCnullBackend_New(sizeof(*backend)); if(!backend) return NULL; + memset(backend, 0, sizeof(*backend)); ALCnullBackend_Construct(backend, device); diff --git a/Alc/backends/oss.c b/Alc/backends/oss.c index c79793c2..54c487a4 100644 --- a/Alc/backends/oss.c +++ b/Alc/backends/oss.c @@ -95,7 +95,7 @@ static DECLARE_FORWARD(ALCplaybackOSS, ALCbackend, ALCuint, availableSamples) static DECLARE_FORWARD(ALCplaybackOSS, ALCbackend, ALint64, getLatency) static DECLARE_FORWARD(ALCplaybackOSS, ALCbackend, void, lock) static DECLARE_FORWARD(ALCplaybackOSS, ALCbackend, void, unlock) -static void ALCplaybackOSS_Delete(ALCplaybackOSS *self); +DECLARE_DEFAULT_ALLOCATORS(ALCplaybackOSS) DEFINE_ALCBACKEND_VTABLE(ALCplaybackOSS); @@ -302,11 +302,6 @@ static void ALCplaybackOSS_stop(ALCplaybackOSS *self) self->mix_data = NULL; } -static void ALCplaybackOSS_Delete(ALCplaybackOSS *self) -{ - free(self); -} - typedef struct ALCcaptureOSS { DERIVE_FROM_TYPE(ALCbackend); @@ -337,7 +332,7 @@ static ALCuint ALCcaptureOSS_availableSamples(ALCcaptureOSS *self); static DECLARE_FORWARD(ALCcaptureOSS, ALCbackend, ALint64, getLatency) static DECLARE_FORWARD(ALCcaptureOSS, ALCbackend, void, lock) static DECLARE_FORWARD(ALCcaptureOSS, ALCbackend, void, unlock) -static void ALCcaptureOSS_Delete(ALCcaptureOSS *self); +DECLARE_DEFAULT_ALLOCATORS(ALCcaptureOSS) DEFINE_ALCBACKEND_VTABLE(ALCcaptureOSS); @@ -539,12 +534,6 @@ static ALCuint ALCcaptureOSS_availableSamples(ALCcaptureOSS *self) return RingBufferSize(self->ring); } -void ALCcaptureOSS_Delete(ALCcaptureOSS *self) -{ - free(self); -} - - typedef struct ALCossBackendFactory { DERIVE_FROM_TYPE(ALCbackendFactory); @@ -615,8 +604,9 @@ ALCbackend* ALCossBackendFactory_createBackend(ALCossBackendFactory* UNUSED(self { ALCplaybackOSS *backend; - backend = calloc(1, sizeof(*backend)); + backend = ALCplaybackOSS_New(sizeof(*backend)); if(!backend) return NULL; + memset(backend, 0, sizeof(*backend)); ALCplaybackOSS_Construct(backend, device); @@ -626,8 +616,9 @@ ALCbackend* ALCossBackendFactory_createBackend(ALCossBackendFactory* UNUSED(self { ALCcaptureOSS *backend; - backend = calloc(1, sizeof(*backend)); + backend = ALCcaptureOSS_New(sizeof(*backend)); if(!backend) return NULL; + memset(backend, 0, sizeof(*backend)); ALCcaptureOSS_Construct(backend, device); diff --git a/Alc/backends/pulseaudio.c b/Alc/backends/pulseaudio.c index 1892e733..d2d5c9aa 100644 --- a/Alc/backends/pulseaudio.c +++ b/Alc/backends/pulseaudio.c @@ -509,6 +509,7 @@ static DECLARE_FORWARD2(ALCpulsePlayback, ALCbackend, ALCenum, captureSamples, A static DECLARE_FORWARD(ALCpulsePlayback, ALCbackend, ALCuint, availableSamples) static void ALCpulsePlayback_lock(ALCpulsePlayback *self); static void ALCpulsePlayback_unlock(ALCpulsePlayback *self); +DECLARE_DEFAULT_ALLOCATORS(ALCpulsePlayback) static void ALCpulsePlayback_Construct(ALCpulsePlayback *self, ALCdevice *device) @@ -1106,12 +1107,6 @@ static ALint64 ALCpulsePlayback_getLatency(ALCpulsePlayback *self) return (ALint64)minu64(latency, U64(0x7fffffffffffffff)/1000) * 1000; } - -static void ALCpulsePlayback_Delete(ALCpulsePlayback *self) -{ - free(self); -} - DEFINE_ALCBACKEND_VTABLE(ALCpulsePlayback); @@ -1159,6 +1154,7 @@ static ALCenum ALCpulseCapture_captureSamples(ALCpulseCapture *self, ALCvoid *bu static ALCuint ALCpulseCapture_availableSamples(ALCpulseCapture *self); static void ALCpulseCapture_lock(ALCpulseCapture *self); static void ALCpulseCapture_unlock(ALCpulseCapture *self); +DECLARE_DEFAULT_ALLOCATORS(ALCpulseCapture) static void ALCpulseCapture_Construct(ALCpulseCapture *self, ALCdevice *device) @@ -1585,12 +1581,6 @@ static ALint64 ALCpulseCapture_getLatency(ALCpulseCapture *self) return (ALint64)minu64(latency, U64(0x7fffffffffffffff)/1000) * 1000; } - -static void ALCpulseCapture_Delete(ALCpulseCapture *self) -{ - free(self); -} - DEFINE_ALCBACKEND_VTABLE(ALCpulseCapture); @@ -1725,8 +1715,9 @@ static ALCbackend* ALCpulseBackendFactory_createBackend(ALCpulseBackendFactory* { ALCpulsePlayback *backend; - backend = calloc(1, sizeof(*backend)); + backend = ALCpulsePlayback_New(sizeof(*backend)); if(!backend) return NULL; + memset(backend, 0, sizeof(*backend)); ALCpulsePlayback_Construct(backend, device); @@ -1736,8 +1727,9 @@ static ALCbackend* ALCpulseBackendFactory_createBackend(ALCpulseBackendFactory* { ALCpulseCapture *backend; - backend = calloc(1, sizeof(*backend)); + backend = ALCpulseCapture_New(sizeof(*backend)); if(!backend) return NULL; + memset(backend, 0, sizeof(*backend)); ALCpulseCapture_Construct(backend, device); |