Fixed an issue with the audio output change not registering.

This commit is contained in:
Cerapter 2018-08-17 01:34:22 +02:00
parent aee3099d9b
commit eee682bf0d
5 changed files with 21 additions and 31 deletions

View File

@ -48,21 +48,6 @@ void AOApplication::construct_lobby()
discord->state_lobby(); discord->state_lobby();
w_lobby->show(); w_lobby->show();
// Change the default audio output device to be the one the user has given
// in his config.ini file for now.
int a = 0;
BASS_DEVICEINFO info;
for (a = 0; BASS_GetDeviceInfo(a, &info); a++)
{
if (get_audio_output_device() == info.name)
{
BASS_SetDevice(a);
qDebug() << info.name << "was set as the default audio output device.";
break;
}
}
} }
void AOApplication::destruct_lobby() void AOApplication::destruct_lobby()
@ -125,20 +110,6 @@ QString AOApplication::get_cccc_version_string()
void AOApplication::reload_theme() void AOApplication::reload_theme()
{ {
current_theme = read_theme(); current_theme = read_theme();
// This may not be the best place for it, but let's read the audio output device just in case.
int a = 0;
BASS_DEVICEINFO info;
for (a = 0; BASS_GetDeviceInfo(a, &info); a++)
{
if (get_audio_output_device() == info.name)
{
BASS_SetDevice(a);
qDebug() << info.name << "was set as the default audio output device.";
break;
}
}
} }
void AOApplication::set_favorite_list() void AOApplication::set_favorite_list()

View File

@ -33,6 +33,7 @@ void AOBlipPlayer::blip_tick()
HSTREAM f_stream = m_stream_list[f_cycle]; HSTREAM f_stream = m_stream_list[f_cycle];
BASS_ChannelSetDevice(f_stream, BASS_GetDevice());
BASS_ChannelPlay(f_stream, false); BASS_ChannelPlay(f_stream, false);
} }

View File

@ -25,6 +25,7 @@ void AOMusicPlayer::play(QString p_song)
this->set_volume(m_volume); this->set_volume(m_volume);
BASS_ChannelSetDevice(m_stream, BASS_GetDevice());
BASS_ChannelPlay(m_stream, false); BASS_ChannelPlay(m_stream, false);
} }

View File

@ -27,6 +27,7 @@ void AOSfxPlayer::play(QString p_sfx, QString p_char)
set_volume(m_volume); set_volume(m_volume);
BASS_ChannelSetDevice(m_stream, BASS_GetDevice());
BASS_ChannelPlay(m_stream, false); BASS_ChannelPlay(m_stream, false);
} }

View File

@ -20,8 +20,24 @@ Courtroom::Courtroom(AOApplication *p_ao_app) : QMainWindow()
ao_app = p_ao_app; ao_app = p_ao_app;
//initializing sound device //initializing sound device
BASS_Init(-1, 48000, BASS_DEVICE_LATENCY, 0, NULL);
// Change the default audio output device to be the one the user has given
// in his config.ini file for now.
int a = 0;
BASS_DEVICEINFO info;
for (a = 0; BASS_GetDeviceInfo(a, &info); a++)
{
if (ao_app->get_audio_output_device() == info.name)
{
BASS_SetDevice(a);
BASS_Init(a, 48000, BASS_DEVICE_LATENCY, 0, NULL);
BASS_PluginLoad("bassopus.dll", BASS_UNICODE); BASS_PluginLoad("bassopus.dll", BASS_UNICODE);
qDebug() << info.name << "was set as the default audio output device.";
break;
}
}
keepalive_timer = new QTimer(this); keepalive_timer = new QTimer(this);
keepalive_timer->start(60000); keepalive_timer->start(60000);