aboutsummaryrefslogtreecommitdiffstats
path: root/Alc/backends
diff options
context:
space:
mode:
Diffstat (limited to 'Alc/backends')
-rw-r--r--Alc/backends/alsa.c20
-rw-r--r--Alc/backends/coreaudio.c1
-rw-r--r--Alc/backends/dsound.c25
-rw-r--r--Alc/backends/mmdevapi.c10
-rw-r--r--Alc/backends/opensl.c35
-rw-r--r--Alc/backends/oss.c22
-rw-r--r--Alc/backends/portaudio.c18
-rw-r--r--Alc/backends/pulseaudio.c28
-rw-r--r--Alc/backends/qsa.c22
-rw-r--r--Alc/backends/sndio.c7
-rw-r--r--Alc/backends/solaris.c7
-rw-r--r--Alc/backends/wave.c7
-rw-r--r--Alc/backends/winmm.c2
13 files changed, 125 insertions, 79 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;
diff --git a/Alc/backends/coreaudio.c b/Alc/backends/coreaudio.c
index 2ee3fa54..bdd9b678 100644
--- a/Alc/backends/coreaudio.c
+++ b/Alc/backends/coreaudio.c
@@ -123,6 +123,7 @@ static void ALCcoreAudioPlayback_Construct(ALCcoreAudioPlayback *self, ALCdevice
static void ALCcoreAudioPlayback_Destruct(ALCcoreAudioPlayback *self)
{
+ ALCcoreAudioPlayback_close(self);
ALCbackend_Destruct(STATIC_CAST(ALCbackend, self));
}
diff --git a/Alc/backends/dsound.c b/Alc/backends/dsound.c
index 8a0a30cb..7760e39d 100644
--- a/Alc/backends/dsound.c
+++ b/Alc/backends/dsound.c
@@ -192,7 +192,7 @@ typedef struct ALCdsoundPlayback {
static int ALCdsoundPlayback_mixerProc(void *ptr);
static void ALCdsoundPlayback_Construct(ALCdsoundPlayback *self, ALCdevice *device);
-static DECLARE_FORWARD(ALCdsoundPlayback, ALCbackend, void, Destruct)
+static void ALCdsoundPlayback_Destruct(ALCdsoundPlayback *self);
static ALCenum ALCdsoundPlayback_open(ALCdsoundPlayback *self, const ALCchar *name);
static void ALCdsoundPlayback_close(ALCdsoundPlayback *self);
static ALCboolean ALCdsoundPlayback_reset(ALCdsoundPlayback *self);
@@ -214,6 +214,12 @@ static void ALCdsoundPlayback_Construct(ALCdsoundPlayback *self, ALCdevice *devi
SET_VTABLE2(ALCdsoundPlayback, ALCbackend, self);
}
+static void ALCdsoundPlayback_Destruct(ALCdsoundPlayback *self)
+{
+ ALCdsoundPlayback_close(self);
+ ALCbackend_Destruct(STATIC_CAST(ALCbackend, self));
+}
+
FORCE_ALIGN static int ALCdsoundPlayback_mixerProc(void *ptr)
{
@@ -399,9 +405,11 @@ static void ALCdsoundPlayback_close(ALCdsoundPlayback *self)
IDirectSoundBuffer_Release(self->PrimaryBuffer);
self->PrimaryBuffer = NULL;
- IDirectSound_Release(self->DS);
+ if(self->DS)
+ IDirectSound_Release(self->DS);
self->DS = NULL;
- CloseHandle(self->NotifyEvent);
+ if(self->NotifyEvent)
+ CloseHandle(self->NotifyEvent);
self->NotifyEvent = NULL;
}
@@ -661,7 +669,7 @@ typedef struct ALCdsoundCapture {
} ALCdsoundCapture;
static void ALCdsoundCapture_Construct(ALCdsoundCapture *self, ALCdevice *device);
-static DECLARE_FORWARD(ALCdsoundCapture, ALCbackend, void, Destruct)
+static void ALCdsoundCapture_Destruct(ALCdsoundCapture *self);
static ALCenum ALCdsoundCapture_open(ALCdsoundCapture *self, const ALCchar *name);
static void ALCdsoundCapture_close(ALCdsoundCapture *self);
static DECLARE_FORWARD(ALCdsoundCapture, ALCbackend, ALCboolean, reset)
@@ -682,6 +690,12 @@ static void ALCdsoundCapture_Construct(ALCdsoundCapture *self, ALCdevice *device
SET_VTABLE2(ALCdsoundCapture, ALCbackend, self);
}
+static void ALCdsoundCapture_Destruct(ALCdsoundCapture *self)
+{
+ ALCdsoundCapture_close(self);
+ ALCbackend_Destruct(STATIC_CAST(ALCbackend, self));
+}
+
static ALCenum ALCdsoundCapture_open(ALCdsoundCapture *self, const ALCchar *deviceName)
{
@@ -867,7 +881,8 @@ static void ALCdsoundCapture_close(ALCdsoundCapture *self)
self->DSCbuffer = NULL;
}
- IDirectSoundCapture_Release(self->DSC);
+ if(self->DSC)
+ IDirectSoundCapture_Release(self->DSC);
self->DSC = NULL;
}
diff --git a/Alc/backends/mmdevapi.c b/Alc/backends/mmdevapi.c
index 55d8ec54..899f73d4 100644
--- a/Alc/backends/mmdevapi.c
+++ b/Alc/backends/mmdevapi.c
@@ -587,6 +587,8 @@ static void ALCmmdevPlayback_Construct(ALCmmdevPlayback *self, ALCdevice *device
static void ALCmmdevPlayback_Destruct(ALCmmdevPlayback *self)
{
+ ALCmmdevPlayback_close(self);
+
if(self->NotifyEvent != NULL)
CloseHandle(self->NotifyEvent);
self->NotifyEvent = NULL;
@@ -840,6 +842,9 @@ static void ALCmmdevPlayback_close(ALCmmdevPlayback *self)
{
ThreadRequest req = { self->MsgEvent, 0 };
+ if(!req.FinishedEvt)
+ return;
+
if(PostThreadMessage(ThreadID, WM_USER_CloseDevice, (WPARAM)&req, (LPARAM)STATIC_CAST(ALCmmdevProxy, self)))
(void)WaitForResponse(&req);
@@ -1287,6 +1292,8 @@ static void ALCmmdevCapture_Construct(ALCmmdevCapture *self, ALCdevice *device)
static void ALCmmdevCapture_Destruct(ALCmmdevCapture *self)
{
+ ALCmmdevCapture_close(self);
+
ll_ringbuffer_free(self->Ring);
self->Ring = NULL;
@@ -1573,6 +1580,9 @@ static void ALCmmdevCapture_close(ALCmmdevCapture *self)
{
ThreadRequest req = { self->MsgEvent, 0 };
+ if(!req.FinishedEvt)
+ return;
+
if(PostThreadMessage(ThreadID, WM_USER_CloseDevice, (WPARAM)&req, (LPARAM)STATIC_CAST(ALCmmdevProxy, self)))
(void)WaitForResponse(&req);
diff --git a/Alc/backends/opensl.c b/Alc/backends/opensl.c
index 4ec003d8..c1283111 100644
--- a/Alc/backends/opensl.c
+++ b/Alc/backends/opensl.c
@@ -194,21 +194,7 @@ static void ALCopenslPlayback_Construct(ALCopenslPlayback *self, ALCdevice *devi
static void ALCopenslPlayback_Destruct(ALCopenslPlayback* self)
{
- if(self->mBufferQueueObj != NULL)
- VCALL0(self->mBufferQueueObj,Destroy)();
- self->mBufferQueueObj = NULL;
-
- if(self->mOutputMix != NULL)
- VCALL0(self->mOutputMix,Destroy)();
- self->mOutputMix = NULL;
-
- if(self->mEngineObj != NULL)
- VCALL0(self->mEngineObj,Destroy)();
- self->mEngineObj = NULL;
- self->mEngine = NULL;
-
- ll_ringbuffer_free(self->mRing);
- self->mRing = NULL;
+ ALCopenslPlayback_close(self);
alcnd_destroy(&self->mCond);
@@ -409,10 +395,12 @@ static void ALCopenslPlayback_close(ALCopenslPlayback *self)
VCALL0(self->mBufferQueueObj,Destroy)();
self->mBufferQueueObj = NULL;
- VCALL0(self->mOutputMix,Destroy)();
+ if(self->mOutputMix)
+ VCALL0(self->mOutputMix,Destroy)();
self->mOutputMix = NULL;
- VCALL0(self->mEngineObj,Destroy)();
+ if(self->mEngineObj)
+ VCALL0(self->mEngineObj,Destroy)();
self->mEngineObj = NULL;
self->mEngine = NULL;
}
@@ -761,18 +749,7 @@ static void ALCopenslCapture_Construct(ALCopenslCapture *self, ALCdevice *device
static void ALCopenslCapture_Destruct(ALCopenslCapture *self)
{
- ll_ringbuffer_free(self->mRing);
- self->mRing = NULL;
-
- if(self->mRecordObj != NULL)
- VCALL0(self->mRecordObj,Destroy)();
- self->mRecordObj = NULL;
-
- if(self->mEngineObj != NULL)
- VCALL0(self->mEngineObj,Destroy)();
- self->mEngineObj = NULL;
- self->mEngine = NULL;
-
+ ALCopenslCapture_close(self);
ALCbackend_Destruct(STATIC_CAST(ALCbackend, self));
}
diff --git a/Alc/backends/oss.c b/Alc/backends/oss.c
index 2ff7c72b..e88e5ff3 100644
--- a/Alc/backends/oss.c
+++ b/Alc/backends/oss.c
@@ -252,7 +252,7 @@ typedef struct ALCplaybackOSS {
static int ALCplaybackOSS_mixerProc(void *ptr);
static void ALCplaybackOSS_Construct(ALCplaybackOSS *self, ALCdevice *device);
-static DECLARE_FORWARD(ALCplaybackOSS, ALCbackend, void, Destruct)
+static void ALCplaybackOSS_Destruct(ALCplaybackOSS *self);
static ALCenum ALCplaybackOSS_open(ALCplaybackOSS *self, const ALCchar *name);
static void ALCplaybackOSS_close(ALCplaybackOSS *self);
static ALCboolean ALCplaybackOSS_reset(ALCplaybackOSS *self);
@@ -342,6 +342,12 @@ static void ALCplaybackOSS_Construct(ALCplaybackOSS *self, ALCdevice *device)
ATOMIC_INIT(&self->killNow, AL_FALSE);
}
+static void ALCplaybackOSS_Destruct(ALCplaybackOSS *self)
+{
+ ALCplaybackOSS_close(self);
+ ALCbackend_Destruct(STATIC_CAST(ALCbackend, self));
+}
+
static ALCenum ALCplaybackOSS_open(ALCplaybackOSS *self, const ALCchar *name)
{
struct oss_device *dev = &oss_playback;
@@ -383,7 +389,8 @@ static ALCenum ALCplaybackOSS_open(ALCplaybackOSS *self, const ALCchar *name)
static void ALCplaybackOSS_close(ALCplaybackOSS *self)
{
- close(self->fd);
+ if(self->fd != -1)
+ close(self->fd);
self->fd = -1;
}
@@ -519,7 +526,7 @@ typedef struct ALCcaptureOSS {
static int ALCcaptureOSS_recordProc(void *ptr);
static void ALCcaptureOSS_Construct(ALCcaptureOSS *self, ALCdevice *device);
-static DECLARE_FORWARD(ALCcaptureOSS, ALCbackend, void, Destruct)
+static void ALCcaptureOSS_Destruct(ALCcaptureOSS *self);
static ALCenum ALCcaptureOSS_open(ALCcaptureOSS *self, const ALCchar *name);
static void ALCcaptureOSS_close(ALCcaptureOSS *self);
static DECLARE_FORWARD(ALCcaptureOSS, ALCbackend, ALCboolean, reset)
@@ -601,6 +608,12 @@ static void ALCcaptureOSS_Construct(ALCcaptureOSS *self, ALCdevice *device)
ATOMIC_INIT(&self->killNow, AL_FALSE);
}
+static void ALCcaptureOSS_Destruct(ALCcaptureOSS *self)
+{
+ ALCcaptureOSS_close(self);
+ ALCbackend_Destruct(STATIC_CAST(ALCbackend, self));
+}
+
static ALCenum ALCcaptureOSS_open(ALCcaptureOSS *self, const ALCchar *name)
{
ALCdevice *device = STATIC_CAST(ALCbackend, self)->mDevice;
@@ -728,7 +741,8 @@ static ALCenum ALCcaptureOSS_open(ALCcaptureOSS *self, const ALCchar *name)
static void ALCcaptureOSS_close(ALCcaptureOSS *self)
{
- close(self->fd);
+ if(self->fd != -1)
+ close(self->fd);
self->fd = -1;
ll_ringbuffer_free(self->ring);
diff --git a/Alc/backends/portaudio.c b/Alc/backends/portaudio.c
index b793486f..58cf9762 100644
--- a/Alc/backends/portaudio.c
+++ b/Alc/backends/portaudio.c
@@ -165,10 +165,7 @@ static void ALCportPlayback_Construct(ALCportPlayback *self, ALCdevice *device)
static void ALCportPlayback_Destruct(ALCportPlayback *self)
{
- if(self->stream)
- Pa_CloseStream(self->stream);
- self->stream = NULL;
-
+ ALCportPlayback_close(self);
ALCbackend_Destruct(STATIC_CAST(ALCbackend, self));
}
@@ -255,7 +252,7 @@ retry_open:
static void ALCportPlayback_close(ALCportPlayback *self)
{
- PaError err = Pa_CloseStream(self->stream);
+ PaError err = self->stream ? Pa_CloseStream(self->stream) : paNoError;
if(err != paNoError)
ERR("Error closing stream: %s\n", Pa_GetErrorText(err));
self->stream = NULL;
@@ -362,14 +359,7 @@ static void ALCportCapture_Construct(ALCportCapture *self, ALCdevice *device)
static void ALCportCapture_Destruct(ALCportCapture *self)
{
- if(self->stream)
- Pa_CloseStream(self->stream);
- self->stream = NULL;
-
- if(self->ring)
- ll_ringbuffer_free(self->ring);
- self->ring = NULL;
-
+ ALCportCapture_close(self);
ALCbackend_Destruct(STATIC_CAST(ALCbackend, self));
}
@@ -454,7 +444,7 @@ static ALCenum ALCportCapture_open(ALCportCapture *self, const ALCchar *name)
static void ALCportCapture_close(ALCportCapture *self)
{
- PaError err = Pa_CloseStream(self->stream);
+ PaError err = self->stream ? Pa_CloseStream(self->stream) : paNoError;
if(err != paNoError)
ERR("Error closing stream: %s\n", Pa_GetErrorText(err));
self->stream = NULL;
diff --git a/Alc/backends/pulseaudio.c b/Alc/backends/pulseaudio.c
index 3208bf26..581f4c38 100644
--- a/Alc/backends/pulseaudio.c
+++ b/Alc/backends/pulseaudio.c
@@ -519,6 +519,7 @@ static void ALCpulsePlayback_Construct(ALCpulsePlayback *self, ALCdevice *device
static void ALCpulsePlayback_Destruct(ALCpulsePlayback *self)
{
+ ALCpulsePlayback_close(self);
AL_STRING_DEINIT(self->device_name);
ALCbackend_Destruct(STATIC_CAST(ALCbackend, self));
}
@@ -958,12 +959,13 @@ static ALCenum ALCpulsePlayback_open(ALCpulsePlayback *self, const ALCchar *name
static void ALCpulsePlayback_close(ALCpulsePlayback *self)
{
- pulse_close(self->loop, self->context, self->stream);
- self->loop = NULL;
- self->context = NULL;
- self->stream = NULL;
-
- alstr_clear(&self->device_name);
+ if(self->loop)
+ {
+ pulse_close(self->loop, self->context, self->stream);
+ self->loop = NULL;
+ self->context = NULL;
+ self->stream = NULL;
+ }
}
static ALCboolean ALCpulsePlayback_reset(ALCpulsePlayback *self)
@@ -1273,6 +1275,7 @@ static void ALCpulseCapture_Construct(ALCpulseCapture *self, ALCdevice *device)
static void ALCpulseCapture_Destruct(ALCpulseCapture *self)
{
+ ALCpulseCapture_close(self);
AL_STRING_DEINIT(self->device_name);
ALCbackend_Destruct(STATIC_CAST(ALCbackend, self));
}
@@ -1621,12 +1624,13 @@ fail:
static void ALCpulseCapture_close(ALCpulseCapture *self)
{
- pulse_close(self->loop, self->context, self->stream);
- self->loop = NULL;
- self->context = NULL;
- self->stream = NULL;
-
- alstr_clear(&self->device_name);
+ if(self->loop)
+ {
+ pulse_close(self->loop, self->context, self->stream);
+ self->loop = NULL;
+ self->context = NULL;
+ self->stream = NULL;
+ }
}
static ALCboolean ALCpulseCapture_start(ALCpulseCapture *self)
diff --git a/Alc/backends/qsa.c b/Alc/backends/qsa.c
index 58193c96..e1bbf2c2 100644
--- a/Alc/backends/qsa.c
+++ b/Alc/backends/qsa.c
@@ -166,7 +166,7 @@ typedef struct PlaybackWrapper {
} PlaybackWrapper;
static void PlaybackWrapper_Construct(PlaybackWrapper *self, ALCdevice *device);
-static DECLARE_FORWARD(PlaybackWrapper, ALCbackend, void, Destruct)
+static void PlaybackWrapper_Destruct(PlaybackWrapper *self);
static ALCenum PlaybackWrapper_open(PlaybackWrapper *self, const ALCchar *name);
static void PlaybackWrapper_close(PlaybackWrapper *self);
static ALCboolean PlaybackWrapper_reset(PlaybackWrapper *self);
@@ -624,6 +624,12 @@ static void PlaybackWrapper_Construct(PlaybackWrapper *self, ALCdevice *device)
self->ExtraData = NULL;
}
+static void PlaybackWrapper_Destruct(PlaybackWrapper *self)
+{
+ PlaybackWrapper_close(self);
+ ALCbackend_Destruct(STATIC_CAST(ALCbackend, self));
+}
+
static ALCenum PlaybackWrapper_open(PlaybackWrapper *self, const ALCchar *name)
{
return qsa_open_playback(self, name);
@@ -631,7 +637,8 @@ static ALCenum PlaybackWrapper_open(PlaybackWrapper *self, const ALCchar *name)
static void PlaybackWrapper_close(PlaybackWrapper *self)
{
- qsa_close_playback(self);
+ if(self->ExtraData)
+ qsa_close_playback(self);
}
static ALCboolean PlaybackWrapper_reset(PlaybackWrapper *self)
@@ -661,7 +668,7 @@ typedef struct CaptureWrapper {
} CaptureWrapper;
static void CaptureWrapper_Construct(CaptureWrapper *self, ALCdevice *device);
-static DECLARE_FORWARD(CaptureWrapper, ALCbackend, void, Destruct)
+static void CaptureWrapper_Destruct(CaptureWrapper *self);
static ALCenum CaptureWrapper_open(CaptureWrapper *self, const ALCchar *name);
static void CaptureWrapper_close(CaptureWrapper *self);
static DECLARE_FORWARD(CaptureWrapper, ALCbackend, ALCboolean, reset)
@@ -945,6 +952,12 @@ static void CaptureWrapper_Construct(CaptureWrapper *self, ALCdevice *device)
self->ExtraData = NULL;
}
+static void CaptureWrapper_Destruct(CaptureWrapper *self)
+{
+ CaptureWrapper_close(self);
+ ALCbackend_Destruct(STATIC_CAST(ALCbackend, self));
+}
+
static ALCenum CaptureWrapper_open(CaptureWrapper *self, const ALCchar *name)
{
return qsa_open_capture(self, name);
@@ -952,7 +965,8 @@ static ALCenum CaptureWrapper_open(CaptureWrapper *self, const ALCchar *name)
static void CaptureWrapper_close(CaptureWrapper *self)
{
- qsa_close_capture(self);
+ if(self->ExtraData)
+ qsa_close_capture(self);
}
static ALCboolean CaptureWrapper_start(CaptureWrapper *self)
diff --git a/Alc/backends/sndio.c b/Alc/backends/sndio.c
index 47e05353..436baf26 100644
--- a/Alc/backends/sndio.c
+++ b/Alc/backends/sndio.c
@@ -77,9 +77,7 @@ static void ALCsndioBackend_Construct(ALCsndioBackend *self, ALCdevice *device)
static void ALCsndioBackend_Destruct(ALCsndioBackend *self)
{
- if(self->sndHandle)
- sio_close(self->sndHandle);
- self->sndHandle = NULL;
+ ALCsndioBackend_close(self);
al_free(self->mix_data);
self->mix_data = NULL;
@@ -152,7 +150,8 @@ static ALCenum ALCsndioBackend_open(ALCsndioBackend *self, const ALCchar *name)
static void ALCsndioBackend_close(ALCsndioBackend *self)
{
- sio_close(self->sndHandle);
+ if(self->sndHandle)
+ sio_close(self->sndHandle);
self->sndHandle = NULL;
}
diff --git a/Alc/backends/solaris.c b/Alc/backends/solaris.c
index 59cc5ddc..3230b401 100644
--- a/Alc/backends/solaris.c
+++ b/Alc/backends/solaris.c
@@ -90,9 +90,7 @@ static void ALCsolarisBackend_Construct(ALCsolarisBackend *self, ALCdevice *devi
static void ALCsolarisBackend_Destruct(ALCsolarisBackend *self)
{
- if(self->fd != -1)
- close(self->fd);
- self->fd = -1;
+ ALCsolarisBackend_close(self);
free(self->mix_data);
self->mix_data = NULL;
@@ -193,7 +191,8 @@ static ALCenum ALCsolarisBackend_open(ALCsolarisBackend *self, const ALCchar *na
static void ALCsolarisBackend_close(ALCsolarisBackend *self)
{
- close(self->fd);
+ if(self->fd != -1)
+ close(self->fd);
self->fd = -1;
}
diff --git a/Alc/backends/wave.c b/Alc/backends/wave.c
index 1c502fd9..538ab5e6 100644
--- a/Alc/backends/wave.c
+++ b/Alc/backends/wave.c
@@ -84,7 +84,7 @@ typedef struct ALCwaveBackend {
static int ALCwaveBackend_mixerProc(void *ptr);
static void ALCwaveBackend_Construct(ALCwaveBackend *self, ALCdevice *device);
-static DECLARE_FORWARD(ALCwaveBackend, ALCbackend, void, Destruct)
+static void ALCwaveBackend_Destruct(ALCwaveBackend *self);
static ALCenum ALCwaveBackend_open(ALCwaveBackend *self, const ALCchar *name);
static void ALCwaveBackend_close(ALCwaveBackend *self);
static ALCboolean ALCwaveBackend_reset(ALCwaveBackend *self);
@@ -114,6 +114,11 @@ static void ALCwaveBackend_Construct(ALCwaveBackend *self, ALCdevice *device)
self->killNow = 1;
}
+static void ALCwaveBackend_Destruct(ALCwaveBackend *self)
+{
+ ALCwaveBackend_close(self);
+ ALCbackend_Destruct(STATIC_CAST(ALCbackend, self));
+}
static int ALCwaveBackend_mixerProc(void *ptr)
{
diff --git a/Alc/backends/winmm.c b/Alc/backends/winmm.c
index 0fcab458..885b624c 100644
--- a/Alc/backends/winmm.c
+++ b/Alc/backends/winmm.c
@@ -475,6 +475,7 @@ static void ALCwinmmCapture_Construct(ALCwinmmCapture *self, ALCdevice *device)
static void ALCwinmmCapture_Destruct(ALCwinmmCapture *self)
{
+ ALCwinmmCapture_close(self);
if(self->InHdl)
waveInClose(self->InHdl);
self->InHdl = 0;
@@ -664,6 +665,7 @@ static void ALCwinmmCapture_close(ALCwinmmCapture *self)
int i;
/* Tell the processing thread to quit and wait for it to do so. */
+ if(self->killNow) return;
self->killNow = AL_TRUE;
PostThreadMessage(self->thread, WM_QUIT, 0, 0);