From 160e70f8f27394eccd7d757fd73c9665cdfe1d65 Mon Sep 17 00:00:00 2001 From: Chris Robinson Date: Sun, 15 Jun 2014 09:27:00 -0700 Subject: [PATCH] Fix getting the actual device name --- src/sound/oalsound.cpp | 25 +++++++++++++++++++++---- 1 file changed, 21 insertions(+), 4 deletions(-) diff --git a/src/sound/oalsound.cpp b/src/sound/oalsound.cpp index afcaed59f9..3c3037f88e 100644 --- a/src/sound/oalsound.cpp +++ b/src/sound/oalsound.cpp @@ -591,7 +591,13 @@ OpenALSoundRenderer::OpenALSoundRenderer() } } - Printf(" Opened device "TEXTCOLOR_ORANGE"%s\n", alcGetString(Device, ALC_DEVICE_SPECIFIER)); + const ALCchar *current = NULL; + if(alcIsExtensionPresent(Device, "ALC_ENUMERATE_ALL_EXT")) + current = alcGetString(Device, ALC_ALL_DEVICES_SPECIFIER); + if(alcGetError(Device) != ALC_NO_ERROR || !current) + current = alcGetString(Device, ALC_DEVICE_SPECIFIER); + Printf(" Opened device "TEXTCOLOR_ORANGE"%s\n", current); + ALCint major=0, minor=0; alcGetIntegerv(Device, ALC_MAJOR_VERSION, 1, &major); alcGetIntegerv(Device, ALC_MINOR_VERSION, 1, &minor); @@ -609,7 +615,7 @@ OpenALSoundRenderer::OpenALSoundRenderer() // Make sure one source is capable of stereo output with the rest doing // mono, without running out of voices attribs.push_back(ALC_MONO_SOURCES); - attribs.push_back((std::max)(*snd_channels, 2) - 1); + attribs.push_back(std::max(*snd_channels, 2) - 1); attribs.push_back(ALC_STEREO_SOURCES); attribs.push_back(1); // Other attribs..? @@ -657,7 +663,8 @@ OpenALSoundRenderer::OpenALSoundRenderer() alcGetIntegerv(Device, ALC_MONO_SOURCES, 1, &numMono); alcGetIntegerv(Device, ALC_STEREO_SOURCES, 1, &numStereo); - Sources.resize((std::min)((std::max)(*snd_channels, 2), numMono+numStereo)); + Sources.resize(std::min(std::max(*snd_channels, 2), + numMono+numStereo)); for(size_t i = 0;i < Sources.size();i++) { alGenSources(1, &Sources[i]); @@ -1663,13 +1670,23 @@ void OpenALSoundRenderer::PrintDriversList() const ALCchar *drivers = (alcIsExtensionPresent(NULL, "ALC_ENUMERATE_ALL_EXT") ? alcGetString(NULL, ALC_ALL_DEVICES_SPECIFIER) : alcGetString(NULL, ALC_DEVICE_SPECIFIER)); - const ALCchar *current = alcGetString(Device, ALC_DEVICE_SPECIFIER); if(drivers == NULL) { Printf(TEXTCOLOR_YELLOW"Failed to retrieve device list: %s\n", alcGetString(NULL, alcGetError(NULL))); return; } + const ALCchar *current = NULL; + if(alcIsExtensionPresent(Device, "ALC_ENUMERATE_ALL_EXT")) + current = alcGetString(Device, ALC_ALL_DEVICES_SPECIFIER); + if(alcGetError(Device) != ALC_NO_ERROR || !current) + current = alcGetString(Device, ALC_DEVICE_SPECIFIER); + if(current == NULL) + { + Printf(TEXTCOLOR_YELLOW"Failed to retrieve device name: %s\n", alcGetString(Device, alcGetError(Device))); + return; + } + Printf("%c%s%2d. %s\n", ' ', ((strcmp(snd_aldevice, "Default") == 0) ? TEXTCOLOR_BOLD : ""), 0, "Default"); for(int i = 1;*drivers;i++)