Fixed a Windows bug where there was no way to get back to the default audio device.

This commit is contained in:
Cerapter 2018-08-24 15:51:28 +02:00
parent 4ee565591f
commit 91ad46eea0
7 changed files with 43 additions and 11 deletions

View File

@ -265,7 +265,7 @@ private:
const int CCCC_RELEASE = 1; const int CCCC_RELEASE = 1;
const int CCCC_MAJOR_VERSION = 3; const int CCCC_MAJOR_VERSION = 3;
const int CCCC_MINOR_VERSION = 0; const int CCCC_MINOR_VERSION = 1;
QString current_theme = "default"; QString current_theme = "default";

View File

@ -29,6 +29,7 @@ void AOBlipPlayer::blip_tick()
HSTREAM f_stream = m_stream_list[f_cycle]; HSTREAM f_stream = m_stream_list[f_cycle];
if (ao_app->get_audio_output_device() != "Default")
BASS_ChannelSetDevice(f_stream, BASS_GetDevice()); BASS_ChannelSetDevice(f_stream, BASS_GetDevice());
BASS_ChannelPlay(f_stream, false); BASS_ChannelPlay(f_stream, false);
} }

View File

@ -21,6 +21,7 @@ void AOMusicPlayer::play(QString p_song)
this->set_volume(m_volume); this->set_volume(m_volume);
if (ao_app->get_audio_output_device() != "Default")
BASS_ChannelSetDevice(m_stream, BASS_GetDevice()); BASS_ChannelSetDevice(m_stream, BASS_GetDevice());
BASS_ChannelPlay(m_stream, false); BASS_ChannelPlay(m_stream, false);
} }

View File

@ -211,6 +211,11 @@ AOOptionsDialog::AOOptionsDialog(QWidget *parent, AOApplication *p_ao_app) : QDi
int a = 0; int a = 0;
BASS_DEVICEINFO info; BASS_DEVICEINFO info;
if (needs_default_audiodev())
{
AudioDeviceCombobox->addItem("Default");
}
for (a = 0; BASS_GetDeviceInfo(a, &info); a++) for (a = 0; BASS_GetDeviceInfo(a, &info); a++)
{ {
AudioDeviceCombobox->addItem(info.name); AudioDeviceCombobox->addItem(info.name);
@ -339,3 +344,17 @@ void AOOptionsDialog::discard_pressed()
{ {
done(0); done(0);
} }
#if (defined (_WIN32) || defined (_WIN64))
bool AOOptionsDialog::needs_default_audiodev()
{
return true;
}
#elif (defined (LINUX) || defined (__linux__))
bool AOOptionsDialog::needs_default_audiodev()
{
return false;
}
#else
#error This operating system is not supported.
#endif

View File

@ -79,6 +79,8 @@ private:
QLabel *BlankBlipsLabel; QLabel *BlankBlipsLabel;
QDialogButtonBox *SettingsButtons; QDialogButtonBox *SettingsButtons;
bool needs_default_audiodev();
signals: signals:
public slots: public slots:

View File

@ -23,6 +23,7 @@ void AOSfxPlayer::play(QString p_sfx, QString p_char)
set_volume(m_volume); set_volume(m_volume);
if (ao_app->get_audio_output_device() != "Default")
BASS_ChannelSetDevice(m_stream, BASS_GetDevice()); BASS_ChannelSetDevice(m_stream, BASS_GetDevice());
BASS_ChannelPlay(m_stream, false); BASS_ChannelPlay(m_stream, false);
} }

View File

@ -19,6 +19,13 @@ Courtroom::Courtroom(AOApplication *p_ao_app) : QMainWindow()
int a = 0; int a = 0;
BASS_DEVICEINFO info; BASS_DEVICEINFO info;
if (ao_app->get_audio_output_device() == "Default")
{
BASS_Init(-1, 48000, BASS_DEVICE_LATENCY, 0, NULL);
BASS_PluginLoad("bassopus.dll", BASS_UNICODE);
}
else
{
for (a = 0; BASS_GetDeviceInfo(a, &info); a++) for (a = 0; BASS_GetDeviceInfo(a, &info); a++)
{ {
if (ao_app->get_audio_output_device() == info.name) if (ao_app->get_audio_output_device() == info.name)
@ -30,6 +37,7 @@ Courtroom::Courtroom(AOApplication *p_ao_app) : QMainWindow()
break; break;
} }
} }
}
keepalive_timer = new QTimer(this); keepalive_timer = new QTimer(this);
keepalive_timer->start(60000); keepalive_timer->start(60000);