diff options
author | Chris Robinson <[email protected]> | 2019-10-09 00:11:19 -0700 |
---|---|---|
committer | Chris Robinson <[email protected]> | 2019-10-09 00:11:19 -0700 |
commit | 2842df5a02b5a65b9977a64de8ea6bea8adbc964 (patch) | |
tree | e4cd87aa5974cd1b4c1f3094387c0b965f739f1e | |
parent | 963580c2d503eab7c6d8f60a367498ff103bfa3e (diff) |
Catch exceptions from backend start calls
-rw-r--r-- | alc/alc.cpp | 35 |
1 files changed, 24 insertions, 11 deletions
diff --git a/alc/alc.cpp b/alc/alc.cpp index 025395fe..7702a147 100644 --- a/alc/alc.cpp +++ b/alc/alc.cpp @@ -2241,9 +2241,16 @@ static ALCenum UpdateDeviceParams(ALCdevice *device, const ALCint *attrList) if(!device->Flags.get<DevicePaused>()) { - if(device->Backend->start() == false) + try { + auto backend = device->Backend.get(); + if(!backend->start()) + throw al::backend_exception{ALC_INVALID_DEVICE, "Backend error"}; + device->Flags.set<DeviceRunning>(); + } + catch(al::backend_exception& e) { + WARN("Failed to start playback: %s\n", e.what()); return ALC_INVALID_DEVICE; - device->Flags.set<DeviceRunning>(); + } } return ALC_NO_ERROR; @@ -3874,11 +3881,14 @@ START_API_FUNC alcSetError(dev.get(), ALC_INVALID_DEVICE); else if(!dev->Flags.get<DeviceRunning>()) { - if(dev->Backend->start()) + try { + auto backend = dev->Backend.get(); + if(!backend->start()) + throw al::backend_exception{ALC_INVALID_DEVICE, "Device start failure"}; dev->Flags.set<DeviceRunning>(); - else - { - aluHandleDisconnect(dev.get(), "Device start failure"); + } + catch(al::backend_exception& e) { + aluHandleDisconnect(dev.get(), "%s", e.what()); alcSetError(dev.get(), ALC_INVALID_DEVICE); } } @@ -4101,13 +4111,16 @@ START_API_FUNC if(dev->mContexts.load()->empty()) return; - if(dev->Backend->start() == false) - { - aluHandleDisconnect(dev.get(), "Device start failure"); + try { + auto backend = dev->Backend.get(); + if(!backend->start()) + throw al::backend_exception{ALC_INVALID_DEVICE, "Device start failure"}; + dev->Flags.set<DeviceRunning>(); + } + catch(al::backend_exception& e) { + aluHandleDisconnect(dev.get(), "%s", e.what()); alcSetError(dev.get(), ALC_INVALID_DEVICE); - return; } - dev->Flags.set<DeviceRunning>(); } END_API_FUNC |