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

Ignore music playing state when game is paused #2337

Open
wants to merge 2 commits into
base: master
Choose a base branch
from

Conversation

ilmoro93
Copy link
Contributor

As reported in #2180, the music doesn't restart when the game is resumed from pause.

This PR fixes it by preventing Play music option to be unselected by cfg.musicPlaying = playMusic(mi.pathId, cfg.volume, false); in playBackgroundMusic() when game isPaused().

But there is still a problem: when resuming in Locomotion the music is actually resumed, while in OpenLoco it restarts from the beginning.

Moreover I have noticed that clicking Load Saved Game in main menu also stops the music.

I don't know if we should solve everything in one PR or you can review and merge this little fix only.

@AaronVanGeffen
Copy link
Member

But there is still a problem: when resuming in Locomotion the music is actually resumed, while in OpenLoco it restarts from the beginning.

Unlike vanilla, OpenLoco does not keep track of music progression. That much is currently delegated to the stream library (OpenAL). We could potentially reintroduce this, though, by querying track progression before the stream is cut.

@ZehMatt
Copy link
Contributor

ZehMatt commented Mar 11, 2024

But there is still a problem: when resuming in Locomotion the music is actually resumed, while in OpenLoco it restarts from the beginning.

Unlike vanilla, OpenLoco does not keep track of music progression. That much is currently delegated to the stream library (OpenAL). We could potentially reintroduce this, though, by querying track progression before the stream is cut.

Do we need to track the progress? I think pause/resume functionality exists in OpenAL so we don't have to do that ourselves.

@ilmoro93
Copy link
Contributor Author

ilmoro93 commented Mar 29, 2024

I have tried the alSourcePause() function of OpenAL. If I get a working solution I will make a PR in the next days to fix #2180 and to enable music resume after pause.

@ilmoro93
Copy link
Contributor Author

I think Audio::playMusic() should not return bool. The return value is only used in playBackgroundMusic() and assigned to cfg.musicPlaying, which unselects the Play music option, and I think this is wrong (see #2180 (comment)).
What do you think?

@ilmoro93 ilmoro93 marked this pull request as ready for review April 3, 2024 20:32
@LeftofZen LeftofZen added the changelog Should get a changelog entry label Apr 25, 2024
@LeftofZen LeftofZen added this to the v24.04+ milestone Apr 25, 2024
@LeftofZen
Copy link
Contributor

perhaps a broader discussion; should the music pause at all when the user pauses the game? the ambient track does not pause, so perhaps either it should, or the music shouldn't

Copy link
Contributor

@LeftofZen LeftofZen left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

  • functionality works but also introduces a bug - if you mute the audio with
    image
    then the playlist cycles through tracks infinitely. this does not happen in 24.04
  • needs changelog

@ilmoro93
Copy link
Contributor Author

perhaps a broader discussion; should the music pause at all when the user pauses the game? the ambient track does not pause, so perhaps either it should, or the music shouldn't

I think every sound should pause when the game is paused, like vanilla. I find it more intuitive, it makes it clear that game is playing when music resumes.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
changelog Should get a changelog entry pending improvement
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants