diff options
Diffstat (limited to 'src/courtroom.cpp')
| -rw-r--r-- | src/courtroom.cpp | 31 |
1 files changed, 13 insertions, 18 deletions
diff --git a/src/courtroom.cpp b/src/courtroom.cpp index 7646794..9d872a2 100644 --- a/src/courtroom.cpp +++ b/src/courtroom.cpp @@ -4,6 +4,7 @@ #include "moderation_functions.h" #include "options.h" +#include <QFileInfo> #include <QtConcurrent/QtConcurrent> // #define DEBUG_TRANSITION @@ -16,7 +17,7 @@ Courtroom::Courtroom(AOApplication *p_ao_app) setWindowFlags((this->windowFlags() | Qt::CustomizeWindowHint) & ~Qt::WindowMaximizeButtonHint); setObjectName("courtroom"); - ao_app->initBASS(); + ao_app->initAudio(); keepalive_timer = new QTimer(this); keepalive_timer->start(45000); @@ -33,7 +34,7 @@ Courtroom::Courtroom(AOApplication *p_ao_app) music_player = new AOMusicPlayer(ao_app); music_player->setMuted(true); - connect(&music_player->m_watcher, &QFutureWatcher<QString>::finished, this, &Courtroom::update_ui_music_name, Qt::QueuedConnection); + connect(music_player, &AOMusicPlayer::track_ready, this, [this](QString label) { ui_music_name->setText(label); }); sfx_player = new AOSfxPlayer(ao_app); sfx_player->setMuted(true); @@ -538,6 +539,8 @@ Courtroom::~Courtroom() delete sfx_player; delete objection_player; delete blip_player; + + ma_engine_uninit(&ao_app->audio_engine); } void Courtroom::on_application_state_changed(Qt::ApplicationState state) @@ -4720,8 +4723,7 @@ void Courtroom::handle_song(QStringList *p_contents) int effect_flags = 0; // No effects by default - vanilla functionality QString f_song = f_contents.at(0); - QString f_song_clear = QUrl(f_song).fileName(); - f_song_clear = f_song_clear.left(f_song_clear.lastIndexOf('.')); + QString f_song_clear = QFileInfo(f_song).completeBaseName(); int n_char = f_contents.at(1).toInt(&ok); if (!ok) @@ -4791,24 +4793,17 @@ void Courtroom::handle_song(QStringList *p_contents) { // Current song UI only displays the song playing, not other channels. // Any other music playing is irrelevant. - if (music_player->m_watcher.isRunning()) - { - music_player->m_watcher.cancel(); - } - ui_music_name->setText(tr("[LOADING] %1").arg(f_song_clear)); + ui_music_name->setText("[LOADING]"); } - music_player->m_watcher.setFuture(QtConcurrent::run([=, this]() -> QString { return music_player->playStream(f_song, channel, looping, effect_flags); })); -} - -void Courtroom::update_ui_music_name() -{ - QString result = music_player->m_watcher.result(); - if (result.isEmpty()) + if (f_song.startsWith("http")) { - return; + music_player->play_from_url(f_song, channel, looping, effect_flags); + } + else + { + music_player->play_from_file(f_song, channel, looping, effect_flags); } - ui_music_name->setText(result); } void Courtroom::handle_wtce(QString p_wtce, int variant) |
