From a522441bbe6817798ca58b93d7adb180a9598640 Mon Sep 17 00:00:00 2001 From: wm4 Date: Thu, 18 Sep 2014 00:12:59 +0200 Subject: command: add osd-sym-cc property This allows you to reproduce the OSD symbol. --- player/command.c | 11 +++++++++++ player/core.h | 1 + player/osd.c | 21 ++++++++++----------- 3 files changed, 22 insertions(+), 11 deletions(-) (limited to 'player') diff --git a/player/command.c b/player/command.c index 6c881bcfca..8c2856c360 100644 --- a/player/command.c +++ b/player/command.c @@ -2220,6 +2220,15 @@ static int mp_property_osd_par(void *ctx, struct m_property *prop, return m_property_double_ro(action, arg, vo_res.display_par); } +static int mp_property_osd_sym(void *ctx, struct m_property *prop, + int action, void *arg) +{ + MPContext *mpctx = ctx; + char temp[20]; + get_current_osd_sym(mpctx, temp, sizeof(temp)); + return m_property_strdup_ro(action, arg, temp); +} + /// Video fps (RO) static int mp_property_fps(void *ctx, struct m_property *prop, int action, void *arg) @@ -2806,6 +2815,8 @@ static const struct m_property mp_properties[] = { {"osd-height", mp_property_osd_h}, {"osd-par", mp_property_osd_par}, + {"osd-sym-cc", mp_property_osd_sym}, + // Subs {"sid", mp_property_sub}, {"secondary-sid", mp_property_sub2}, diff --git a/player/core.h b/player/core.h index 9d9fefee21..434be6e1e9 100644 --- a/player/core.h +++ b/player/core.h @@ -434,6 +434,7 @@ void set_osd_msg(struct MPContext *mpctx, int level, int time, const char* fmt, ...) PRINTF_ATTRIBUTE(4,5); void set_osd_function(struct MPContext *mpctx, int osd_function); void set_osd_subtitle(struct MPContext *mpctx, const char *text); +void get_current_osd_sym(struct MPContext *mpctx, char *buf, size_t buf_size); // playloop.c void mp_wait_events(struct MPContext *mpctx, double sleeptime); diff --git a/player/osd.c b/player/osd.c index 08bf28dd85..04b21a22f2 100644 --- a/player/osd.c +++ b/player/osd.c @@ -443,17 +443,8 @@ void set_osd_subtitle(struct MPContext *mpctx, const char *text) term_osd_set_subs(mpctx, text); } -// sym == mpctx->osd_function -static void saddf_osd_function_sym(char **buffer, int sym) +void get_current_osd_sym(struct MPContext *mpctx, char *buf, size_t buf_size) { - char temp[10]; - osd_get_function_sym(temp, sizeof(temp), sym); - saddf(buffer, "%s ", temp); -} - -static void sadd_osd_status(char **buffer, struct MPContext *mpctx, bool full) -{ - bool fractions = mpctx->opts->osd_fractions; int sym = mpctx->osd_function; if (!sym) { if (mpctx->paused_for_cache && !mpctx->opts->pause) { @@ -464,7 +455,15 @@ static void sadd_osd_status(char **buffer, struct MPContext *mpctx, bool full) sym = OSD_PLAY; } } - saddf_osd_function_sym(buffer, sym); + osd_get_function_sym(buf, buf_size, sym); +} + +static void sadd_osd_status(char **buffer, struct MPContext *mpctx, bool full) +{ + bool fractions = mpctx->opts->osd_fractions; + char sym[10]; + get_current_osd_sym(mpctx, sym, sizeof(sym)); + saddf(buffer, "%s ", sym); char *custom_msg = mpctx->opts->osd_status_msg; if (custom_msg && full) { char *text = mp_property_expand_escaped_string(mpctx, custom_msg); -- cgit v1.2.3