mirror of
https://github.com/mpv-player/mpv
synced 2025-04-11 04:01:31 +00:00
options: remove CONF_TYPE_POSITION
This was the option parser for the off_t C type. These days, off_t is always int64_t, so replace all its uses by int64_t and CONF_TYPE_INT64. Fix the --sstep option. It used CONF_TYPE_INT with an off_t variable, which will result in invalid memory accesses. Make it use type double instead, which seems to make more sense for this option.
This commit is contained in:
parent
10437c35df
commit
3d67041089
@ -381,7 +381,7 @@ const m_option_t common_opts[] = {
|
|||||||
{"frames", &play_n_frames_mf, CONF_TYPE_INT, CONF_MIN, 0, 0, NULL},
|
{"frames", &play_n_frames_mf, CONF_TYPE_INT, CONF_MIN, 0, 0, NULL},
|
||||||
|
|
||||||
// seek to byte/seconds position
|
// seek to byte/seconds position
|
||||||
{"sb", &seek_to_byte, CONF_TYPE_POSITION, CONF_MIN, 0, 0, NULL},
|
{"sb", &seek_to_byte, CONF_TYPE_INT64, CONF_MIN, 0, 0, NULL},
|
||||||
OPT_TIME("ss", seek_to_sec, 0),
|
OPT_TIME("ss", seek_to_sec, 0),
|
||||||
|
|
||||||
// start paused
|
// start paused
|
||||||
@ -678,7 +678,7 @@ const m_option_t mplayer_opts[]={
|
|||||||
OPT_STRING("vobsub", vobsub_name, 0),
|
OPT_STRING("vobsub", vobsub_name, 0),
|
||||||
{"vobsubid", &vobsub_id, CONF_TYPE_INT, CONF_RANGE, 0, 31, NULL},
|
{"vobsubid", &vobsub_id, CONF_TYPE_INT, CONF_RANGE, 0, 31, NULL},
|
||||||
|
|
||||||
{"sstep", &step_sec, CONF_TYPE_INT, CONF_MIN, 0, 0, NULL},
|
{"sstep", &step_sec, CONF_TYPE_DOUBLE, CONF_MIN, 0, 0, NULL},
|
||||||
|
|
||||||
OPT_CHOICE("framedrop", frame_dropping, 0,
|
OPT_CHOICE("framedrop", frame_dropping, 0,
|
||||||
({"no", 0},
|
({"no", 0},
|
||||||
|
24
command.c
24
command.c
@ -261,11 +261,11 @@ static int mp_property_stream_pos(m_option_t *prop, int action, void *arg,
|
|||||||
return M_PROPERTY_ERROR;
|
return M_PROPERTY_ERROR;
|
||||||
switch (action) {
|
switch (action) {
|
||||||
case M_PROPERTY_GET:
|
case M_PROPERTY_GET:
|
||||||
*(off_t *) arg = stream_tell(stream);
|
*(int64_t *) arg = stream_tell(stream);
|
||||||
return M_PROPERTY_OK;
|
return M_PROPERTY_OK;
|
||||||
case M_PROPERTY_SET:
|
case M_PROPERTY_SET:
|
||||||
M_PROPERTY_CLAMP(prop, *(off_t *) arg);
|
M_PROPERTY_CLAMP(prop, *(int64_t *) arg);
|
||||||
stream_seek(stream, *(off_t *) arg);
|
stream_seek(stream, *(int64_t *) arg);
|
||||||
return M_PROPERTY_OK;
|
return M_PROPERTY_OK;
|
||||||
}
|
}
|
||||||
return M_PROPERTY_NOT_IMPLEMENTED;
|
return M_PROPERTY_NOT_IMPLEMENTED;
|
||||||
@ -280,7 +280,7 @@ static int mp_property_stream_start(m_option_t *prop, int action,
|
|||||||
return M_PROPERTY_UNAVAILABLE;
|
return M_PROPERTY_UNAVAILABLE;
|
||||||
switch (action) {
|
switch (action) {
|
||||||
case M_PROPERTY_GET:
|
case M_PROPERTY_GET:
|
||||||
*(off_t *) arg = stream->start_pos;
|
*(int64_t *) arg = stream->start_pos;
|
||||||
return M_PROPERTY_OK;
|
return M_PROPERTY_OK;
|
||||||
}
|
}
|
||||||
return M_PROPERTY_NOT_IMPLEMENTED;
|
return M_PROPERTY_NOT_IMPLEMENTED;
|
||||||
@ -295,7 +295,7 @@ static int mp_property_stream_end(m_option_t *prop, int action, void *arg,
|
|||||||
return M_PROPERTY_UNAVAILABLE;
|
return M_PROPERTY_UNAVAILABLE;
|
||||||
switch (action) {
|
switch (action) {
|
||||||
case M_PROPERTY_GET:
|
case M_PROPERTY_GET:
|
||||||
*(off_t *) arg = stream->end_pos;
|
*(int64_t *) arg = stream->end_pos;
|
||||||
return M_PROPERTY_OK;
|
return M_PROPERTY_OK;
|
||||||
}
|
}
|
||||||
return M_PROPERTY_NOT_IMPLEMENTED;
|
return M_PROPERTY_NOT_IMPLEMENTED;
|
||||||
@ -310,7 +310,7 @@ static int mp_property_stream_length(m_option_t *prop, int action,
|
|||||||
return M_PROPERTY_UNAVAILABLE;
|
return M_PROPERTY_UNAVAILABLE;
|
||||||
switch (action) {
|
switch (action) {
|
||||||
case M_PROPERTY_GET:
|
case M_PROPERTY_GET:
|
||||||
*(off_t *) arg = stream->end_pos - stream->start_pos;
|
*(int64_t *) arg = stream->end_pos - stream->start_pos;
|
||||||
return M_PROPERTY_OK;
|
return M_PROPERTY_OK;
|
||||||
}
|
}
|
||||||
return M_PROPERTY_NOT_IMPLEMENTED;
|
return M_PROPERTY_NOT_IMPLEMENTED;
|
||||||
@ -1650,13 +1650,13 @@ static const m_option_t mp_properties[] = {
|
|||||||
0, 0, 0, NULL },
|
0, 0, 0, NULL },
|
||||||
{ "demuxer", mp_property_demuxer, CONF_TYPE_STRING,
|
{ "demuxer", mp_property_demuxer, CONF_TYPE_STRING,
|
||||||
0, 0, 0, NULL },
|
0, 0, 0, NULL },
|
||||||
{ "stream-pos", mp_property_stream_pos, CONF_TYPE_POSITION,
|
{ "stream-pos", mp_property_stream_pos, CONF_TYPE_INT64,
|
||||||
M_OPT_MIN, 0, 0, NULL },
|
M_OPT_MIN, 0, 0, NULL },
|
||||||
{ "stream-start", mp_property_stream_start, CONF_TYPE_POSITION,
|
{ "stream-start", mp_property_stream_start, CONF_TYPE_INT64,
|
||||||
M_OPT_MIN, 0, 0, NULL },
|
M_OPT_MIN, 0, 0, NULL },
|
||||||
{ "stream-end", mp_property_stream_end, CONF_TYPE_POSITION,
|
{ "stream-end", mp_property_stream_end, CONF_TYPE_INT64,
|
||||||
M_OPT_MIN, 0, 0, NULL },
|
M_OPT_MIN, 0, 0, NULL },
|
||||||
{ "stream-length", mp_property_stream_length, CONF_TYPE_POSITION,
|
{ "stream-length", mp_property_stream_length, CONF_TYPE_INT64,
|
||||||
M_OPT_MIN, 0, 0, NULL },
|
M_OPT_MIN, 0, 0, NULL },
|
||||||
{ "stream-time-pos", mp_property_stream_time_pos, CONF_TYPE_TIME,
|
{ "stream-time-pos", mp_property_stream_time_pos, CONF_TYPE_TIME,
|
||||||
M_OPT_MIN, 0, 0, NULL },
|
M_OPT_MIN, 0, 0, NULL },
|
||||||
@ -2118,7 +2118,7 @@ void run_command(MPContext *mpctx, mp_cmd_t *cmd)
|
|||||||
void *arg = NULL;
|
void *arg = NULL;
|
||||||
int r, i;
|
int r, i;
|
||||||
double d;
|
double d;
|
||||||
off_t o;
|
int64_t o;
|
||||||
cmd->args[0].v.s = translate_legacy_property(cmd, cmd->args[0].v.s);
|
cmd->args[0].v.s = translate_legacy_property(cmd, cmd->args[0].v.s);
|
||||||
if (cmd->args[1].v.f) {
|
if (cmd->args[1].v.f) {
|
||||||
m_option_t *prop;
|
m_option_t *prop;
|
||||||
@ -2135,7 +2135,7 @@ void run_command(MPContext *mpctx, mp_cmd_t *cmd)
|
|||||||
else if (prop->type == CONF_TYPE_DOUBLE ||
|
else if (prop->type == CONF_TYPE_DOUBLE ||
|
||||||
prop->type == CONF_TYPE_TIME)
|
prop->type == CONF_TYPE_TIME)
|
||||||
d = cmd->args[1].v.f, arg = &d;
|
d = cmd->args[1].v.f, arg = &d;
|
||||||
else if (prop->type == CONF_TYPE_POSITION)
|
else if (prop->type == CONF_TYPE_INT64)
|
||||||
o = cmd->args[1].v.f, arg = &o;
|
o = cmd->args[1].v.f, arg = &o;
|
||||||
else
|
else
|
||||||
mp_msg(MSGT_CPLAYER, MSGL_WARN,
|
mp_msg(MSGT_CPLAYER, MSGL_WARN,
|
||||||
|
29
m_option.c
29
m_option.c
@ -423,35 +423,6 @@ const m_option_type_t m_option_type_float = {
|
|||||||
.copy = copy_opt,
|
.copy = copy_opt,
|
||||||
};
|
};
|
||||||
|
|
||||||
///////////// Position
|
|
||||||
#undef VAL
|
|
||||||
#define VAL(x) (*(off_t *)(x))
|
|
||||||
|
|
||||||
static int parse_position(const m_option_t *opt, struct bstr name,
|
|
||||||
struct bstr param, void *dst)
|
|
||||||
{
|
|
||||||
long long tmp;
|
|
||||||
int r = parse_longlong(opt, name, param, &tmp);
|
|
||||||
if (r >= 0 && dst)
|
|
||||||
*(off_t *)dst = tmp;
|
|
||||||
return r;
|
|
||||||
}
|
|
||||||
|
|
||||||
static char *print_position(const m_option_t *opt, const void *val)
|
|
||||||
{
|
|
||||||
return talloc_asprintf(NULL, "%"PRId64, (int64_t)VAL(val));
|
|
||||||
}
|
|
||||||
|
|
||||||
const m_option_type_t m_option_type_position = {
|
|
||||||
// Integer (off_t)
|
|
||||||
.name = "Position",
|
|
||||||
.size = sizeof(off_t),
|
|
||||||
.parse = parse_position,
|
|
||||||
.print = print_position,
|
|
||||||
.copy = copy_opt,
|
|
||||||
};
|
|
||||||
|
|
||||||
|
|
||||||
///////////// String
|
///////////// String
|
||||||
|
|
||||||
#undef VAL
|
#undef VAL
|
||||||
|
@ -43,7 +43,6 @@ extern const m_option_type_t m_option_type_float;
|
|||||||
extern const m_option_type_t m_option_type_double;
|
extern const m_option_type_t m_option_type_double;
|
||||||
extern const m_option_type_t m_option_type_string;
|
extern const m_option_type_t m_option_type_string;
|
||||||
extern const m_option_type_t m_option_type_string_list;
|
extern const m_option_type_t m_option_type_string_list;
|
||||||
extern const m_option_type_t m_option_type_position;
|
|
||||||
extern const m_option_type_t m_option_type_time;
|
extern const m_option_type_t m_option_type_time;
|
||||||
extern const m_option_type_t m_option_type_time_size;
|
extern const m_option_type_t m_option_type_time_size;
|
||||||
extern const m_option_type_t m_option_type_choice;
|
extern const m_option_type_t m_option_type_choice;
|
||||||
@ -167,7 +166,6 @@ struct m_sub_options {
|
|||||||
#define CONF_TYPE_PRINT_FUNC (&m_option_type_print_func)
|
#define CONF_TYPE_PRINT_FUNC (&m_option_type_print_func)
|
||||||
#define CONF_TYPE_SUBCONFIG (&m_option_type_subconfig)
|
#define CONF_TYPE_SUBCONFIG (&m_option_type_subconfig)
|
||||||
#define CONF_TYPE_STRING_LIST (&m_option_type_string_list)
|
#define CONF_TYPE_STRING_LIST (&m_option_type_string_list)
|
||||||
#define CONF_TYPE_POSITION (&m_option_type_position)
|
|
||||||
#define CONF_TYPE_IMGFMT (&m_option_type_imgfmt)
|
#define CONF_TYPE_IMGFMT (&m_option_type_imgfmt)
|
||||||
#define CONF_TYPE_AFMT (&m_option_type_afmt)
|
#define CONF_TYPE_AFMT (&m_option_type_afmt)
|
||||||
#define CONF_TYPE_SPAN (&m_option_type_span)
|
#define CONF_TYPE_SPAN (&m_option_type_span)
|
||||||
|
@ -204,8 +204,8 @@ static const char av_desync_help_text[] = _(
|
|||||||
static int drop_frame_cnt; // total number of dropped frames
|
static int drop_frame_cnt; // total number of dropped frames
|
||||||
|
|
||||||
// seek:
|
// seek:
|
||||||
static off_t seek_to_byte;
|
static int64_t seek_to_byte;
|
||||||
static off_t step_sec;
|
static double step_sec;
|
||||||
|
|
||||||
static m_time_size_t end_at = { .type = END_AT_NONE, .pos = 0 };
|
static m_time_size_t end_at = { .type = END_AT_NONE, .pos = 0 };
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user