Skip to content

Commit

Permalink
m_option: add print callback to start/end/length
Browse files Browse the repository at this point in the history
  • Loading branch information
wiiaboo authored and kevmitch committed Jan 3, 2018
1 parent c809b73 commit 877775f
Showing 1 changed file with 18 additions and 0 deletions.
18 changes: 18 additions & 0 deletions options/m_option.c
Original file line number Diff line number Diff line change
Expand Up @@ -2431,10 +2431,28 @@ static int parse_rel_time(struct mp_log *log, const m_option_t *opt,
return 1;
}

static char *print_rel_time(const m_option_t *opt, const void *val)
{
const struct m_rel_time *t = val;
switch(t->type) {
case REL_TIME_ABSOLUTE:
return talloc_asprintf(NULL, "%g", t->pos);
case REL_TIME_RELATIVE:
return talloc_asprintf(NULL, "%s%g",
(t->pos >= 0) ? "+" : "-", fabs(t->pos));
case REL_TIME_CHAPTER:
return talloc_asprintf(NULL, "#%g", t->pos);
case REL_TIME_PERCENT:
return talloc_asprintf(NULL, "%g%%", t->pos);
}
return talloc_strdup(NULL, "none");
}

const m_option_type_t m_option_type_rel_time = {
.name = "Relative time or percent position",
.size = sizeof(struct m_rel_time),
.parse = parse_rel_time,
.print = print_rel_time,
.copy = copy_opt,
};

Expand Down

0 comments on commit 877775f

Please sign in to comment.