fixed stopping music if global anim music differs from current music
authorHolger Schemel <info@artsoft.org>
Wed, 16 Aug 2023 15:16:50 +0000 (17:16 +0200)
committerHolger Schemel <info@artsoft.org>
Wed, 16 Aug 2023 15:30:50 +0000 (17:30 +0200)
commitebd52bd119746407c06131563cc9b5c1b7c3d01d
tree13873b91bb9a6c2aa281532db1dd39bfcb44ee5e
parent9bef503670630747428334ba43f938c24132d834
fixed stopping music if global anim music differs from current music

As there is only one single music channel, the following edge case
could happen before this commit: The current screen plays music from
a global animation, while the next screen plays background music as
defined for this screen (as it might happen with two title screens).
When going from one screen to the other screen, the global animation
music from the first screen is stopped and the background music for
the second screen is started.

If there is a delay between both screens (typically by fading from one
screen to the next one), the first music is stopped and the second
music is started shortly after. Everything works as expected.

However, if there is no delay between both screens (if fading is
disabled by setup menu or by graphics configuration), stopping and
starting old and new music happens in the same screen frame. But as
global animations (including music) are applied *after* the screen is
prepared (also including music), the music for the new screen is
started and immediately stopped again by the global animation code,
which notices the screen change and stops the global animation for the
previous screen (including stopping music for it).

This is fixed now by only stoping the global animation's music if it
is still the same as the currently playing music (which would not be
the case in the edge case described above).
src/anim.c