aboutsummaryrefslogtreecommitdiffstats
path: root/Alc
diff options
context:
space:
mode:
Diffstat (limited to 'Alc')
-rw-r--r--Alc/alc.cpp76
1 files changed, 41 insertions, 35 deletions
diff --git a/Alc/alc.cpp b/Alc/alc.cpp
index 3bc365c8..9b4c2978 100644
--- a/Alc/alc.cpp
+++ b/Alc/alc.cpp
@@ -3680,20 +3680,22 @@ START_API_FUNC
device->AuxiliaryEffectSlotMax = 64;
device->NumAuxSends = DEFAULT_SENDS;
- /* Create the device backend. */
- device->Backend = PlaybackBackend.getFactory().createBackend(device.get(),
- BackendType::Playback);
- if(!device->Backend)
- {
- alcSetError(nullptr, ALC_OUT_OF_MEMORY);
- return nullptr;
+ try {
+ /* Create the device backend. */
+ device->Backend = PlaybackBackend.getFactory().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;
+ }
}
-
- /* Find a playback device to open */
- ALCenum err{device->Backend->open(deviceName)};
- if(err != ALC_NO_ERROR)
- {
- alcSetError(nullptr, err);
+ catch(al::backend_exception &e) {
+ WARN("Failed to open playback device: %s\n", e.what());
+ alcSetError(nullptr, e.errorCode());
return nullptr;
}
@@ -3934,21 +3936,23 @@ START_API_FUNC
device->UpdateSize = samples;
device->BufferSize = samples;
- device->Backend = CaptureBackend.getFactory().createBackend(device.get(),
- BackendType::Capture);
- if(!device->Backend)
- {
- alcSetError(nullptr, ALC_OUT_OF_MEMORY);
- return nullptr;
- }
+ try {
+ device->Backend = CaptureBackend.getFactory().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);
+ 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;
+ }
+ }
+ catch(al::backend_exception &e) {
+ WARN("Failed to open capture device: %s\n", e.what());
+ alcSetError(nullptr, e.errorCode());
return nullptr;
}
@@ -4108,17 +4112,19 @@ START_API_FUNC
device->NumStereoSources = 1;
device->NumMonoSources = device->SourcesMax - device->NumStereoSources;
- device->Backend = LoopbackBackendFactory::getFactory().createBackend(device.get(),
- BackendType::Playback);
- if(!device->Backend)
- {
- alcSetError(nullptr, ALC_OUT_OF_MEMORY);
+ try {
+ device->Backend = LoopbackBackendFactory::getFactory().createBackend(device.get(),
+ BackendType::Playback);
+
+ // Open the "backend"
+ device->Backend->open("Loopback");
+ }
+ catch(al::backend_exception &e) {
+ WARN("Failed to open loopback device: %s\n", e.what());
+ alcSetError(nullptr, e.errorCode());
return nullptr;
}
- // Open the "backend"
- device->Backend->open("Loopback");
-
{
std::lock_guard<std::recursive_mutex> _{ListLock};
auto iter = std::lower_bound(DeviceList.cbegin(), DeviceList.cend(), device.get());