mirror of
https://github.com/mpv-player/mpv
synced 2025-01-16 22:37:28 +01:00
Move loop_times to option struct
This commit is contained in:
parent
67778746ce
commit
ef74d21b1f
@ -89,6 +89,7 @@ const m_option_t tvscan_conf[]={
|
||||
|
||||
#define FLAG_ON(optname, varname, flags) {optname, NULL, CONF_TYPE_FLAG, flags, 0, 1, NULL, 1, offsetof(struct MPOpts, varname)}
|
||||
#define FLAG_OFF(optname, varname, flags) {optname, NULL, CONF_TYPE_FLAG, flags, 1, 0, NULL, 1, offsetof(struct MPOpts, varname)}
|
||||
#define FLAG_CONSTANTS(optname, varname, offvalue, value, flags) {optname, NULL, CONF_TYPE_FLAG, flags, offvalue, value, NULL, 1, offsetof(struct MPOpts, varname)}
|
||||
#define STRINGLIST(optname, varname, flags) {optname, NULL, CONF_TYPE_STRING_LIST, flags, 0, 0, NULL, 1, offsetof(struct MPOpts, varname)}
|
||||
#define INTRANGE(optname, varname, min, max, flags) {optname, NULL, CONF_TYPE_INT, (flags)|CONF_RANGE, min, max, NULL, 1, offsetof(struct MPOpts, varname)}
|
||||
|
||||
@ -322,8 +323,8 @@ const m_option_t mplayer_opts[]={
|
||||
{"guiwid", &guiWinID, CONF_TYPE_INT, 0, 0, 0, NULL},
|
||||
#endif
|
||||
|
||||
{"noloop", &mpctx_s.loop_times, CONF_TYPE_FLAG, 0, 0, -1, NULL},
|
||||
{"loop", &mpctx_s.loop_times, CONF_TYPE_INT, CONF_RANGE, -1, 10000, NULL},
|
||||
FLAG_CONSTANTS("noloop", loop_times, 0, -1, 0),
|
||||
INTRANGE("loop", loop_times, -1, 10000, 0),
|
||||
{"playlist", NULL, CONF_TYPE_STRING, 0, 0, 0, NULL},
|
||||
|
||||
// a-v sync stuff:
|
||||
|
@ -177,18 +177,19 @@ static int mp_property_osdlevel(m_option_t * prop, int action, void *arg,
|
||||
static int mp_property_loop(m_option_t * prop, int action, void *arg,
|
||||
MPContext * mpctx)
|
||||
{
|
||||
struct MPOpts *opts = &mpctx->opts;
|
||||
switch (action) {
|
||||
case M_PROPERTY_PRINT:
|
||||
if (!arg) return M_PROPERTY_ERROR;
|
||||
if (mpctx->loop_times < 0)
|
||||
if (opts->loop_times < 0)
|
||||
*(char**)arg = strdup("off");
|
||||
else if (mpctx->loop_times == 0)
|
||||
else if (opts->loop_times == 0)
|
||||
*(char**)arg = strdup("inf");
|
||||
else
|
||||
break;
|
||||
return M_PROPERTY_OK;
|
||||
}
|
||||
return m_property_int_range(prop, action, arg, &mpctx->loop_times);
|
||||
return m_property_int_range(prop, action, arg, &opts->loop_times);
|
||||
}
|
||||
|
||||
/// Playback speed (RW)
|
||||
|
@ -8,6 +8,7 @@ void set_default_mplayer_options(struct MPOpts *opts)
|
||||
.audio_driver_list = NULL,
|
||||
.video_driver_list = NULL,
|
||||
.fixed_vo = 0,
|
||||
.loop_times = -1,
|
||||
.user_correct_pts = -1,
|
||||
};
|
||||
}
|
||||
|
@ -52,7 +52,6 @@ typedef struct MPContext {
|
||||
play_tree_iter_t *playtree_iter;
|
||||
int eof;
|
||||
int play_tree_step;
|
||||
int loop_times;
|
||||
|
||||
stream_t *stream;
|
||||
demuxer_t *demuxer;
|
||||
|
13
mplayer.c
13
mplayer.c
@ -200,7 +200,6 @@ static MPContext mpctx_s = {
|
||||
.global_sub_pos = -1,
|
||||
.set_of_sub_pos = -1,
|
||||
.file_format = DEMUXER_TYPE_UNKNOWN,
|
||||
.loop_times = -1,
|
||||
.last_dvb_step = 1,
|
||||
};
|
||||
|
||||
@ -3641,8 +3640,8 @@ if (mpctx->stream->type==STREAMTYPE_TV) mp_input_set_section("tv");
|
||||
|
||||
//==================== START PLAYING =======================
|
||||
|
||||
if(mpctx->loop_times>1) mpctx->loop_times--; else
|
||||
if(mpctx->loop_times==1) mpctx->loop_times = -1;
|
||||
if(opts->loop_times>1) opts->loop_times--; else
|
||||
if(opts->loop_times==1) opts->loop_times = -1;
|
||||
|
||||
mp_msg(MSGT_CPLAYER,MSGL_INFO,MSGTR_StartPlaying);
|
||||
|
||||
@ -3861,11 +3860,11 @@ if(step_sec>0) {
|
||||
mpctx->was_paused = 0;
|
||||
|
||||
/* Looping. */
|
||||
if(mpctx->eof==1 && mpctx->loop_times>=0) {
|
||||
mp_msg(MSGT_CPLAYER,MSGL_V,"loop_times = %d, eof = %d\n", mpctx->loop_times,mpctx->eof);
|
||||
if(mpctx->eof==1 && opts->loop_times>=0) {
|
||||
mp_msg(MSGT_CPLAYER,MSGL_V,"loop_times = %d, eof = %d\n", opts->loop_times,mpctx->eof);
|
||||
|
||||
if(mpctx->loop_times>1) mpctx->loop_times--; else
|
||||
if(mpctx->loop_times==1) mpctx->loop_times=-1;
|
||||
if(opts->loop_times>1) opts->loop_times--; else
|
||||
if(opts->loop_times==1) opts->loop_times=-1;
|
||||
play_n_frames=play_n_frames_mf;
|
||||
mpctx->eof=0;
|
||||
abs_seek_pos=SEEK_ABSOLUTE; rel_seek_secs=seek_to_sec;
|
||||
|
Loading…
Reference in New Issue
Block a user