diff options
author | Chris Robinson <[email protected]> | 2023-12-12 23:39:51 -0800 |
---|---|---|
committer | Chris Robinson <[email protected]> | 2023-12-12 23:39:51 -0800 |
commit | b81a270f6c1e795ca70d7684e0ccf35a19f247e2 (patch) | |
tree | 4cabf477f01f1b111f2340b79eae743a5802f7e8 /alc | |
parent | c7774aa488961e0af2895008fb0063fb790b0a58 (diff) |
Properly check that the device was playing before restarting it
Diffstat (limited to 'alc')
-rw-r--r-- | alc/alc.cpp | 11 |
1 files changed, 4 insertions, 7 deletions
diff --git a/alc/alc.cpp b/alc/alc.cpp index 3ab9325a..784c9661 100644 --- a/alc/alc.cpp +++ b/alc/alc.cpp @@ -3450,8 +3450,9 @@ FORCE_ALIGN ALCboolean ALC_APIENTRY alcReopenDeviceSOFT(ALCdevice *device, } std::lock_guard<std::mutex> _{dev->StateLock}; - /* Force the backend to stop mixing first since we're reopening. */ - if(dev->mDeviceState == DeviceState::Playing) + /* Force the backend device to stop first since we're opening another one. */ + const bool wasPlaying{dev->mDeviceState == DeviceState::Playing}; + if(wasPlaying) { dev->Backend->stop(); dev->mDeviceState = DeviceState::Configured; @@ -3476,11 +3477,7 @@ FORCE_ALIGN ALCboolean ALC_APIENTRY alcReopenDeviceSOFT(ALCdevice *device, alcSetError(dev.get(), (e.errorCode() == al::backend_error::OutOfMemory) ? ALC_OUT_OF_MEMORY : ALC_INVALID_VALUE); - /* If the device is connected, not paused, and has contexts, ensure it - * continues playing. - */ - if(dev->Connected.load(std::memory_order_relaxed) && !dev->Flags.test(DevicePaused) - && dev->mDeviceState == DeviceState::Configured) + if(dev->Connected.load(std::memory_order_relaxed) && wasPlaying) { try { auto backend = dev->Backend.get(); |