aboutsummaryrefslogtreecommitdiffstats
path: root/Alc/backends/alsa.c
diff options
context:
space:
mode:
authorChris Robinson <[email protected]>2018-01-29 01:00:53 -0800
committerChris Robinson <[email protected]>2018-01-29 01:00:53 -0800
commite7217760f39071c7aec542c8f3fbaad21c71924a (patch)
tree903f585eaa34750b2f7c4a65619c1cf4475bb8a0 /Alc/backends/alsa.c
parenta042dbf30524429b49adb63efda35f53054ae924 (diff)
Don't bother with an explicit stop backend method
Diffstat (limited to 'Alc/backends/alsa.c')
-rw-r--r--Alc/backends/alsa.c42
1 files changed, 20 insertions, 22 deletions
diff --git a/Alc/backends/alsa.c b/Alc/backends/alsa.c
index 27d36560..915d31d3 100644
--- a/Alc/backends/alsa.c
+++ b/Alc/backends/alsa.c
@@ -448,7 +448,6 @@ static int ALCplaybackAlsa_mixerNoMMapProc(void *ptr);
static void ALCplaybackAlsa_Construct(ALCplaybackAlsa *self, ALCdevice *device);
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);
static ALCboolean ALCplaybackAlsa_start(ALCplaybackAlsa *self);
static void ALCplaybackAlsa_stop(ALCplaybackAlsa *self);
@@ -466,11 +465,16 @@ static void ALCplaybackAlsa_Construct(ALCplaybackAlsa *self, ALCdevice *device)
{
ALCbackend_Construct(STATIC_CAST(ALCbackend, self), device);
SET_VTABLE2(ALCplaybackAlsa, ALCbackend, self);
+
+ self->pcmHandle = NULL;
+ self->buffer = NULL;
}
void ALCplaybackAlsa_Destruct(ALCplaybackAlsa *self)
{
- ALCplaybackAlsa_close(self);
+ if(self->pcmHandle)
+ snd_pcm_close(self->pcmHandle);
+ self->pcmHandle = NULL;
ALCbackend_Destruct(STATIC_CAST(ALCbackend, self));
}
@@ -708,12 +712,6 @@ static ALCenum ALCplaybackAlsa_open(ALCplaybackAlsa *self, const ALCchar *name)
return ALC_NO_ERROR;
}
-static void ALCplaybackAlsa_close(ALCplaybackAlsa *self)
-{
- snd_pcm_close(self->pcmHandle);
- self->pcmHandle = NULL;
-}
-
static ALCboolean ALCplaybackAlsa_reset(ALCplaybackAlsa *self)
{
ALCdevice *device = STATIC_CAST(ALCbackend, self)->mDevice;
@@ -982,7 +980,6 @@ typedef struct ALCcaptureAlsa {
static void ALCcaptureAlsa_Construct(ALCcaptureAlsa *self, ALCdevice *device);
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)
static ALCboolean ALCcaptureAlsa_start(ALCcaptureAlsa *self);
static void ALCcaptureAlsa_stop(ALCcaptureAlsa *self);
@@ -1000,11 +997,24 @@ static void ALCcaptureAlsa_Construct(ALCcaptureAlsa *self, ALCdevice *device)
{
ALCbackend_Construct(STATIC_CAST(ALCbackend, self), device);
SET_VTABLE2(ALCcaptureAlsa, ALCbackend, self);
+
+ self->pcmHandle = NULL;
+ self->buffer = NULL;
+ self->ring = NULL;
}
void ALCcaptureAlsa_Destruct(ALCcaptureAlsa *self)
{
- ALCcaptureAlsa_close(self);
+ if(self->pcmHandle)
+ snd_pcm_close(self->pcmHandle);
+ self->pcmHandle = NULL;
+
+ al_free(self->buffer);
+ self->buffer = NULL;
+
+ ll_ringbuffer_free(self->ring);
+ self->ring = NULL;
+
ALCbackend_Destruct(STATIC_CAST(ALCbackend, self));
}
@@ -1139,18 +1149,6 @@ error2:
return ALC_INVALID_VALUE;
}
-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;
-}
-
static ALCboolean ALCcaptureAlsa_start(ALCcaptureAlsa *self)
{
int err = snd_pcm_start(self->pcmHandle);