aboutsummaryrefslogtreecommitdiffstats
path: root/Alc/alc.cpp
diff options
context:
space:
mode:
authorChris Robinson <[email protected]>2019-04-20 19:29:33 -0700
committerChris Robinson <[email protected]>2019-04-20 19:29:33 -0700
commit725ceb128ed4cb48a039d2f32ae73f8c8dccabef (patch)
tree82bc0f8d9b08a26c89e1ae46195d5017abe09d1d /Alc/alc.cpp
parent87e279082f5b25be662a3ae116fbb92b7dac6330 (diff)
Open the playback device earlier
So we actually have a device name to get the initial settings for. Be aware that some backends set a format when opening instead of on reset, so such devices will only set the default format (it can't get a desired format without the device name, but the format will already be set once that's known). The affected backends are WinMM, SDL2, and PortAudio (none of which are generally used). This could be fixed by reopening the device during reset, but it would need to be done carefully.
Diffstat (limited to 'Alc/alc.cpp')
-rw-r--r--Alc/alc.cpp38
1 files changed, 20 insertions, 18 deletions
diff --git a/Alc/alc.cpp b/Alc/alc.cpp
index f5da7657..27e926da 100644
--- a/Alc/alc.cpp
+++ b/Alc/alc.cpp
@@ -3665,7 +3665,7 @@ START_API_FUNC
DeviceRef device{new ALCdevice{Playback}};
- //Set output format
+ /* Set output format */
device->FmtChans = DevFmtChannelsDefault;
device->FmtType = DevFmtTypeDefault;
device->Frequency = DEFAULT_OUTPUT_RATE;
@@ -3677,6 +3677,24 @@ 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;
+ }
+
+ /* Find a playback device to open */
+ ALCenum err{device->Backend->open(deviceName)};
+ if(err != ALC_NO_ERROR)
+ {
+ alcSetError(nullptr, err);
+ return nullptr;
+ }
+
+ deviceName = device->DeviceName.c_str();
const ALCchar *fmt{};
if(ConfigValueStr(deviceName, nullptr, "channels", &fmt))
{
@@ -3774,23 +3792,7 @@ START_API_FUNC
device->NumStereoSources = 1;
device->NumMonoSources = device->SourcesMax - device->NumStereoSources;
- device->Backend = PlaybackBackend.getFactory().createBackend(device.get(),
- BackendType::Playback);
- if(!device->Backend)
- {
- alcSetError(nullptr, ALC_OUT_OF_MEMORY);
- return nullptr;
- }
-
- // Find a playback device to open
- ALCenum err{device->Backend->open(deviceName)};
- if(err != ALC_NO_ERROR)
- {
- alcSetError(nullptr, err);
- return nullptr;
- }
-
- if(ConfigValueStr(device->DeviceName.c_str(), nullptr, "ambi-format", &fmt))
+ if(ConfigValueStr(deviceName, nullptr, "ambi-format", &fmt))
{
if(strcasecmp(fmt, "fuma") == 0)
{