aboutsummaryrefslogtreecommitdiffstats
path: root/Alc/backends/alsa.c
diff options
context:
space:
mode:
authorChris Robinson <[email protected]>2018-01-28 23:32:28 -0800
committerChris Robinson <[email protected]>2018-01-28 23:32:28 -0800
commita042dbf30524429b49adb63efda35f53054ae924 (patch)
tree6e905d8173f2db6dd41b2e9cb471a9c860c54279 /Alc/backends/alsa.c
parent328fd7329d1ae1554452d2d4b0384173c0f47079 (diff)
Call the backend close method in the destructor
Diffstat (limited to 'Alc/backends/alsa.c')
-rw-r--r--Alc/backends/alsa.c20
1 files changed, 18 insertions, 2 deletions
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;