Skip to content

Commit

Permalink
Rewind playlist if calling fluid_player_play after all loops complete (
Browse files Browse the repository at this point in the history
  • Loading branch information
albedozero authored Oct 30, 2021
1 parent de05ef2 commit a3dd7fd
Showing 1 changed file with 10 additions and 0 deletions.
10 changes: 10 additions & 0 deletions src/midi/fluid_midi.c
Original file line number Diff line number Diff line change
Expand Up @@ -2200,6 +2200,9 @@ fluid_player_callback(void *data, unsigned int msec)
* Activates play mode for a MIDI player if not already playing.
* @param player MIDI player instance
* @return #FLUID_OK on success, #FLUID_FAILED otherwise
*
* If the list of files added to the player has completed its requested number of loops,
* the playlist will be restarted from the beginning with a loop count of 1.
*/
int
fluid_player_play(fluid_player_t *player)
Expand All @@ -2215,10 +2218,17 @@ fluid_player_play(fluid_player_t *player)
fluid_sample_timer_reset(player->synth, player->sample_timer);
}

/* If we're at the end of the playlist and there are no loops left, loop once */
if(player->currentfile == NULL && player->loop == 0)
{
player->loop = 1;
}

fluid_atomic_int_set(&player->status, FLUID_PLAYER_PLAYING);

return FLUID_OK;
}

/**
* Pauses the MIDI playback.
*
Expand Down

0 comments on commit a3dd7fd

Please sign in to comment.