summaryrefslogtreecommitdiffstats
path: root/command.c
diff options
context:
space:
mode:
authorUoti Urpala <uau@symbol.nonexistent.invalid>2008-08-13 08:06:26 +0300
committerUoti Urpala <uau@symbol.nonexistent.invalid>2008-08-13 08:06:26 +0300
commit8ea7eb77fc7ba8bd0b596ea32ee60909a012828f (patch)
tree6d997337d31fe3577a66df3bb5a4c87b3b26fccc /command.c
parente107cf785132418cc658e1cee4ad814e17eac886 (diff)
downloadmpv-8ea7eb77fc7ba8bd0b596ea32ee60909a012828f.tar.bz2
mpv-8ea7eb77fc7ba8bd0b596ea32ee60909a012828f.tar.xz
core: Clean up move-to-next-file logic
The mpctx->eof field was used to also store other reasons to stop playing the current file besides EOF, and the code didn't properly distinguish those from EOF. Rename the field to "stop_play" and clean up some of the code accessing it. Properly separating EOF from other reasons allows handling file switching better. Before this commit buffered audio was always drained before moving to the next file (the only exception when it was NOT drained when stopping a file was when quitting the player completely). This added an extra delay when manually moving to the next file as you had to wait for the currently buffered audio to finish playing before the next file would start. After this commit audio is only drained if the file reaches EOF normally; otherwise audio is cut and the next file starts immediately.
Diffstat (limited to 'command.c')
-rw-r--r--command.c34
1 files changed, 19 insertions, 15 deletions
diff --git a/command.c b/command.c
index 418e30b84f..2bba96dca2 100644
--- a/command.c
+++ b/command.c
@@ -2513,12 +2513,12 @@ int run_command(MPContext *mpctx, mp_cmd_t *cmd)
play_tree_iter_new_copy(mpctx->playtree_iter);
if (play_tree_iter_step(i, n, 0) ==
PLAY_TREE_ITER_ENTRY)
- mpctx->eof =
+ mpctx->stop_play =
(n > 0) ? PT_NEXT_ENTRY : PT_PREV_ENTRY;
play_tree_iter_free(i);
} else
- mpctx->eof = (n > 0) ? PT_NEXT_ENTRY : PT_PREV_ENTRY;
- if (mpctx->eof)
+ mpctx->stop_play = (n > 0) ? PT_NEXT_ENTRY : PT_PREV_ENTRY;
+ if (mpctx->stop_play)
mpctx->play_tree_step = n;
brk_cmd = 1;
}
@@ -2533,10 +2533,10 @@ int run_command(MPContext *mpctx, mp_cmd_t *cmd)
play_tree_iter_t *i =
play_tree_iter_new_copy(mpctx->playtree_iter);
if (play_tree_iter_up_step(i, n, 0) == PLAY_TREE_ITER_ENTRY)
- mpctx->eof = (n > 0) ? PT_UP_NEXT : PT_UP_PREV;
+ mpctx->stop_play = (n > 0) ? PT_UP_NEXT : PT_UP_PREV;
play_tree_iter_free(i);
} else
- mpctx->eof = (n > 0) ? PT_UP_NEXT : PT_UP_PREV;
+ mpctx->stop_play = (n > 0) ? PT_UP_NEXT : PT_UP_PREV;
brk_cmd = 1;
}
break;
@@ -2547,9 +2547,9 @@ int run_command(MPContext *mpctx, mp_cmd_t *cmd)
if (v > 0
&& mpctx->playtree_iter->file <
mpctx->playtree_iter->num_files)
- mpctx->eof = PT_NEXT_SRC;
+ mpctx->stop_play = PT_NEXT_SRC;
else if (v < 0 && mpctx->playtree_iter->file > 1)
- mpctx->eof = PT_PREV_SRC;
+ mpctx->stop_play = PT_PREV_SRC;
}
brk_cmd = 1;
break;
@@ -2632,7 +2632,7 @@ int run_command(MPContext *mpctx, mp_cmd_t *cmd)
play_tree_free_list(mpctx->playtree->child, 1);
play_tree_set_child(mpctx->playtree, e);
play_tree_iter_step(mpctx->playtree_iter, 0, 0);
- mpctx->eof = PT_NEXT_SRC;
+ mpctx->stop_play = PT_NEXT_SRC;
}
brk_cmd = 1;
}
@@ -2655,7 +2655,7 @@ int run_command(MPContext *mpctx, mp_cmd_t *cmd)
play_tree_free_list(mpctx->playtree->child, 1);
play_tree_set_child(mpctx->playtree, e);
play_tree_iter_step(mpctx->playtree_iter, 0, 0);
- mpctx->eof = PT_NEXT_SRC;
+ mpctx->stop_play = PT_NEXT_SRC;
}
}
brk_cmd = 1;
@@ -2667,7 +2667,7 @@ int run_command(MPContext *mpctx, mp_cmd_t *cmd)
while (play_tree_iter_up_step
(mpctx->playtree_iter, 0, 1) != PLAY_TREE_ITER_END)
/* NOP */ ;
- mpctx->eof = PT_STOP;
+ mpctx->stop_play = PT_STOP;
brk_cmd = 1;
break;
@@ -2790,8 +2790,10 @@ int run_command(MPContext *mpctx, mp_cmd_t *cmd)
dir = DVB_CHANNEL_LOWER;
- if (dvb_step_channel(mpctx->stream, dir))
- mpctx->eof = mpctx->dvbin_reopen = 1;
+ if (dvb_step_channel(mpctx->stream, dir)) {
+ mpctx->stop_play = PT_NEXT_ENTRY;
+ mpctx->dvbin_reopen = 1;
+ }
}
#endif /* CONFIG_DVBIN */
break;
@@ -2821,9 +2823,11 @@ int run_command(MPContext *mpctx, mp_cmd_t *cmd)
if (mpctx->stream->type == STREAMTYPE_DVB) {
mpctx->last_dvb_step = 1;
- if (dvb_set_channel
- (mpctx->stream, cmd->args[1].v.i, cmd->args[0].v.i))
- mpctx->eof = mpctx->dvbin_reopen = 1;
+ if (dvb_set_channel(mpctx->stream, cmd->args[1].v.i,
+ cmd->args[0].v.i)) {
+ mpctx->stop_play = PT_NEXT_ENTRY;
+ mpctx->dvbin_reopen = 1;
+ }
}
break;
#endif /* CONFIG_DVBIN */