diff options
author | Chris Robinson <[email protected]> | 2019-10-07 21:37:56 -0700 |
---|---|---|
committer | Chris Robinson <[email protected]> | 2019-10-07 21:37:56 -0700 |
commit | 02d80cd74dd7b4517550af2f4ea22c409323a1d9 (patch) | |
tree | f72a927a6565d76dc7087f1a15f82733d92b4155 /alc/alc.cpp | |
parent | f8ff4e269bf04aae1c430dbb218b4f4f6605df45 (diff) |
Use exceptions for backend open failures
Diffstat (limited to 'alc/alc.cpp')
-rw-r--r-- | alc/alc.cpp | 32 |
1 files changed, 10 insertions, 22 deletions
diff --git a/alc/alc.cpp b/alc/alc.cpp index 119067fd..025395fe 100644 --- a/alc/alc.cpp +++ b/alc/alc.cpp @@ -3548,16 +3548,9 @@ START_API_FUNC device->NumAuxSends = DEFAULT_SENDS; try { - /* Create the device backend. */ - device->Backend = PlaybackFactory->createBackend(device.get(), BackendType::Playback); - - /* Find a playback device to open */ - ALCenum err{device->Backend->open(deviceName)}; - if(err != ALC_NO_ERROR) - { - alcSetError(nullptr, err); - return nullptr; - } + auto backend = PlaybackFactory->createBackend(device.get(), BackendType::Playback); + backend->open(deviceName); + device->Backend = std::move(backend); } catch(al::backend_exception &e) { WARN("Failed to open playback device: %s\n", e.what()); @@ -3811,17 +3804,13 @@ START_API_FUNC device->BufferSize = static_cast<ALuint>(samples); try { - device->Backend = CaptureFactory->createBackend(device.get(), BackendType::Capture); - TRACE("Capture format: %s, %s, %uhz, %u / %u buffer\n", DevFmtChannelsString(device->FmtChans), DevFmtTypeString(device->FmtType), device->Frequency, device->UpdateSize, device->BufferSize); - ALCenum err{device->Backend->open(deviceName)}; - if(err != ALC_NO_ERROR) - { - alcSetError(nullptr, err); - return nullptr; - } + + auto backend = CaptureFactory->createBackend(device.get(), BackendType::Capture); + backend->open(deviceName); + device->Backend = std::move(backend); } catch(al::backend_exception &e) { WARN("Failed to open capture device: %s\n", e.what()); @@ -4000,11 +3989,10 @@ START_API_FUNC device->NumMonoSources = device->SourcesMax - device->NumStereoSources; try { - device->Backend = LoopbackBackendFactory::getFactory().createBackend(device.get(), + auto backend = LoopbackBackendFactory::getFactory().createBackend(device.get(), BackendType::Playback); - - // Open the "backend" - device->Backend->open("Loopback"); + backend->open("Loopback"); + device->Backend = std::move(backend); } catch(al::backend_exception &e) { WARN("Failed to open loopback device: %s\n", e.what()); |