Skip to content
Permalink
Browse files

SDL: Use a configurable output device.

  • Loading branch information...
unknownbrackets committed Sep 15, 2019
1 parent 141258c commit 875131605174f90808004619a26ac6b89ff4a207
Showing with 22 additions and 2 deletions.
  1. +1 −0 Core/Config.cpp
  2. +1 −0 Core/Config.h
  3. +10 −1 Qt/QtMain.cpp
  4. +10 −1 SDL/SDLMain.cpp
@@ -778,6 +778,7 @@ static ConfigSetting soundSettings[] = {
ConfigSetting("AudioResampler", &g_Config.bAudioResampler, true, true, true),
ConfigSetting("GlobalVolume", &g_Config.iGlobalVolume, VOLUME_MAX, true, true),
ConfigSetting("AltSpeedVolume", &g_Config.iAltSpeedVolume, -1, true, true),
ConfigSetting("AudioDevice", &g_Config.sAudioDevice, "", true, false),

ConfigSetting(false),
};
@@ -197,6 +197,7 @@ struct Config {
int iGlobalVolume;
int iAltSpeedVolume;
bool bExtraAudioBuffering; // For bluetooth
std::string sAudioDevice;

// UI
bool bShowDebuggerOnLoad;
@@ -196,7 +196,16 @@ static int mainInternal(QApplication &a, MainAudioDeviceID &audioDev) {
fmt.callback = &mixaudio;
fmt.userdata = (void *)0;

audioDev = SDL_OpenAudioDevice(nullptr, 0, &fmt, &ret_fmt, SDL_AUDIO_ALLOW_FREQUENCY_CHANGE);
audioDev = 0;
if (!g_Config.sAudioDevice.empty()) {
audioDev = SDL_OpenAudioDevice(g_Config.sAudioDevice.c_str(), 0, &fmt, &ret_fmt, SDL_AUDIO_ALLOW_FREQUENCY_CHANGE);
if (audioDev <= 0) {
WLOG("Failed to open preferred audio device %s", g_Config.sAudioDevice.c_str());
}
}
if (audioDev <= 0) {
audioDev = SDL_OpenAudioDevice(nullptr, 0, &fmt, &ret_fmt, SDL_AUDIO_ALLOW_FREQUENCY_CHANGE);
}
if (audioDev <= 0) {
ELOG("Failed to open audio: %s", SDL_GetError());
} else {
@@ -582,7 +582,16 @@ int main(int argc, char *argv[]) {
fmt.callback = &mixaudio;
fmt.userdata = (void *)0;

SDL_AudioDeviceID audioDev = SDL_OpenAudioDevice(nullptr, 0, &fmt, &ret_fmt, SDL_AUDIO_ALLOW_FREQUENCY_CHANGE);
SDL_AudioDeviceID audioDev = 0;
if (!g_Config.sAudioDevice.empty()) {
audioDev = SDL_OpenAudioDevice(g_Config.sAudioDevice.c_str(), 0, &fmt, &ret_fmt, SDL_AUDIO_ALLOW_FREQUENCY_CHANGE);
if (audioDev <= 0) {
WLOG("Failed to open preferred audio device %s", g_Config.sAudioDevice.c_str());
}
}
if (audioDev <= 0) {
audioDev = SDL_OpenAudioDevice(nullptr, 0, &fmt, &ret_fmt, SDL_AUDIO_ALLOW_FREQUENCY_CHANGE);
}
if (audioDev <= 0) {
ELOG("Failed to open audio: %s", SDL_GetError());
} else {

0 comments on commit 8751316

Please sign in to comment.
You can’t perform that action at this time.