mirror of
https://github.com/RPCS3/rpcs3.git
synced 2024-11-17 08:11:51 +00:00
Qt: try to fix sound effects
Don't re-use sound effect objects. Allow 3 sounds simultaneously.
This commit is contained in:
parent
1444981bdc
commit
e48bd29584
@ -606,11 +606,19 @@ void gui_application::InitializeCallbacks()
|
||||
{
|
||||
if (fs::is_file(path))
|
||||
{
|
||||
m_sound_effect.stop();
|
||||
m_sound_effect.setSource(QUrl::fromLocalFile(qstr(path)));
|
||||
m_sound_effect.setVolume(g_cfg.audio.volume * 0.01f);
|
||||
m_sound_effect.setLoopCount(1);
|
||||
m_sound_effect.play();
|
||||
// Allow to play 3 sound effects at the same time
|
||||
while (m_sound_effects.size() >= 3)
|
||||
{
|
||||
m_sound_effects.pop_front();
|
||||
}
|
||||
|
||||
// Create a new sound effect. Re-using the same object seems to be broken for some users starting with Qt 6.6.3.
|
||||
std::unique_ptr<QSoundEffect> sound_effect = std::make_unique<QSoundEffect>();
|
||||
sound_effect->setSource(QUrl::fromLocalFile(qstr(path)));
|
||||
sound_effect->setVolume(g_cfg.audio.volume * 0.01f);
|
||||
sound_effect->play();
|
||||
|
||||
m_sound_effects.push_back(std::move(sound_effect));
|
||||
}
|
||||
});
|
||||
};
|
||||
|
@ -16,6 +16,7 @@
|
||||
|
||||
#include <memory>
|
||||
#include <functional>
|
||||
#include <deque>
|
||||
|
||||
class gs_frame;
|
||||
class main_window;
|
||||
@ -96,7 +97,7 @@ private:
|
||||
QTimer m_timer;
|
||||
QElapsedTimer m_timer_playtime;
|
||||
|
||||
QSoundEffect m_sound_effect{};
|
||||
std::deque<std::unique_ptr<QSoundEffect>> m_sound_effects{};
|
||||
|
||||
std::shared_ptr<emu_settings> m_emu_settings;
|
||||
std::shared_ptr<gui_settings> m_gui_settings;
|
||||
|
Loading…
Reference in New Issue
Block a user