cellMusic: fix qt music handler resume

This commit is contained in:
Megamouse 2022-03-06 12:09:04 +01:00
parent aafd74f9ea
commit 00f6763228
1 changed files with 14 additions and 4 deletions

View File

@ -11,7 +11,10 @@ LOG_CHANNEL(music_log, "Music");
qt_music_handler::qt_music_handler() qt_music_handler::qt_music_handler()
{ {
music_log.notice("Constructing Qt music handler..."); music_log.notice("Constructing Qt music handler...");
m_media_player = std::make_shared<QMediaPlayer>(); m_media_player = std::make_shared<QMediaPlayer>();
m_media_player->setAudioRole(QAudio::Role::MusicRole);
m_error_handler = std::make_unique<qt_music_error_handler>(m_media_player); m_error_handler = std::make_unique<qt_music_error_handler>(m_media_player);
} }
@ -39,11 +42,18 @@ void qt_music_handler::play(const std::string& path)
atomic_t<bool> wake_up = false; atomic_t<bool> wake_up = false;
Emu.CallFromMainThread([&wake_up, &path, this]() Emu.CallFromMainThread([&wake_up, &path, this]()
{
if (m_state == CELL_MUSIC_PB_STATUS_PAUSE)
{
music_log.notice("Resuming music: %s", path);
}
else
{ {
music_log.notice("Playing music: %s", path); music_log.notice("Playing music: %s", path);
m_media_player->setAudioRole(QAudio::Role::MusicRole);
m_media_player->setPlaybackRate(1.0); m_media_player->setPlaybackRate(1.0);
m_media_player->setMedia(QUrl(QString::fromStdString(path))); m_media_player->setMedia(QUrl(QString::fromStdString(path)));
}
m_media_player->play(); m_media_player->play();
wake_up = true; wake_up = true;
wake_up.notify_one(); wake_up.notify_one();