Skip to content

Commit d2e3104

Browse files
committed
AudioPlayer: Reset sounds before playing them
1 parent 5f21681 commit d2e3104

File tree

1 file changed

+11
-1
lines changed

1 file changed

+11
-1
lines changed

src/audio/audioplayer.cpp

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,17 @@ void AudioPlayer::start()
6767
if (!AudioEngine::initialized())
6868
return;
6969

70-
ma_result result = ma_sound_start(m_sound);
70+
if (isPlaying())
71+
stop();
72+
73+
ma_result result = ma_sound_seek_to_pcm_frame(m_sound, 0);
74+
75+
if (result != MA_SUCCESS) {
76+
std::cerr << "Failed to seek to PCM frame 0." << std::endl;
77+
m_started = false;
78+
}
79+
80+
result = ma_sound_start(m_sound);
7181

7282
if (result != MA_SUCCESS) {
7383
std::cerr << "Failed to start sound." << std::endl;

0 commit comments

Comments
 (0)