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

Terminate MIDI player once synth ticks overflows #1236

Merged
merged 1 commit into from
May 13, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 10 additions & 0 deletions src/midi/fluid_midi.c
Original file line number Diff line number Diff line change
Expand Up @@ -2141,6 +2141,16 @@ fluid_player_callback(void *data, unsigned int msec)
}
}

if(msec < player->cur_msec)
{
// overflow of fluid_synth_get_ticks()
FLUID_LOG(FLUID_ERR, "The maximum playback duration has been reached. Terminating player!");
fluid_player_stop(player);
fluid_player_seek(player, 0);
player->cur_ticks = 0;
return 0;
}

player->cur_msec = msec;
deltatime = fluid_atomic_float_get(&player->deltatime);
player->cur_ticks = (player->start_ticks
Expand Down
2 changes: 1 addition & 1 deletion src/midi/fluid_midi.h
Original file line number Diff line number Diff line change
Expand Up @@ -305,7 +305,7 @@ struct _fluid_player_t
int last_callback_ticks; /* the last tick number that was passed to player->tick_callback */
int begin_msec; /* the time (msec) of the beginning of the file */
int start_msec; /* the start time of the last tempo change */
int cur_msec; /* the current time */
unsigned int cur_msec; /* the current time */
int end_msec; /* when >=0, playback is extended until this time (for, e.g., reverb) */
char end_pedals_disabled; /* 1 once the pedals have been released after the last midi event, 0 otherwise */
/* sync mode: indicates the tempo mode the player is driven by (see fluid_player_set_tempo()):
Expand Down
Loading