2018-02-01 10:12:53 -08:00
|
|
|
/* Copyright (C) 2018 Wildfire Games.
|
2009-04-18 10:00:33 -07:00
|
|
|
*
|
2010-02-08 08:23:39 -08:00
|
|
|
* Permission is hereby granted, free of charge, to any person obtaining
|
|
|
|
|
* a copy of this software and associated documentation files (the
|
|
|
|
|
* "Software"), to deal in the Software without restriction, including
|
|
|
|
|
* without limitation the rights to use, copy, modify, merge, publish,
|
|
|
|
|
* distribute, sublicense, and/or sell copies of the Software, and to
|
|
|
|
|
* permit persons to whom the Software is furnished to do so, subject to
|
|
|
|
|
* the following conditions:
|
2016-11-23 05:02:58 -08:00
|
|
|
*
|
2010-02-08 08:23:39 -08:00
|
|
|
* The above copyright notice and this permission notice shall be included
|
|
|
|
|
* in all copies or substantial portions of the Software.
|
2016-11-23 05:02:58 -08:00
|
|
|
*
|
2010-02-08 08:23:39 -08:00
|
|
|
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
|
|
|
|
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
|
|
|
|
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
|
|
|
|
|
* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
|
|
|
|
|
* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
|
|
|
|
|
* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
|
|
|
|
|
* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
2009-04-18 10:00:33 -07:00
|
|
|
*/
|
|
|
|
|
|
2009-04-18 10:51:05 -07:00
|
|
|
/*
|
|
|
|
|
* sound card detection.
|
2006-04-23 16:14:18 -07:00
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
#include "precompiled.h"
|
2017-07-06 10:29:49 -07:00
|
|
|
#include "lib/snd.h"
|
2006-04-23 16:14:18 -07:00
|
|
|
|
2017-07-06 10:29:49 -07:00
|
|
|
#include <stdio.h>
|
|
|
|
|
#include <stdlib.h>
|
2009-07-16 16:53:46 -07:00
|
|
|
|
2017-07-06 10:29:49 -07:00
|
|
|
#include "lib/external_libraries/openal.h"
|
2006-04-23 16:14:18 -07:00
|
|
|
|
2017-07-06 10:29:49 -07:00
|
|
|
std::string snd_card;
|
|
|
|
|
std::string snd_drv_ver;
|
2006-04-23 16:14:18 -07:00
|
|
|
|
|
|
|
|
void snd_detect()
|
|
|
|
|
{
|
2017-07-06 10:29:49 -07:00
|
|
|
// OpenAL alGetString might not return anything interesting on certain platforms
|
|
|
|
|
// (see https://stackoverflow.com/questions/28960638 for an example).
|
|
|
|
|
// However our previous code supported only Windows, and alGetString does work on
|
|
|
|
|
// Windows, so this is an improvement.
|
|
|
|
|
|
|
|
|
|
// Sound cards
|
|
|
|
|
|
|
|
|
|
const ALCchar* devices = nullptr;
|
|
|
|
|
if (alcIsExtensionPresent(nullptr, "ALC_enumeration_EXT") == AL_TRUE)
|
|
|
|
|
{
|
|
|
|
|
if (alcIsExtensionPresent(nullptr, "ALC_enumerate_all_EXT") == AL_TRUE)
|
|
|
|
|
devices = alcGetString(nullptr, ALC_ALL_DEVICES_SPECIFIER);
|
|
|
|
|
else
|
|
|
|
|
devices = alcGetString(nullptr, ALC_DEVICE_SPECIFIER);
|
|
|
|
|
}
|
|
|
|
|
WARN_IF_FALSE(devices);
|
|
|
|
|
|
|
|
|
|
snd_card.clear();
|
|
|
|
|
do {
|
|
|
|
|
snd_card += devices;
|
|
|
|
|
devices += strlen(devices) + 1;
|
|
|
|
|
snd_card += "; ";
|
|
|
|
|
} while (*devices);
|
|
|
|
|
|
|
|
|
|
// Driver version
|
2018-02-01 10:12:53 -08:00
|
|
|
const ALCchar* al_version = alGetString(AL_VERSION);
|
|
|
|
|
if (al_version)
|
|
|
|
|
snd_drv_ver = al_version;
|
2006-11-07 05:28:03 -08:00
|
|
|
}
|