From 11d0b04ef3c7c72e6aace1223822af30db5a52fc Mon Sep 17 00:00:00 2001 From: Mary Strodl Date: Tue, 13 Feb 2024 11:58:50 -0500 Subject: [PATCH] Add version gate --- src/command.c | 5 +++++ src/status.c | 6 ++++++ src/status_format.c | 8 ++++++++ 3 files changed, 19 insertions(+) diff --git a/src/command.c b/src/command.c index 1bf6713..5dfc5ea 100644 --- a/src/command.c +++ b/src/command.c @@ -1093,6 +1093,7 @@ cmd_single(int argc, char **argv, struct mpd_connection *conn) int cmd_consume(int argc, char **argv, struct mpd_connection *conn) { +#if LIBMPDCLIENT_CHECK_VERSION(2,21,0) enum mpd_consume_state mode = MPD_CONSUME_UNKNOWN; if (argc == 1) { @@ -1126,6 +1127,10 @@ cmd_consume(int argc, char **argv, struct mpd_connection *conn) printErrorAndExit(conn); return 1; +#else + return bool_cmd(argc, argv, conn, + mpd_status_get_consume, mpd_run_consume); +#endif } int diff --git a/src/status.c b/src/status.c index 6c38135..c559b0d 100644 --- a/src/status.c +++ b/src/status.c @@ -83,12 +83,18 @@ print_status(struct mpd_connection *conn) printf("off "); printf("consume: "); +#if LIBMPDCLIENT_CHECK_VERSION(2,21,0) if (mpd_status_get_consume_state(status) == MPD_CONSUME_ON) printf("on \n"); else if (mpd_status_get_consume_state(status) == MPD_CONSUME_ONESHOT) printf("once\n"); else if (mpd_status_get_consume_state(status) == MPD_CONSUME_OFF) printf("off \n"); +#else + if (mpd_status_get_consume(status)) + printf("on \n"); + else printf("off\n"); +#endif if (mpd_status_get_error(status) != NULL) printf("ERROR: %s\n", diff --git a/src/status_format.c b/src/status_format.c index d6d9b04..8f5c935 100644 --- a/src/status_format.c +++ b/src/status_format.c @@ -89,6 +89,7 @@ status_value(const struct mpd_status *status, const char *name) return "off"; } } else if (strcmp(name, "consume") == 0) { +#if LIBMPDCLIENT_CHECK_VERSION(2,21,0) if (mpd_status_get_consume_state(status) == MPD_CONSUME_ON) { return "on"; } else if (mpd_status_get_consume_state(status) == MPD_CONSUME_ONESHOT) { @@ -96,6 +97,13 @@ status_value(const struct mpd_status *status, const char *name) } else if (mpd_status_get_consume_state(status) == MPD_CONSUME_OFF) { return "off"; } +#else + if (mpd_status_get_consume(status)) { + return "on"; + } else { + return "off"; + } +#endif } else if (strcmp(name, "kbitrate") == 0) { sprintf(buffer, "%u", mpd_status_get_kbit_rate(status)); } else if (strcmp(name, "audioformat") == 0) {