mirror of
https://github.com/ZDoom/fluidsynth.git
synced 2024-11-10 06:51:54 +00:00
Fix race condition in fluid_player_callback (#783)
Co-authored-by: Arthur Chaloin <arthur.chaloin@gmail.com>
This commit is contained in:
parent
13185d32b2
commit
676923757c
2 changed files with 4 additions and 2 deletions
|
@ -246,6 +246,7 @@ enum fluid_player_status
|
|||
{
|
||||
FLUID_PLAYER_READY, /**< Player is ready */
|
||||
FLUID_PLAYER_PLAYING, /**< Player is currently playing */
|
||||
FLUID_PLAYER_STOPPING, /**< Player is stopping, but hasn't finished yet */
|
||||
FLUID_PLAYER_DONE /**< Player is finished playing */
|
||||
};
|
||||
|
||||
|
|
|
@ -2092,6 +2092,7 @@ fluid_player_callback(void *data, unsigned int msec)
|
|||
if(fluid_player_get_status(player) != FLUID_PLAYER_PLAYING)
|
||||
{
|
||||
fluid_synth_all_notes_off(synth, -1);
|
||||
fluid_atomic_int_compare_and_exchange(&player->status, FLUID_PLAYER_STOPPING, FLUID_PLAYER_DONE);
|
||||
return 1;
|
||||
}
|
||||
do
|
||||
|
@ -2154,7 +2155,7 @@ fluid_player_callback(void *data, unsigned int msec)
|
|||
}
|
||||
while(loadnextfile);
|
||||
|
||||
fluid_atomic_int_set(&player->status, status);
|
||||
fluid_atomic_int_compare_and_exchange(&player->status, FLUID_PLAYER_PLAYING, status);
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
@ -2193,7 +2194,7 @@ fluid_player_play(fluid_player_t *player)
|
|||
int
|
||||
fluid_player_stop(fluid_player_t *player)
|
||||
{
|
||||
fluid_atomic_int_set(&player->status, FLUID_PLAYER_DONE);
|
||||
fluid_atomic_int_set(&player->status, FLUID_PLAYER_STOPPING);
|
||||
fluid_player_seek(player, fluid_player_get_current_tick(player));
|
||||
return FLUID_OK;
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue