mirror of
https://github.com/ZDoom/fluidsynth.git
synced 2024-11-10 06:51:54 +00:00
Fix player_seek command in user command file
This commit is contained in:
parent
77f5bee296
commit
d5cb8d312e
2 changed files with 12 additions and 5 deletions
|
@ -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;
|
||||
}
|
||||
|
||||
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,8 +3590,11 @@ int fluid_handle_player_cde(void *data, int ac, char **av, fluid_ostream_t out,
|
|||
}
|
||||
|
||||
fluid_player_seek(handler->player, seek);
|
||||
if(was_running)
|
||||
{
|
||||
fluid_player_play(handler->player);
|
||||
}
|
||||
}
|
||||
/* display position */
|
||||
player_print_position(handler->player, seek, out);
|
||||
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue