Fix player_seek command in user command file

This commit is contained in:
derselbst 2021-02-01 18:43:34 +01:00 committed by Tom M
parent 77f5bee296
commit d5cb8d312e
2 changed files with 12 additions and 5 deletions

View File

@ -3525,7 +3525,7 @@ enum
int fluid_handle_player_cde(void *data, int ac, char **av, fluid_ostream_t out, int cmd)
{
FLUID_ENTRY_COMMAND(data);
int arg;
int arg, was_running;
int seek = -1; /* current seek position in tick */
/* commands name table */
@ -3556,7 +3556,11 @@ int fluid_handle_player_cde(void *data, int ac, char **av, fluid_ostream_t out,
return FLUID_OK;
}
fluid_player_stop(handler->player); /* player_stop */
was_running = fluid_player_get_status(handler->player) == FLUID_PLAYER_PLAYING;
if(was_running)
{
fluid_player_stop(handler->player); /* player_stop */
}
if(cmd != PLAYER_STOP_CDE)
{
@ -3574,7 +3578,7 @@ int fluid_handle_player_cde(void *data, int ac, char **av, fluid_ostream_t out,
{
seek = 0; /* minimum position */
}
else if(arg < seek)
else if(!was_running || arg < seek)
{
seek = arg; /* seek < maximum position */
}
@ -3586,7 +3590,10 @@ int fluid_handle_player_cde(void *data, int ac, char **av, fluid_ostream_t out,
}
fluid_player_seek(handler->player, seek);
fluid_player_play(handler->player);
if(was_running)
{
fluid_player_play(handler->player);
}
}
/* display position */
player_print_position(handler->player, seek, out);

View File

@ -2199,7 +2199,7 @@ fluid_player_get_status(fluid_player_t *player)
*/
int fluid_player_seek(fluid_player_t *player, int ticks)
{
if(ticks < 0 || ticks > fluid_player_get_total_ticks(player))
if(ticks < 0 || (fluid_player_get_status(player) != FLUID_PLAYER_READY && ticks > fluid_player_get_total_ticks(player)))
{
return FLUID_FAILED;
}