core: improve --loop handling

Make per-file loop option start from --ss position, not always 0.
Do looping in more cases; before looping was only done when
encountering real end of file, now it also happens for example at
--endpos or --frames limits. Also move the --ss option to the option
struct.
This commit is contained in:
Uoti Urpala 2011-07-28 11:39:43 +03:00
parent e873d703e9
commit f25accbc51
4 changed files with 9 additions and 7 deletions

View File

@ -497,7 +497,7 @@ const m_option_t common_opts[] = {
// seek to byte/seconds position
{"sb", &seek_to_byte, CONF_TYPE_POSITION, CONF_MIN, 0, 0, NULL},
{"ss", &seek_to_sec, CONF_TYPE_TIME, 0, 0, 0, NULL},
OPT_TIME("ss", seek_to_sec, 0),
// stop at given position
{"endpos", &end_at, CONF_TYPE_TIME_SIZE, 0, 0, 0, NULL},

View File

@ -499,5 +499,6 @@ static inline void m_option_free(const m_option_t *opt, void *dst)
#define OPT_AUDIOFORMAT(optname, varname, flags) {optname, NULL, &m_option_type_afmt, flags, 0, 0, NULL, 1, offsetof(struct MPOpts, varname)}
#define OPT_HELPER_REMOVEPAREN(...) __VA_ARGS__
#define OPT_CHOICE(optname, varname, flags, choices) {optname, NULL, &m_option_type_choice, flags, 0, 0, (void *)&(const struct m_opt_choice_alternatives[]){OPT_HELPER_REMOVEPAREN choices, {NULL}}, 1, offsetof(struct MPOpts, varname)}
#define OPT_TIME(optname, varname, flags) {optname, NULL, &m_option_type_time, flags, 0, 0, NULL, 1, offsetof(struct MPOpts, varname)}
#endif /* MPLAYER_M_OPTION_H */

View File

@ -282,7 +282,6 @@ static int drop_frame_cnt=0; // total number of dropped frames
static int output_quality=0;
// seek:
static double seek_to_sec;
static off_t seek_to_byte=0;
static off_t step_sec=0;
@ -3711,7 +3710,8 @@ static void run_playloop(struct MPContext *mpctx)
edl_update(mpctx);
/* Looping. */
if (mpctx->stop_play==AT_END_OF_FILE && opts->loop_times>=0) {
if (opts->loop_times >= 0 && (mpctx->stop_play == AT_END_OF_FILE ||
mpctx->stop_play == PT_NEXT_ENTRY)) {
mp_msg(MSGT_CPLAYER, MSGL_V, "loop_times = %d\n", opts->loop_times);
if (opts->loop_times>1)
@ -3720,7 +3720,7 @@ static void run_playloop(struct MPContext *mpctx)
opts->loop_times = -1;
play_n_frames = play_n_frames_mf;
mpctx->stop_play = 0;
queue_seek(mpctx, MPSEEK_ABSOLUTE, 0, 0);
queue_seek(mpctx, MPSEEK_ABSOLUTE, opts->seek_to_sec, 0);
}
if (mpctx->seek.type) {
@ -4792,10 +4792,10 @@ if(play_n_frames==0){
mpctx->last_chapter_seek = -1;
// If there's a timeline force an absolute seek to initialize state
if (seek_to_sec || mpctx->timeline) {
queue_seek(mpctx, MPSEEK_ABSOLUTE, seek_to_sec, 0);
if (opts->seek_to_sec || mpctx->timeline) {
queue_seek(mpctx, MPSEEK_ABSOLUTE, opts->seek_to_sec, 0);
seek(mpctx, mpctx->seek, false);
end_at.pos += seek_to_sec;
end_at.pos += opts->seek_to_sec;
}
if (opts->chapterrange[0] > 0) {
double pts;

View File

@ -62,6 +62,7 @@ typedef struct MPOpts {
int consolecontrols;
int doubleclick_time;
int list_properties;
double seek_to_sec;
int audio_id;
int video_id;
int sub_id;