Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Music sometimes not playing after death #1833

Closed
LouriNoel opened this issue Oct 5, 2021 · 1 comment
Closed

Music sometimes not playing after death #1833

LouriNoel opened this issue Oct 5, 2021 · 1 comment

Comments

@LouriNoel
Copy link
Contributor

v0.6.2-842-gb1c41b6df
Ubuntu 20.04.3 (64-bit) (virtual machine, but also happens occasionally on my dual-boot)

Expected behavior

When Tux dies, the music fades out. When respawning (at the level's beginning or at the checkpoint), the music fades in from where it stopped.

Actual behavior

In some cases, the music does not fade in after respawning: we don't hear anything. Taking a checkpoint does not affect this behaviour. Pressing the escape key and resuming the game, or changing the music volume in the options, restarts the music normally.

Steps to reproduce actual behavior

This happens more frequently when the game lags (I tried running the game in a virtual machine), but it can also happen under normal conditions. I will explain why. Just take a level like Nolok's castle and keep dying at the beginning on the first badguy, in this level you don't even have to move.

Additional debugging information

I already investigated the issue, and I will do a PR to fix it.

Normally when Tux dies, the music fades away because we decrease the gain in StreamSoundSource::update. The music fades in after respawning because GameSession calls MusicObject::resume_music, which ultimately increases the gain in StreamSoundSource::update.
But sometimes resume_music is not called soon enough, so the music is paused at the end of the fade time in StreamSoundSource::update. Then the gain increases again after respawning, but the music is not playing because it is paused.

What I suggest (and this is what I do in the PR that will soon follow this post) is to resume m_music_source on top of calling set_fading in SoundManager::resume_music (which is called by GameSession).
This way, this additional call will play the music if it is paused, and otherwise do nothing (ie. return immediately if the music is not paused).

LouriNoel added a commit to LouriNoel/supertux that referenced this issue Oct 5, 2021
Resuming m_music_source on top of calling set_fading will play
the music if it has been paused, and will do nothing if the music
is not paused yet.
tobbi pushed a commit that referenced this issue Oct 11, 2021
Resuming m_music_source on top of calling set_fading will play
the music if it has been paused, and will do nothing if the music
is not paused yet.
@tobbi
Copy link
Member

tobbi commented Oct 13, 2021

Fixed by merged PR.

@tobbi tobbi closed this as completed Oct 13, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants