Implement the option for auto audio devices switching for Windows too

(previously SDL-only)
This commit is contained in:
Henrik Rydgård
2021-07-18 00:07:05 +02:00
parent e03c51fff2
commit 15f3269338
2 changed files with 8 additions and 4 deletions
+6 -2
View File
@@ -634,16 +634,20 @@ void GameSettingsScreen::CreateViews() {
MicChoice->OnChoice.Handle(this, &GameSettingsScreen::OnMicDeviceChange);
}
bool sdlAudio = false;
#if defined(SDL)
std::vector<std::string> audioDeviceList;
SplitString(System_GetProperty(SYSPROP_AUDIO_DEVICE_LIST), '\0', audioDeviceList);
audioDeviceList.insert(audioDeviceList.begin(), a->T("Auto"));
PopupMultiChoiceDynamic *audioDevice = audioSettings->Add(new PopupMultiChoiceDynamic(&g_Config.sAudioDevice, a->T("Device"), audioDeviceList, nullptr, screenManager()));
audioDevice->OnChoice.Handle(this, &GameSettingsScreen::OnAudioDevice);
audioSettings->Add(new CheckBox(&g_Config.bAutoAudioDevice, a->T("Switch on new audio device")));
sdlAudio = true;
#endif
if (sdlAudio || g_Config.iAudioBackend == AUDIO_BACKEND_WASAPI) {
audioSettings->Add(new CheckBox(&g_Config.bAutoAudioDevice, a->T("Use new audio devices automatically")));
}
#if defined(__ANDROID__)
CheckBox *extraAudio = audioSettings->Add(new CheckBox(&g_Config.bExtraAudioBuffering, a->T("AudioBufferingForBluetooth", "Bluetooth-friendly buffer (slower)")));
extraAudio->SetEnabledPtr(&g_Config.bEnableSound);
+2 -2
View File
@@ -59,7 +59,7 @@ public:
deviceChanged_ = false;
}
bool HasDeviceChanged() {
bool HasDefaultDeviceChanged() const {
return deviceChanged_;
}
@@ -529,7 +529,7 @@ void WASAPIAudioThread::Run() {
}
// Check if we should use a new device.
if (notificationClient_ && notificationClient_->HasDeviceChanged()) {
if (notificationClient_ && notificationClient_->HasDefaultDeviceChanged() && g_Config.bAutoAudioDevice) {
hresult = audioInterface_->Stop();
ShutdownAudioDevice();