Skip to content

Commit

Permalink
Add version gate
Browse files Browse the repository at this point in the history
  • Loading branch information
Mstrodl committed Feb 13, 2024
1 parent 52c493b commit 11d0b04
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 0 deletions.
5 changes: 5 additions & 0 deletions src/command.c
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down Expand Up @@ -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
Expand Down
6 changes: 6 additions & 0 deletions src/status.c
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
8 changes: 8 additions & 0 deletions src/status_format.c
Original file line number Diff line number Diff line change
Expand Up @@ -89,13 +89,21 @@ 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) {
return "once";
} 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) {
Expand Down

0 comments on commit 11d0b04

Please sign in to comment.