From f25accbc510b641ac75a1f274376616417763ae5 Mon Sep 17 00:00:00 2001 From: Uoti Urpala Date: Thu, 28 Jul 2011 11:39:43 +0300 Subject: 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. --- cfg-mplayer.h | 2 +- m_option.h | 1 + mplayer.c | 12 ++++++------ options.h | 1 + 4 files changed, 9 insertions(+), 7 deletions(-) diff --git a/cfg-mplayer.h b/cfg-mplayer.h index b767d1c0f1..a07d5ee38e 100644 --- a/cfg-mplayer.h +++ b/cfg-mplayer.h @@ -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}, diff --git a/m_option.h b/m_option.h index 123e51005c..48f94781a3 100644 --- a/m_option.h +++ b/m_option.h @@ -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 */ diff --git a/mplayer.c b/mplayer.c index 0f36247c16..b0c49fcc14 100644 --- a/mplayer.c +++ b/mplayer.c @@ -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; diff --git a/options.h b/options.h index 46d1cf85b7..3349d52edf 100644 --- a/options.h +++ b/options.h @@ -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; -- cgit v1.2.3