summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: 214eea1)
raw | patch | inline | side by side (parent: 214eea1)
author | Max Kellermann <max.kellermann@gmail.com> | |
Sun, 19 Mar 2017 12:10:43 +0000 (13:10 +0100) | ||
committer | Max Kellermann <max.kellermann@gmail.com> | |
Sun, 19 Mar 2017 12:10:43 +0000 (13:10 +0100) |
Return early from mpdclient_cmd_volume_*(), without calling
mpdclient_get_connection(), if we already know the operation would
have no effect.
mpdclient_get_connection(), if we already know the operation would
have no effect.
src/mpdclient.c | patch | blob | history |
diff --git a/src/mpdclient.c b/src/mpdclient.c
index a4e165e9b249c419f96e4cace8903fd099126823..73bb85f337c5679092e07e7526066fa36861676b 100644 (file)
--- a/src/mpdclient.c
+++ b/src/mpdclient.c
bool
mpdclient_cmd_volume_up(struct mpdclient *c)
{
+ if (c->volume < 0 || c->volume >= 100)
+ return true;
+
struct mpd_connection *connection = mpdclient_get_connection(c);
if (connection == NULL)
return false;
- if (c->status == NULL ||
- mpd_status_get_volume(c->status) == -1)
- return true;
-
- if (c->volume < 0)
- c->volume = mpd_status_get_volume(c->status);
-
- if (c->volume >= 100)
- return true;
-
return mpdclient_cmd_volume(c, ++c->volume);
}
bool
mpdclient_cmd_volume_down(struct mpdclient *c)
{
+ if (c->volume <= 0)
+ return true;
+
struct mpd_connection *connection = mpdclient_get_connection(c);
if (connection == NULL)
return false;
- if (c->status == NULL || mpd_status_get_volume(c->status) < 0)
- return true;
-
- if (c->volume < 0)
- c->volume = mpd_status_get_volume(c->status);
-
- if (c->volume <= 0)
- return true;
-
return mpdclient_cmd_volume(c, --c->volume);
}