diff options
author | Chris Robinson <[email protected]> | 2018-01-29 01:00:53 -0800 |
---|---|---|
committer | Chris Robinson <[email protected]> | 2018-01-29 01:00:53 -0800 |
commit | e7217760f39071c7aec542c8f3fbaad21c71924a (patch) | |
tree | 903f585eaa34750b2f7c4a65619c1cf4475bb8a0 | |
parent | a042dbf30524429b49adb63efda35f53054ae924 (diff) |
Don't bother with an explicit stop backend method
-rw-r--r-- | Alc/ALc.c | 9 | ||||
-rw-r--r-- | Alc/backends/alsa.c | 42 | ||||
-rw-r--r-- | Alc/backends/base.h | 3 | ||||
-rw-r--r-- | Alc/backends/coreaudio.c | 11 | ||||
-rw-r--r-- | Alc/backends/dsound.c | 82 | ||||
-rw-r--r-- | Alc/backends/jack.c | 15 | ||||
-rw-r--r-- | Alc/backends/loopback.c | 5 | ||||
-rw-r--r-- | Alc/backends/mmdevapi.c | 84 | ||||
-rw-r--r-- | Alc/backends/null.c | 5 | ||||
-rw-r--r-- | Alc/backends/opensl.c | 59 | ||||
-rw-r--r-- | Alc/backends/oss.c | 34 | ||||
-rw-r--r-- | Alc/backends/portaudio.c | 37 | ||||
-rw-r--r-- | Alc/backends/pulseaudio.c | 42 | ||||
-rw-r--r-- | Alc/backends/qsa.c | 22 | ||||
-rw-r--r-- | Alc/backends/sndio.c | 15 | ||||
-rw-r--r-- | Alc/backends/solaris.c | 13 | ||||
-rw-r--r-- | Alc/backends/wave.c | 13 | ||||
-rw-r--r-- | Alc/backends/winmm.c | 66 |
18 files changed, 209 insertions, 348 deletions
@@ -2434,11 +2434,8 @@ static ALCvoid FreeDevice(ALCdevice *device) TRACE("%p\n", device); if(device->Backend) - { - V0(device->Backend,close)(); DELETE_OBJ(device->Backend); - device->Backend = NULL; - } + device->Backend = NULL; almtx_destroy(&device->BackendLock); @@ -4146,8 +4143,6 @@ ALC_API ALCdevice* ALC_APIENTRY alcOpenDevice(const ALCchar *deviceName) // Find a playback device to open if((err=V(device->Backend,open)(deviceName)) != ALC_NO_ERROR) { - DELETE_OBJ(device->Backend); - device->Backend = NULL; FreeDevice(device); alcSetError(NULL, err); return NULL; @@ -4318,8 +4313,6 @@ ALC_API ALCdevice* ALC_APIENTRY alcCaptureOpenDevice(const ALCchar *deviceName, ); if((err=V(device->Backend,open)(deviceName)) != ALC_NO_ERROR) { - DELETE_OBJ(device->Backend); - device->Backend = NULL; FreeDevice(device); alcSetError(NULL, err); return NULL; 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); diff --git a/Alc/backends/base.h b/Alc/backends/base.h index 318e86fc..177f6869 100644 --- a/Alc/backends/base.h +++ b/Alc/backends/base.h @@ -43,7 +43,6 @@ struct ALCbackendVtable { void (*const Destruct)(ALCbackend*); ALCenum (*const open)(ALCbackend*, const ALCchar*); - void (*const close)(ALCbackend*); ALCboolean (*const reset)(ALCbackend*); ALCboolean (*const start)(ALCbackend*); @@ -63,7 +62,6 @@ struct ALCbackendVtable { #define DEFINE_ALCBACKEND_VTABLE(T) \ DECLARE_THUNK(T, ALCbackend, void, Destruct) \ DECLARE_THUNK1(T, ALCbackend, ALCenum, open, const ALCchar*) \ -DECLARE_THUNK(T, ALCbackend, void, close) \ DECLARE_THUNK(T, ALCbackend, ALCboolean, reset) \ DECLARE_THUNK(T, ALCbackend, ALCboolean, start) \ DECLARE_THUNK(T, ALCbackend, void, stop) \ @@ -79,7 +77,6 @@ static const struct ALCbackendVtable T##_ALCbackend_vtable = { \ T##_ALCbackend_Destruct, \ \ T##_ALCbackend_open, \ - T##_ALCbackend_close, \ T##_ALCbackend_reset, \ T##_ALCbackend_start, \ T##_ALCbackend_stop, \ diff --git a/Alc/backends/coreaudio.c b/Alc/backends/coreaudio.c index bdd9b678..3db0d702 100644 --- a/Alc/backends/coreaudio.c +++ b/Alc/backends/coreaudio.c @@ -98,7 +98,6 @@ typedef struct ALCcoreAudioPlayback { static void ALCcoreAudioPlayback_Construct(ALCcoreAudioPlayback *self, ALCdevice *device); static void ALCcoreAudioPlayback_Destruct(ALCcoreAudioPlayback *self); static ALCenum ALCcoreAudioPlayback_open(ALCcoreAudioPlayback *self, const ALCchar *name); -static void ALCcoreAudioPlayback_close(ALCcoreAudioPlayback *self); static ALCboolean ALCcoreAudioPlayback_reset(ALCcoreAudioPlayback *self); static ALCboolean ALCcoreAudioPlayback_start(ALCcoreAudioPlayback *self); static void ALCcoreAudioPlayback_stop(ALCcoreAudioPlayback *self); @@ -123,7 +122,9 @@ static void ALCcoreAudioPlayback_Construct(ALCcoreAudioPlayback *self, ALCdevice static void ALCcoreAudioPlayback_Destruct(ALCcoreAudioPlayback *self) { - ALCcoreAudioPlayback_close(self); + AudioUnitUninitialize(self->audioUnit); + AudioComponentInstanceDispose(self->audioUnit); + ALCbackend_Destruct(STATIC_CAST(ALCbackend, self)); } @@ -190,12 +191,6 @@ static ALCenum ALCcoreAudioPlayback_open(ALCcoreAudioPlayback *self, const ALCch return ALC_NO_ERROR; } -static void ALCcoreAudioPlayback_close(ALCcoreAudioPlayback *self) -{ - AudioUnitUninitialize(self->audioUnit); - AudioComponentInstanceDispose(self->audioUnit); -} - static ALCboolean ALCcoreAudioPlayback_reset(ALCcoreAudioPlayback *self) { ALCdevice *device = STATIC_CAST(ALCbackend,self)->mDevice; diff --git a/Alc/backends/dsound.c b/Alc/backends/dsound.c index 7760e39d..3d130615 100644 --- a/Alc/backends/dsound.c +++ b/Alc/backends/dsound.c @@ -194,7 +194,6 @@ static int ALCdsoundPlayback_mixerProc(void *ptr); static void ALCdsoundPlayback_Construct(ALCdsoundPlayback *self, ALCdevice *device); 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); static ALCboolean ALCdsoundPlayback_start(ALCdsoundPlayback *self); static void ALCdsoundPlayback_stop(ALCdsoundPlayback *self); @@ -212,11 +211,33 @@ static void ALCdsoundPlayback_Construct(ALCdsoundPlayback *self, ALCdevice *devi { ALCbackend_Construct(STATIC_CAST(ALCbackend, self), device); SET_VTABLE2(ALCdsoundPlayback, ALCbackend, self); + + self->DS = NULL; + self->PrimaryBuffer = NULL; + self->Buffer = NULL; + self->Notifies = NULL; + self->NotifyEvent = NULL; } static void ALCdsoundPlayback_Destruct(ALCdsoundPlayback *self) { - ALCdsoundPlayback_close(self); + if(self->Notifies) + IDirectSoundNotify_Release(self->Notifies); + self->Notifies = NULL; + if(self->Buffer) + IDirectSoundBuffer_Release(self->Buffer); + self->Buffer = NULL; + if(self->PrimaryBuffer != NULL) + IDirectSoundBuffer_Release(self->PrimaryBuffer); + self->PrimaryBuffer = NULL; + + if(self->DS) + IDirectSound_Release(self->DS); + self->DS = NULL; + if(self->NotifyEvent) + CloseHandle(self->NotifyEvent); + self->NotifyEvent = NULL; + ALCbackend_Destruct(STATIC_CAST(ALCbackend, self)); } @@ -393,26 +414,6 @@ static ALCenum ALCdsoundPlayback_open(ALCdsoundPlayback *self, const ALCchar *de return ALC_NO_ERROR; } -static void ALCdsoundPlayback_close(ALCdsoundPlayback *self) -{ - if(self->Notifies) - IDirectSoundNotify_Release(self->Notifies); - self->Notifies = NULL; - if(self->Buffer) - IDirectSoundBuffer_Release(self->Buffer); - self->Buffer = NULL; - if(self->PrimaryBuffer != NULL) - IDirectSoundBuffer_Release(self->PrimaryBuffer); - self->PrimaryBuffer = NULL; - - if(self->DS) - IDirectSound_Release(self->DS); - self->DS = NULL; - if(self->NotifyEvent) - CloseHandle(self->NotifyEvent); - self->NotifyEvent = NULL; -} - static ALCboolean ALCdsoundPlayback_reset(ALCdsoundPlayback *self) { ALCdevice *device = STATIC_CAST(ALCbackend, self)->mDevice; @@ -671,7 +672,6 @@ typedef struct ALCdsoundCapture { static void ALCdsoundCapture_Construct(ALCdsoundCapture *self, ALCdevice *device); 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) static ALCboolean ALCdsoundCapture_start(ALCdsoundCapture *self); static void ALCdsoundCapture_stop(ALCdsoundCapture *self); @@ -688,11 +688,28 @@ static void ALCdsoundCapture_Construct(ALCdsoundCapture *self, ALCdevice *device { ALCbackend_Construct(STATIC_CAST(ALCbackend, self), device); SET_VTABLE2(ALCdsoundCapture, ALCbackend, self); + + self->DSC = NULL; + self->DSCbuffer = NULL; + self->Ring = NULL; } static void ALCdsoundCapture_Destruct(ALCdsoundCapture *self) { - ALCdsoundCapture_close(self); + ll_ringbuffer_free(self->Ring); + self->Ring = NULL; + + if(self->DSCbuffer != NULL) + { + IDirectSoundCaptureBuffer_Stop(self->DSCbuffer); + IDirectSoundCaptureBuffer_Release(self->DSCbuffer); + self->DSCbuffer = NULL; + } + + if(self->DSC) + IDirectSoundCapture_Release(self->DSC); + self->DSC = NULL; + ALCbackend_Destruct(STATIC_CAST(ALCbackend, self)); } @@ -869,23 +886,6 @@ static ALCenum ALCdsoundCapture_open(ALCdsoundCapture *self, const ALCchar *devi return ALC_NO_ERROR; } -static void ALCdsoundCapture_close(ALCdsoundCapture *self) -{ - ll_ringbuffer_free(self->Ring); - self->Ring = NULL; - - if(self->DSCbuffer != NULL) - { - IDirectSoundCaptureBuffer_Stop(self->DSCbuffer); - IDirectSoundCaptureBuffer_Release(self->DSCbuffer); - self->DSCbuffer = NULL; - } - - if(self->DSC) - IDirectSoundCapture_Release(self->DSC); - self->DSC = NULL; -} - static ALCboolean ALCdsoundCapture_start(ALCdsoundCapture *self) { HRESULT hr; diff --git a/Alc/backends/jack.c b/Alc/backends/jack.c index 0dc01ae7..f1141ce9 100644 --- a/Alc/backends/jack.c +++ b/Alc/backends/jack.c @@ -164,7 +164,6 @@ static int ALCjackPlayback_mixerProc(void *arg); static void ALCjackPlayback_Construct(ALCjackPlayback *self, ALCdevice *device); static void ALCjackPlayback_Destruct(ALCjackPlayback *self); static ALCenum ALCjackPlayback_open(ALCjackPlayback *self, const ALCchar *name); -static void ALCjackPlayback_close(ALCjackPlayback *self); static ALCboolean ALCjackPlayback_reset(ALCjackPlayback *self); static ALCboolean ALCjackPlayback_start(ALCjackPlayback *self); static void ALCjackPlayback_stop(ALCjackPlayback *self); @@ -388,20 +387,6 @@ static ALCenum ALCjackPlayback_open(ALCjackPlayback *self, const ALCchar *name) return ALC_NO_ERROR; } -static void ALCjackPlayback_close(ALCjackPlayback *self) -{ - ALuint i; - - for(i = 0;i < MAX_OUTPUT_CHANNELS;i++) - { - if(self->Port[i]) - jack_port_unregister(self->Client, self->Port[i]); - self->Port[i] = NULL; - } - jack_client_close(self->Client); - self->Client = NULL; -} - static ALCboolean ALCjackPlayback_reset(ALCjackPlayback *self) { ALCdevice *device = STATIC_CAST(ALCbackend, self)->mDevice; diff --git a/Alc/backends/loopback.c b/Alc/backends/loopback.c index 8f23aad9..9186a92f 100644 --- a/Alc/backends/loopback.c +++ b/Alc/backends/loopback.c @@ -35,7 +35,6 @@ typedef struct ALCloopback { static void ALCloopback_Construct(ALCloopback *self, ALCdevice *device); static DECLARE_FORWARD(ALCloopback, ALCbackend, void, Destruct) static ALCenum ALCloopback_open(ALCloopback *self, const ALCchar *name); -static void ALCloopback_close(ALCloopback *self); static ALCboolean ALCloopback_reset(ALCloopback *self); static ALCboolean ALCloopback_start(ALCloopback *self); static void ALCloopback_stop(ALCloopback *self); @@ -63,10 +62,6 @@ static ALCenum ALCloopback_open(ALCloopback *self, const ALCchar *name) return ALC_NO_ERROR; } -static void ALCloopback_close(ALCloopback* UNUSED(self)) -{ -} - static ALCboolean ALCloopback_reset(ALCloopback *self) { SetDefaultWFXChannelOrder(STATIC_CAST(ALCbackend, self)->mDevice); diff --git a/Alc/backends/mmdevapi.c b/Alc/backends/mmdevapi.c index 899f73d4..d63d22df 100644 --- a/Alc/backends/mmdevapi.c +++ b/Alc/backends/mmdevapi.c @@ -545,7 +545,6 @@ static void ALCmmdevPlayback_Construct(ALCmmdevPlayback *self, ALCdevice *device static void ALCmmdevPlayback_Destruct(ALCmmdevPlayback *self); static ALCenum ALCmmdevPlayback_open(ALCmmdevPlayback *self, const ALCchar *name); static HRESULT ALCmmdevPlayback_openProxy(ALCmmdevPlayback *self); -static void ALCmmdevPlayback_close(ALCmmdevPlayback *self); static void ALCmmdevPlayback_closeProxy(ALCmmdevPlayback *self); static ALCboolean ALCmmdevPlayback_reset(ALCmmdevPlayback *self); static HRESULT ALCmmdevPlayback_resetProxy(ALCmmdevPlayback *self); @@ -587,7 +586,22 @@ static void ALCmmdevPlayback_Construct(ALCmmdevPlayback *self, ALCdevice *device static void ALCmmdevPlayback_Destruct(ALCmmdevPlayback *self) { - ALCmmdevPlayback_close(self); + if(self->MsgEvent) + { + ThreadRequest req = { self->MsgEvent, 0 }; + if(PostThreadMessage(ThreadID, WM_USER_CloseDevice, (WPARAM)&req, (LPARAM)STATIC_CAST(ALCmmdevProxy, self))) + (void)WaitForResponse(&req); + + CloseHandle(self->MsgEvent); + self->MsgEvent = NULL; + } + + if(self->NotifyEvent) + CloseHandle(self->NotifyEvent); + self->NotifyEvent = NULL; + + free(self->devid); + self->devid = NULL; if(self->NotifyEvent != NULL) CloseHandle(self->NotifyEvent); @@ -838,26 +852,6 @@ static HRESULT ALCmmdevPlayback_openProxy(ALCmmdevPlayback *self) } -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); - - CloseHandle(self->MsgEvent); - self->MsgEvent = NULL; - - CloseHandle(self->NotifyEvent); - self->NotifyEvent = NULL; - - free(self->devid); - self->devid = NULL; -} - static void ALCmmdevPlayback_closeProxy(ALCmmdevPlayback *self) { if(self->client) @@ -1248,7 +1242,6 @@ static void ALCmmdevCapture_Construct(ALCmmdevCapture *self, ALCdevice *device); static void ALCmmdevCapture_Destruct(ALCmmdevCapture *self); static ALCenum ALCmmdevCapture_open(ALCmmdevCapture *self, const ALCchar *name); static HRESULT ALCmmdevCapture_openProxy(ALCmmdevCapture *self); -static void ALCmmdevCapture_close(ALCmmdevCapture *self); static void ALCmmdevCapture_closeProxy(ALCmmdevCapture *self); static DECLARE_FORWARD(ALCmmdevCapture, ALCbackend, ALCboolean, reset) static HRESULT ALCmmdevCapture_resetProxy(ALCmmdevCapture *self); @@ -1292,7 +1285,19 @@ static void ALCmmdevCapture_Construct(ALCmmdevCapture *self, ALCdevice *device) static void ALCmmdevCapture_Destruct(ALCmmdevCapture *self) { - ALCmmdevCapture_close(self); + if(self->MsgEvent) + { + ThreadRequest req = { self->MsgEvent, 0 }; + if(PostThreadMessage(ThreadID, WM_USER_CloseDevice, (WPARAM)&req, (LPARAM)STATIC_CAST(ALCmmdevProxy, self))) + (void)WaitForResponse(&req); + + CloseHandle(self->MsgEvent); + self->MsgEvent = NULL; + } + + if(self->NotifyEvent != NULL) + CloseHandle(self->NotifyEvent); + self->NotifyEvent = NULL; ll_ringbuffer_free(self->Ring); self->Ring = NULL; @@ -1300,13 +1305,6 @@ static void ALCmmdevCapture_Destruct(ALCmmdevCapture *self) DestroySampleConverter(&self->SampleConv); DestroyChannelConverter(&self->ChannelConv); - if(self->NotifyEvent != NULL) - CloseHandle(self->NotifyEvent); - self->NotifyEvent = NULL; - if(self->MsgEvent != NULL) - CloseHandle(self->MsgEvent); - self->MsgEvent = NULL; - free(self->devid); self->devid = NULL; @@ -1529,7 +1527,6 @@ static ALCenum ALCmmdevCapture_open(ALCmmdevCapture *self, const ALCchar *device if(FAILED(hr)) { - ALCmmdevCapture_close(self); if(hr == E_OUTOFMEMORY) return ALC_OUT_OF_MEMORY; return ALC_INVALID_VALUE; @@ -1576,29 +1573,6 @@ static HRESULT ALCmmdevCapture_openProxy(ALCmmdevCapture *self) } -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); - - ll_ringbuffer_free(self->Ring); - self->Ring = NULL; - - CloseHandle(self->MsgEvent); - self->MsgEvent = NULL; - - CloseHandle(self->NotifyEvent); - self->NotifyEvent = NULL; - - free(self->devid); - self->devid = NULL; -} - static void ALCmmdevCapture_closeProxy(ALCmmdevCapture *self) { if(self->client) diff --git a/Alc/backends/null.c b/Alc/backends/null.c index e8c43782..d17c8bda 100644 --- a/Alc/backends/null.c +++ b/Alc/backends/null.c @@ -45,7 +45,6 @@ static int ALCnullBackend_mixerProc(void *ptr); static void ALCnullBackend_Construct(ALCnullBackend *self, ALCdevice *device); static DECLARE_FORWARD(ALCnullBackend, ALCbackend, void, Destruct) static ALCenum ALCnullBackend_open(ALCnullBackend *self, const ALCchar *name); -static void ALCnullBackend_close(ALCnullBackend *self); static ALCboolean ALCnullBackend_reset(ALCnullBackend *self); static ALCboolean ALCnullBackend_start(ALCnullBackend *self); static void ALCnullBackend_stop(ALCnullBackend *self); @@ -135,10 +134,6 @@ static ALCenum ALCnullBackend_open(ALCnullBackend *self, const ALCchar *name) return ALC_NO_ERROR; } -static void ALCnullBackend_close(ALCnullBackend* UNUSED(self)) -{ -} - static ALCboolean ALCnullBackend_reset(ALCnullBackend *self) { SetDefaultWFXChannelOrder(STATIC_CAST(ALCbackend, self)->mDevice); diff --git a/Alc/backends/opensl.c b/Alc/backends/opensl.c index c1283111..7edc9ff8 100644 --- a/Alc/backends/opensl.c +++ b/Alc/backends/opensl.c @@ -160,7 +160,6 @@ static int ALCopenslPlayback_mixerProc(void *arg); static void ALCopenslPlayback_Construct(ALCopenslPlayback *self, ALCdevice *device); static void ALCopenslPlayback_Destruct(ALCopenslPlayback *self); static ALCenum ALCopenslPlayback_open(ALCopenslPlayback *self, const ALCchar *name); -static void ALCopenslPlayback_close(ALCopenslPlayback *self); static ALCboolean ALCopenslPlayback_reset(ALCopenslPlayback *self); static ALCboolean ALCopenslPlayback_start(ALCopenslPlayback *self); static void ALCopenslPlayback_stop(ALCopenslPlayback *self); @@ -194,7 +193,18 @@ static void ALCopenslPlayback_Construct(ALCopenslPlayback *self, ALCdevice *devi static void ALCopenslPlayback_Destruct(ALCopenslPlayback* self) { - ALCopenslPlayback_close(self); + if(self->mBufferQueueObj != NULL) + VCALL0(self->mBufferQueueObj,Destroy)(); + self->mBufferQueueObj = NULL; + + if(self->mOutputMix) + VCALL0(self->mOutputMix,Destroy)(); + self->mOutputMix = NULL; + + if(self->mEngineObj) + VCALL0(self->mEngineObj,Destroy)(); + self->mEngineObj = NULL; + self->mEngine = NULL; alcnd_destroy(&self->mCond); @@ -389,22 +399,6 @@ static ALCenum ALCopenslPlayback_open(ALCopenslPlayback *self, const ALCchar *na return ALC_NO_ERROR; } -static void ALCopenslPlayback_close(ALCopenslPlayback *self) -{ - if(self->mBufferQueueObj != NULL) - VCALL0(self->mBufferQueueObj,Destroy)(); - self->mBufferQueueObj = NULL; - - if(self->mOutputMix) - VCALL0(self->mOutputMix,Destroy)(); - self->mOutputMix = NULL; - - if(self->mEngineObj) - VCALL0(self->mEngineObj,Destroy)(); - self->mEngineObj = NULL; - self->mEngine = NULL; -} - static ALCboolean ALCopenslPlayback_reset(ALCopenslPlayback *self) { ALCdevice *device = STATIC_CAST(ALCbackend,self)->mDevice; @@ -710,7 +704,6 @@ static void ALCopenslCapture_process(SLAndroidSimpleBufferQueueItf bq, void *con static void ALCopenslCapture_Construct(ALCopenslCapture *self, ALCdevice *device); static void ALCopenslCapture_Destruct(ALCopenslCapture *self); static ALCenum ALCopenslCapture_open(ALCopenslCapture *self, const ALCchar *name); -static void ALCopenslCapture_close(ALCopenslCapture *self); static DECLARE_FORWARD(ALCopenslCapture, ALCbackend, ALCboolean, reset) static ALCboolean ALCopenslCapture_start(ALCopenslCapture *self); static void ALCopenslCapture_stop(ALCopenslCapture *self); @@ -749,7 +742,18 @@ static void ALCopenslCapture_Construct(ALCopenslCapture *self, ALCdevice *device static void ALCopenslCapture_Destruct(ALCopenslCapture *self) { - ALCopenslCapture_close(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; + ALCbackend_Destruct(STATIC_CAST(ALCbackend, self)); } @@ -918,21 +922,6 @@ static ALCenum ALCopenslCapture_open(ALCopenslCapture *self, const ALCchar *name return ALC_NO_ERROR; } -static void ALCopenslCapture_close(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; -} - static ALCboolean ALCopenslCapture_start(ALCopenslCapture *self) { SLRecordItf record; diff --git a/Alc/backends/oss.c b/Alc/backends/oss.c index e88e5ff3..b2d9c555 100644 --- a/Alc/backends/oss.c +++ b/Alc/backends/oss.c @@ -254,7 +254,6 @@ static int ALCplaybackOSS_mixerProc(void *ptr); static void ALCplaybackOSS_Construct(ALCplaybackOSS *self, ALCdevice *device); 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); static ALCboolean ALCplaybackOSS_start(ALCplaybackOSS *self); static void ALCplaybackOSS_stop(ALCplaybackOSS *self); @@ -339,12 +338,16 @@ static void ALCplaybackOSS_Construct(ALCplaybackOSS *self, ALCdevice *device) ALCbackend_Construct(STATIC_CAST(ALCbackend, self), device); SET_VTABLE2(ALCplaybackOSS, ALCbackend, self); + self->fd = -1; ATOMIC_INIT(&self->killNow, AL_FALSE); } static void ALCplaybackOSS_Destruct(ALCplaybackOSS *self) { - ALCplaybackOSS_close(self); + if(self->fd != -1) + close(self->fd); + self->fd = -1; + ALCbackend_Destruct(STATIC_CAST(ALCbackend, self)); } @@ -387,13 +390,6 @@ static ALCenum ALCplaybackOSS_open(ALCplaybackOSS *self, const ALCchar *name) return ALC_NO_ERROR; } -static void ALCplaybackOSS_close(ALCplaybackOSS *self) -{ - if(self->fd != -1) - close(self->fd); - self->fd = -1; -} - static ALCboolean ALCplaybackOSS_reset(ALCplaybackOSS *self) { ALCdevice *device = STATIC_CAST(ALCbackend, self)->mDevice; @@ -528,7 +524,6 @@ static int ALCcaptureOSS_recordProc(void *ptr); static void ALCcaptureOSS_Construct(ALCcaptureOSS *self, ALCdevice *device); 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) static ALCboolean ALCcaptureOSS_start(ALCcaptureOSS *self); static void ALCcaptureOSS_stop(ALCcaptureOSS *self); @@ -605,12 +600,19 @@ static void ALCcaptureOSS_Construct(ALCcaptureOSS *self, ALCdevice *device) ALCbackend_Construct(STATIC_CAST(ALCbackend, self), device); SET_VTABLE2(ALCcaptureOSS, ALCbackend, self); + self->fd = -1; + self->ring = NULL; ATOMIC_INIT(&self->killNow, AL_FALSE); } static void ALCcaptureOSS_Destruct(ALCcaptureOSS *self) { - ALCcaptureOSS_close(self); + if(self->fd != -1) + close(self->fd); + self->fd = -1; + + ll_ringbuffer_free(self->ring); + self->ring = NULL; ALCbackend_Destruct(STATIC_CAST(ALCbackend, self)); } @@ -739,16 +741,6 @@ static ALCenum ALCcaptureOSS_open(ALCcaptureOSS *self, const ALCchar *name) return ALC_NO_ERROR; } -static void ALCcaptureOSS_close(ALCcaptureOSS *self) -{ - if(self->fd != -1) - close(self->fd); - self->fd = -1; - - ll_ringbuffer_free(self->ring); - self->ring = NULL; -} - static ALCboolean ALCcaptureOSS_start(ALCcaptureOSS *self) { ATOMIC_STORE_SEQ(&self->killNow, AL_FALSE); diff --git a/Alc/backends/portaudio.c b/Alc/backends/portaudio.c index 58cf9762..fdc8a2a5 100644 --- a/Alc/backends/portaudio.c +++ b/Alc/backends/portaudio.c @@ -141,7 +141,6 @@ static int ALCportPlayback_WriteCallback(const void *inputBuffer, void *outputBu static void ALCportPlayback_Construct(ALCportPlayback *self, ALCdevice *device); static void ALCportPlayback_Destruct(ALCportPlayback *self); static ALCenum ALCportPlayback_open(ALCportPlayback *self, const ALCchar *name); -static void ALCportPlayback_close(ALCportPlayback *self); static ALCboolean ALCportPlayback_reset(ALCportPlayback *self); static ALCboolean ALCportPlayback_start(ALCportPlayback *self); static void ALCportPlayback_stop(ALCportPlayback *self); @@ -165,7 +164,11 @@ static void ALCportPlayback_Construct(ALCportPlayback *self, ALCdevice *device) static void ALCportPlayback_Destruct(ALCportPlayback *self) { - ALCportPlayback_close(self); + PaError err = self->stream ? Pa_CloseStream(self->stream) : paNoError; + if(err != paNoError) + ERR("Error closing stream: %s\n", Pa_GetErrorText(err)); + self->stream = NULL; + ALCbackend_Destruct(STATIC_CAST(ALCbackend, self)); } @@ -250,14 +253,6 @@ retry_open: } -static void ALCportPlayback_close(ALCportPlayback *self) -{ - PaError err = self->stream ? Pa_CloseStream(self->stream) : paNoError; - if(err != paNoError) - ERR("Error closing stream: %s\n", Pa_GetErrorText(err)); - self->stream = NULL; -} - static ALCboolean ALCportPlayback_reset(ALCportPlayback *self) { ALCdevice *device = STATIC_CAST(ALCbackend, self)->mDevice; @@ -335,7 +330,6 @@ static int ALCportCapture_ReadCallback(const void *inputBuffer, void *outputBuff static void ALCportCapture_Construct(ALCportCapture *self, ALCdevice *device); static void ALCportCapture_Destruct(ALCportCapture *self); static ALCenum ALCportCapture_open(ALCportCapture *self, const ALCchar *name); -static void ALCportCapture_close(ALCportCapture *self); static DECLARE_FORWARD(ALCportCapture, ALCbackend, ALCboolean, reset) static ALCboolean ALCportCapture_start(ALCportCapture *self); static void ALCportCapture_stop(ALCportCapture *self); @@ -355,11 +349,19 @@ static void ALCportCapture_Construct(ALCportCapture *self, ALCdevice *device) SET_VTABLE2(ALCportCapture, ALCbackend, self); self->stream = NULL; + self->ring = NULL; } static void ALCportCapture_Destruct(ALCportCapture *self) { - ALCportCapture_close(self); + PaError err = self->stream ? Pa_CloseStream(self->stream) : paNoError; + if(err != paNoError) + ERR("Error closing stream: %s\n", Pa_GetErrorText(err)); + self->stream = NULL; + + ll_ringbuffer_free(self->ring); + self->ring = NULL; + ALCbackend_Destruct(STATIC_CAST(ALCbackend, self)); } @@ -442,17 +444,6 @@ static ALCenum ALCportCapture_open(ALCportCapture *self, const ALCchar *name) return ALC_NO_ERROR; } -static void ALCportCapture_close(ALCportCapture *self) -{ - PaError err = self->stream ? Pa_CloseStream(self->stream) : paNoError; - if(err != paNoError) - ERR("Error closing stream: %s\n", Pa_GetErrorText(err)); - self->stream = NULL; - - ll_ringbuffer_free(self->ring); - self->ring = NULL; -} - static ALCboolean ALCportCapture_start(ALCportCapture *self) { diff --git a/Alc/backends/pulseaudio.c b/Alc/backends/pulseaudio.c index 581f4c38..bcfbb6c2 100644 --- a/Alc/backends/pulseaudio.c +++ b/Alc/backends/pulseaudio.c @@ -495,7 +495,6 @@ static int ALCpulsePlayback_mixerProc(void *ptr); static void ALCpulsePlayback_Construct(ALCpulsePlayback *self, ALCdevice *device); static void ALCpulsePlayback_Destruct(ALCpulsePlayback *self); static ALCenum ALCpulsePlayback_open(ALCpulsePlayback *self, const ALCchar *name); -static void ALCpulsePlayback_close(ALCpulsePlayback *self); static ALCboolean ALCpulsePlayback_reset(ALCpulsePlayback *self); static ALCboolean ALCpulsePlayback_start(ALCpulsePlayback *self); static void ALCpulsePlayback_stop(ALCpulsePlayback *self); @@ -514,12 +513,19 @@ static void ALCpulsePlayback_Construct(ALCpulsePlayback *self, ALCdevice *device ALCbackend_Construct(STATIC_CAST(ALCbackend, self), device); SET_VTABLE2(ALCpulsePlayback, ALCbackend, self); + self->loop = NULL; AL_STRING_INIT(self->device_name); } static void ALCpulsePlayback_Destruct(ALCpulsePlayback *self) { - ALCpulsePlayback_close(self); + if(self->loop) + { + pulse_close(self->loop, self->context, self->stream); + self->loop = NULL; + self->context = NULL; + self->stream = NULL; + } AL_STRING_DEINIT(self->device_name); ALCbackend_Destruct(STATIC_CAST(ALCbackend, self)); } @@ -957,17 +963,6 @@ static ALCenum ALCpulsePlayback_open(ALCpulsePlayback *self, const ALCchar *name return ALC_NO_ERROR; } -static void ALCpulsePlayback_close(ALCpulsePlayback *self) -{ - 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) { ALCdevice *device = STATIC_CAST(ALCbackend,self)->mDevice; @@ -1251,7 +1246,6 @@ static pa_stream *ALCpulseCapture_connectStream(const char *device_name, static void ALCpulseCapture_Construct(ALCpulseCapture *self, ALCdevice *device); static void ALCpulseCapture_Destruct(ALCpulseCapture *self); static ALCenum ALCpulseCapture_open(ALCpulseCapture *self, const ALCchar *name); -static void ALCpulseCapture_close(ALCpulseCapture *self); static DECLARE_FORWARD(ALCpulseCapture, ALCbackend, ALCboolean, reset) static ALCboolean ALCpulseCapture_start(ALCpulseCapture *self); static void ALCpulseCapture_stop(ALCpulseCapture *self); @@ -1270,12 +1264,19 @@ static void ALCpulseCapture_Construct(ALCpulseCapture *self, ALCdevice *device) ALCbackend_Construct(STATIC_CAST(ALCbackend, self), device); SET_VTABLE2(ALCpulseCapture, ALCbackend, self); + self->loop = NULL; AL_STRING_INIT(self->device_name); } static void ALCpulseCapture_Destruct(ALCpulseCapture *self) { - ALCpulseCapture_close(self); + if(self->loop) + { + pulse_close(self->loop, self->context, self->stream); + self->loop = NULL; + self->context = NULL; + self->stream = NULL; + } AL_STRING_DEINIT(self->device_name); ALCbackend_Destruct(STATIC_CAST(ALCbackend, self)); } @@ -1622,17 +1623,6 @@ fail: return ALC_INVALID_VALUE; } -static void ALCpulseCapture_close(ALCpulseCapture *self) -{ - 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) { pa_operation *o; diff --git a/Alc/backends/qsa.c b/Alc/backends/qsa.c index e1bbf2c2..614d738c 100644 --- a/Alc/backends/qsa.c +++ b/Alc/backends/qsa.c @@ -168,7 +168,6 @@ typedef struct PlaybackWrapper { static void PlaybackWrapper_Construct(PlaybackWrapper *self, ALCdevice *device); 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); static ALCboolean PlaybackWrapper_start(PlaybackWrapper *self); static void PlaybackWrapper_stop(PlaybackWrapper *self); @@ -626,7 +625,9 @@ static void PlaybackWrapper_Construct(PlaybackWrapper *self, ALCdevice *device) static void PlaybackWrapper_Destruct(PlaybackWrapper *self) { - PlaybackWrapper_close(self); + if(self->ExtraData) + qsa_close_playback(self); + ALCbackend_Destruct(STATIC_CAST(ALCbackend, self)); } @@ -635,12 +636,6 @@ static ALCenum PlaybackWrapper_open(PlaybackWrapper *self, const ALCchar *name) return qsa_open_playback(self, name); } -static void PlaybackWrapper_close(PlaybackWrapper *self) -{ - if(self->ExtraData) - qsa_close_playback(self); -} - static ALCboolean PlaybackWrapper_reset(PlaybackWrapper *self) { return qsa_reset_playback(self); @@ -670,7 +665,6 @@ typedef struct CaptureWrapper { static void CaptureWrapper_Construct(CaptureWrapper *self, ALCdevice *device); 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) static ALCboolean CaptureWrapper_start(CaptureWrapper *self); static void CaptureWrapper_stop(CaptureWrapper *self); @@ -954,7 +948,9 @@ static void CaptureWrapper_Construct(CaptureWrapper *self, ALCdevice *device) static void CaptureWrapper_Destruct(CaptureWrapper *self) { - CaptureWrapper_close(self); + if(self->ExtraData) + qsa_close_capture(self); + ALCbackend_Destruct(STATIC_CAST(ALCbackend, self)); } @@ -963,12 +959,6 @@ static ALCenum CaptureWrapper_open(CaptureWrapper *self, const ALCchar *name) return qsa_open_capture(self, name); } -static void CaptureWrapper_close(CaptureWrapper *self) -{ - if(self->ExtraData) - qsa_close_capture(self); -} - static ALCboolean CaptureWrapper_start(CaptureWrapper *self) { qsa_start_capture(self); diff --git a/Alc/backends/sndio.c b/Alc/backends/sndio.c index 436baf26..f7b9af69 100644 --- a/Alc/backends/sndio.c +++ b/Alc/backends/sndio.c @@ -52,7 +52,6 @@ static int ALCsndioBackend_mixerProc(void *ptr); static void ALCsndioBackend_Construct(ALCsndioBackend *self, ALCdevice *device); static void ALCsndioBackend_Destruct(ALCsndioBackend *self); static ALCenum ALCsndioBackend_open(ALCsndioBackend *self, const ALCchar *name); -static void ALCsndioBackend_close(ALCsndioBackend *self); static ALCboolean ALCsndioBackend_reset(ALCsndioBackend *self); static ALCboolean ALCsndioBackend_start(ALCsndioBackend *self); static void ALCsndioBackend_stop(ALCsndioBackend *self); @@ -73,11 +72,16 @@ static void ALCsndioBackend_Construct(ALCsndioBackend *self, ALCdevice *device) { ALCbackend_Construct(STATIC_CAST(ALCbackend, self), device); SET_VTABLE2(ALCsndioBackend, ALCbackend, self); + + self->sndHandle = NULL; + self->mix_data = NULL; } static void ALCsndioBackend_Destruct(ALCsndioBackend *self) { - ALCsndioBackend_close(self); + if(self->sndHandle) + sio_close(self->sndHandle); + self->sndHandle = NULL; al_free(self->mix_data); self->mix_data = NULL; @@ -148,13 +152,6 @@ static ALCenum ALCsndioBackend_open(ALCsndioBackend *self, const ALCchar *name) return ALC_NO_ERROR; } -static void ALCsndioBackend_close(ALCsndioBackend *self) -{ - if(self->sndHandle) - sio_close(self->sndHandle); - self->sndHandle = NULL; -} - static ALCboolean ALCsndioBackend_reset(ALCsndioBackend *self) { ALCdevice *device = STATIC_CAST(ALCbackend,self)->mDevice; diff --git a/Alc/backends/solaris.c b/Alc/backends/solaris.c index 3230b401..49bfad3c 100644 --- a/Alc/backends/solaris.c +++ b/Alc/backends/solaris.c @@ -60,7 +60,6 @@ static int ALCsolarisBackend_mixerProc(void *ptr); static void ALCsolarisBackend_Construct(ALCsolarisBackend *self, ALCdevice *device); static void ALCsolarisBackend_Destruct(ALCsolarisBackend *self); static ALCenum ALCsolarisBackend_open(ALCsolarisBackend *self, const ALCchar *name); -static void ALCsolarisBackend_close(ALCsolarisBackend *self); static ALCboolean ALCsolarisBackend_reset(ALCsolarisBackend *self); static ALCboolean ALCsolarisBackend_start(ALCsolarisBackend *self); static void ALCsolarisBackend_stop(ALCsolarisBackend *self); @@ -85,12 +84,15 @@ static void ALCsolarisBackend_Construct(ALCsolarisBackend *self, ALCdevice *devi SET_VTABLE2(ALCsolarisBackend, ALCbackend, self); self->fd = -1; + self->mix_data = NULL; ATOMIC_INIT(&self->killNow, AL_FALSE); } static void ALCsolarisBackend_Destruct(ALCsolarisBackend *self) { - ALCsolarisBackend_close(self); + if(self->fd != -1) + close(self->fd); + self->fd = -1; free(self->mix_data); self->mix_data = NULL; @@ -189,13 +191,6 @@ static ALCenum ALCsolarisBackend_open(ALCsolarisBackend *self, const ALCchar *na return ALC_NO_ERROR; } -static void ALCsolarisBackend_close(ALCsolarisBackend *self) -{ - if(self->fd != -1) - close(self->fd); - self->fd = -1; -} - static ALCboolean ALCsolarisBackend_reset(ALCsolarisBackend *self) { ALCdevice *device = STATIC_CAST(ALCbackend,self)->mDevice; diff --git a/Alc/backends/wave.c b/Alc/backends/wave.c index 538ab5e6..ecb066f8 100644 --- a/Alc/backends/wave.c +++ b/Alc/backends/wave.c @@ -86,7 +86,6 @@ static int ALCwaveBackend_mixerProc(void *ptr); static void ALCwaveBackend_Construct(ALCwaveBackend *self, ALCdevice *device); 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); static ALCboolean ALCwaveBackend_start(ALCwaveBackend *self); static void ALCwaveBackend_stop(ALCwaveBackend *self); @@ -116,7 +115,10 @@ static void ALCwaveBackend_Construct(ALCwaveBackend *self, ALCdevice *device) static void ALCwaveBackend_Destruct(ALCwaveBackend *self) { - ALCwaveBackend_close(self); + if(self->mFile) + fclose(self->mFile); + self->mFile = NULL; + ALCbackend_Destruct(STATIC_CAST(ALCbackend, self)); } @@ -239,13 +241,6 @@ static ALCenum ALCwaveBackend_open(ALCwaveBackend *self, const ALCchar *name) return ALC_NO_ERROR; } -static void ALCwaveBackend_close(ALCwaveBackend *self) -{ - if(self->mFile) - fclose(self->mFile); - self->mFile = NULL; -} - static ALCboolean ALCwaveBackend_reset(ALCwaveBackend *self) { ALCdevice *device = STATIC_CAST(ALCbackend, self)->mDevice; diff --git a/Alc/backends/winmm.c b/Alc/backends/winmm.c index 885b624c..59164441 100644 --- a/Alc/backends/winmm.c +++ b/Alc/backends/winmm.c @@ -159,7 +159,6 @@ static void CALLBACK ALCwinmmPlayback_waveOutProc(HWAVEOUT device, UINT msg, DWO static int ALCwinmmPlayback_mixerProc(void *arg); static ALCenum ALCwinmmPlayback_open(ALCwinmmPlayback *self, const ALCchar *name); -static void ALCwinmmPlayback_close(ALCwinmmPlayback *self); static ALCboolean ALCwinmmPlayback_reset(ALCwinmmPlayback *self); static ALCboolean ALCwinmmPlayback_start(ALCwinmmPlayback *self); static void ALCwinmmPlayback_stop(ALCwinmmPlayback *self); @@ -312,9 +311,6 @@ failure: return ALC_INVALID_VALUE; } -static void ALCwinmmPlayback_close(ALCwinmmPlayback* UNUSED(self)) -{ } - static ALCboolean ALCwinmmPlayback_reset(ALCwinmmPlayback *self) { ALCdevice *device = STATIC_CAST(ALCbackend, self)->mDevice; @@ -448,7 +444,6 @@ static void CALLBACK ALCwinmmCapture_waveInProc(HWAVEIN device, UINT msg, DWORD_ static int ALCwinmmCapture_captureProc(void *arg); static ALCenum ALCwinmmCapture_open(ALCwinmmCapture *self, const ALCchar *name); -static void ALCwinmmCapture_close(ALCwinmmCapture *self); static DECLARE_FORWARD(ALCwinmmCapture, ALCbackend, ALCboolean, reset) static ALCboolean ALCwinmmCapture_start(ALCwinmmCapture *self); static void ALCwinmmCapture_stop(ALCwinmmCapture *self); @@ -475,7 +470,34 @@ static void ALCwinmmCapture_Construct(ALCwinmmCapture *self, ALCdevice *device) static void ALCwinmmCapture_Destruct(ALCwinmmCapture *self) { - ALCwinmmCapture_close(self); + void *buffer = NULL; + int i; + + /* Tell the processing thread to quit and wait for it to do so. */ + if(!self->killNow) + { + self->killNow = AL_TRUE; + PostThreadMessage(self->thread, WM_QUIT, 0, 0); + + althrd_join(self->thread, &i); + + /* Make sure capture is stopped and all pending buffers are flushed. */ + waveInReset(self->InHdl); + + // Release the wave buffers + for(i = 0;i < 4;i++) + { + waveInUnprepareHeader(self->InHdl, &self->WaveBuffer[i], sizeof(WAVEHDR)); + if(i == 0) buffer = self->WaveBuffer[i].lpData; + self->WaveBuffer[i].lpData = NULL; + } + free(buffer); + } + + ll_ringbuffer_free(self->Ring); + self->Ring = NULL; + + // Close the Wave device if(self->InHdl) waveInClose(self->InHdl); self->InHdl = 0; @@ -659,38 +681,6 @@ failure: return ALC_INVALID_VALUE; } -static void ALCwinmmCapture_close(ALCwinmmCapture *self) -{ - void *buffer = NULL; - 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); - - althrd_join(self->thread, &i); - - /* Make sure capture is stopped and all pending buffers are flushed. */ - waveInReset(self->InHdl); - - // Release the wave buffers - for(i = 0;i < 4;i++) - { - waveInUnprepareHeader(self->InHdl, &self->WaveBuffer[i], sizeof(WAVEHDR)); - if(i == 0) buffer = self->WaveBuffer[i].lpData; - self->WaveBuffer[i].lpData = NULL; - } - free(buffer); - - ll_ringbuffer_free(self->Ring); - self->Ring = NULL; - - // Close the Wave device - waveInClose(self->InHdl); - self->InHdl = NULL; -} - static ALCboolean ALCwinmmCapture_start(ALCwinmmCapture *self) { waveInStart(self->InHdl); |