From a042dbf30524429b49adb63efda35f53054ae924 Mon Sep 17 00:00:00 2001 From: Chris Robinson Date: Sun, 28 Jan 2018 23:32:28 -0800 Subject: Call the backend close method in the destructor --- Alc/backends/alsa.c | 20 ++++++++++++++++++-- 1 file changed, 18 insertions(+), 2 deletions(-) (limited to 'Alc/backends/alsa.c') diff --git a/Alc/backends/alsa.c b/Alc/backends/alsa.c index fb5a4446..27d36560 100644 --- a/Alc/backends/alsa.c +++ b/Alc/backends/alsa.c @@ -446,7 +446,7 @@ static int ALCplaybackAlsa_mixerProc(void *ptr); static int ALCplaybackAlsa_mixerNoMMapProc(void *ptr); static void ALCplaybackAlsa_Construct(ALCplaybackAlsa *self, ALCdevice *device); -static DECLARE_FORWARD(ALCplaybackAlsa, ALCbackend, void, Destruct) +static void ALCplaybackAlsa_Destruct(ALCplaybackAlsa *self); static ALCenum ALCplaybackAlsa_open(ALCplaybackAlsa *self, const ALCchar *name); static void ALCplaybackAlsa_close(ALCplaybackAlsa *self); static ALCboolean ALCplaybackAlsa_reset(ALCplaybackAlsa *self); @@ -468,6 +468,12 @@ static void ALCplaybackAlsa_Construct(ALCplaybackAlsa *self, ALCdevice *device) SET_VTABLE2(ALCplaybackAlsa, ALCbackend, self); } +void ALCplaybackAlsa_Destruct(ALCplaybackAlsa *self) +{ + ALCplaybackAlsa_close(self); + ALCbackend_Destruct(STATIC_CAST(ALCbackend, self)); +} + static int ALCplaybackAlsa_mixerProc(void *ptr) { @@ -705,6 +711,7 @@ static ALCenum ALCplaybackAlsa_open(ALCplaybackAlsa *self, const ALCchar *name) static void ALCplaybackAlsa_close(ALCplaybackAlsa *self) { snd_pcm_close(self->pcmHandle); + self->pcmHandle = NULL; } static ALCboolean ALCplaybackAlsa_reset(ALCplaybackAlsa *self) @@ -973,7 +980,7 @@ typedef struct ALCcaptureAlsa { } ALCcaptureAlsa; static void ALCcaptureAlsa_Construct(ALCcaptureAlsa *self, ALCdevice *device); -static DECLARE_FORWARD(ALCcaptureAlsa, ALCbackend, void, Destruct) +static void ALCcaptureAlsa_Destruct(ALCcaptureAlsa *self); static ALCenum ALCcaptureAlsa_open(ALCcaptureAlsa *self, const ALCchar *name); static void ALCcaptureAlsa_close(ALCcaptureAlsa *self); static DECLARE_FORWARD(ALCcaptureAlsa, ALCbackend, ALCboolean, reset) @@ -995,6 +1002,12 @@ static void ALCcaptureAlsa_Construct(ALCcaptureAlsa *self, ALCdevice *device) SET_VTABLE2(ALCcaptureAlsa, ALCbackend, self); } +void ALCcaptureAlsa_Destruct(ALCcaptureAlsa *self) +{ + ALCcaptureAlsa_close(self); + ALCbackend_Destruct(STATIC_CAST(ALCbackend, self)); +} + static ALCenum ALCcaptureAlsa_open(ALCcaptureAlsa *self, const ALCchar *name) { @@ -1129,7 +1142,10 @@ error2: static void ALCcaptureAlsa_close(ALCcaptureAlsa *self) { snd_pcm_close(self->pcmHandle); + self->pcmHandle = NULL; + ll_ringbuffer_free(self->ring); + self->ring = NULL; al_free(self->buffer); self->buffer = NULL; -- cgit v1.2.3