From 35b78d55a4554d41bfcb8864c080ea1164c9b183 Mon Sep 17 00:00:00 2001 From: kdhp Date: Fri, 8 Jun 2018 01:42:13 +0000 Subject: Stop capture devices while closing In 'alcCaptureCloseDevice', check if the capture device is running and stop it if necessary. This fixes the case where the device data is deallocated while a background thread is still running (Issue #199) --- Alc/ALc.c | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/Alc/ALc.c b/Alc/ALc.c index 1858c29b..2e9dc710 100644 --- a/Alc/ALc.c +++ b/Alc/ALc.c @@ -4401,6 +4401,12 @@ ALC_API ALCboolean ALC_APIENTRY alcCaptureCloseDevice(ALCdevice *device) } UnlockLists(); + almtx_lock(&device->BackendLock); + if((device->Flags&DEVICE_RUNNING)) + V0(device->Backend,stop)(); + device->Flags &= ~DEVICE_RUNNING; + almtx_unlock(&device->BackendLock); + ALCdevice_DecRef(device); return ALC_TRUE; -- cgit v1.2.3