From eee682bf0d603b0afe9dc2e41bf971669cea225d Mon Sep 17 00:00:00 2001 From: Cerapter Date: Fri, 17 Aug 2018 01:34:22 +0200 Subject: [PATCH] Fixed an issue with the audio output change not registering. --- aoapplication.cpp | 29 ----------------------------- aoblipplayer.cpp | 1 + aomusicplayer.cpp | 1 + aosfxplayer.cpp | 1 + courtroom.cpp | 20 ++++++++++++++++++-- 5 files changed, 21 insertions(+), 31 deletions(-) diff --git a/aoapplication.cpp b/aoapplication.cpp index b8db52e..0133765 100644 --- a/aoapplication.cpp +++ b/aoapplication.cpp @@ -48,21 +48,6 @@ void AOApplication::construct_lobby() discord->state_lobby(); 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() @@ -125,20 +110,6 @@ QString AOApplication::get_cccc_version_string() void AOApplication::reload_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() diff --git a/aoblipplayer.cpp b/aoblipplayer.cpp index f212453..5669a12 100644 --- a/aoblipplayer.cpp +++ b/aoblipplayer.cpp @@ -33,6 +33,7 @@ void AOBlipPlayer::blip_tick() HSTREAM f_stream = m_stream_list[f_cycle]; + BASS_ChannelSetDevice(f_stream, BASS_GetDevice()); BASS_ChannelPlay(f_stream, false); } diff --git a/aomusicplayer.cpp b/aomusicplayer.cpp index a9a9baf..3246fc2 100644 --- a/aomusicplayer.cpp +++ b/aomusicplayer.cpp @@ -25,6 +25,7 @@ void AOMusicPlayer::play(QString p_song) this->set_volume(m_volume); + BASS_ChannelSetDevice(m_stream, BASS_GetDevice()); BASS_ChannelPlay(m_stream, false); } diff --git a/aosfxplayer.cpp b/aosfxplayer.cpp index 6ad59ba..c090be1 100644 --- a/aosfxplayer.cpp +++ b/aosfxplayer.cpp @@ -27,6 +27,7 @@ void AOSfxPlayer::play(QString p_sfx, QString p_char) set_volume(m_volume); + BASS_ChannelSetDevice(m_stream, BASS_GetDevice()); BASS_ChannelPlay(m_stream, false); } diff --git a/courtroom.cpp b/courtroom.cpp index 6e855f3..3dd0c4f 100644 --- a/courtroom.cpp +++ b/courtroom.cpp @@ -20,8 +20,24 @@ Courtroom::Courtroom(AOApplication *p_ao_app) : QMainWindow() ao_app = p_ao_app; //initializing sound device - BASS_Init(-1, 48000, BASS_DEVICE_LATENCY, 0, NULL); - BASS_PluginLoad("bassopus.dll", BASS_UNICODE); + + + // 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); + qDebug() << info.name << "was set as the default audio output device."; + break; + } + } keepalive_timer = new QTimer(this); keepalive_timer->start(60000);