From 52ce4aea44ef42d8690a2ebc1ed1eb7a999cb29f Mon Sep 17 00:00:00 2001 From: Max Kellermann Date: Thu, 21 Dec 2017 11:31:55 +0100 Subject: [PATCH] output: add _get_plugin() --- NEWS | 1 + include/mpd/output.h | 10 ++++++++++ libmpdclient.ld | 1 + src/output.c | 16 ++++++++++++++++ 4 files changed, 28 insertions(+) diff --git a/NEWS b/NEWS index 6f08e17..3c9a356 100644 --- a/NEWS +++ b/NEWS @@ -1,6 +1,7 @@ libmpdclient 2.14 (not yet released) * support MPD protocol 0.21 - command "outputset" + - mpd_output_get_plugin() * MSVC compatibility * improved local and abstract socket support diff --git a/include/mpd/output.h b/include/mpd/output.h index bd7120c..858c9ee 100644 --- a/include/mpd/output.h +++ b/include/mpd/output.h @@ -100,6 +100,16 @@ const char * mpd_output_get_name(const struct mpd_output *output); /** + * @return the plugin of the specified #mpd_output object, or NULL if + * none was specified by the server + * + * @since libmpdclient 2.14, MPD 0.21 + */ +mpd_pure +const char * +mpd_output_get_plugin(const struct mpd_output *output); + +/** * @return true if this output is enabled */ mpd_pure diff --git a/libmpdclient.ld b/libmpdclient.ld index 0dfc87a..49f5a6c 100644 --- a/libmpdclient.ld +++ b/libmpdclient.ld @@ -119,6 +119,7 @@ global: mpd_output_free; mpd_output_get_id; mpd_output_get_name; + mpd_output_get_plugin; mpd_output_get_enabled; mpd_send_outputs; mpd_recv_output; diff --git a/src/output.c b/src/output.c index df82835..5dec9c5 100644 --- a/src/output.c +++ b/src/output.c @@ -40,6 +40,7 @@ struct mpd_output { unsigned id; char *name; + char *plugin; bool enabled; }; @@ -60,6 +61,7 @@ mpd_output_begin(const struct mpd_pair *pair) output->id = atoi(pair->value); output->name = NULL; + output->plugin = NULL; output->enabled = false; return output; @@ -78,6 +80,12 @@ mpd_output_feed(struct mpd_output *output, const struct mpd_pair *pair) output->name = strdup(pair->value); } else if (strcmp(pair->name, "outputenabled") == 0) output->enabled = atoi(pair->value) != 0; + else if (strcmp(pair->name, "plugin") == 0) { + if (output->plugin != NULL) + free(output->plugin); + + output->plugin = strdup(pair->value); + } return true; } @@ -108,6 +116,14 @@ mpd_output_get_name(const struct mpd_output *output) return output->name; } +const char * +mpd_output_get_plugin(const struct mpd_output *output) +{ + assert(output != NULL); + + return output->plugin; +} + bool mpd_output_get_enabled(const struct mpd_output *output) { -- 2.11.4.GIT