From 694157e024e52e6fcb01cfd2e9c6d50b85f9621f Mon Sep 17 00:00:00 2001 From: wm4 Date: Mon, 30 Oct 2017 14:56:50 +0100 Subject: m_option: pretty print mpv_node for OSD Somewhat useful for debugging. Unfortunately libass (or something else) strips leading whitespace, making it look slightly more ugly than necessary. Still an improvement. --- options/m_option.c | 11 +++++++++++ 1 file changed, 11 insertions(+) (limited to 'options') diff --git a/options/m_option.c b/options/m_option.c index 00ea5d6d93..9472f3c870 100644 --- a/options/m_option.c +++ b/options/m_option.c @@ -3249,6 +3249,16 @@ static char *print_node(const m_option_t *opt, const void *val) return t; } +static char *pretty_print_node(const m_option_t *opt, const void *val) +{ + char *t = talloc_strdup(NULL, ""); + if (json_write_pretty(&t, &VAL(val)) < 0) { + talloc_free(t); + t = NULL; + } + return t; +} + static void dup_node(void *ta_parent, struct mpv_node *node) { switch (node->format) { @@ -3342,6 +3352,7 @@ const m_option_type_t m_option_type_node = { .size = sizeof(struct mpv_node), .parse = parse_node, .print = print_node, + .pretty_print = pretty_print_node, .copy = copy_node, .free = free_node, .set = node_set, -- cgit v1.2.3