summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: 1ba1a67)
raw | patch | inline | side by side (parent: 1ba1a67)
author | Max Kellermann <max@duempel.org> | |
Fri, 12 Jun 2009 17:41:24 +0000 (19:41 +0200) | ||
committer | Max Kellermann <max@duempel.org> | |
Fri, 12 Jun 2009 17:41:24 +0000 (19:41 +0200) |
src/mpdclient.c | patch | blob | history | |
src/mpdclient.h | patch | blob | history | |
src/screen.c | patch | blob | history |
diff --git a/src/mpdclient.c b/src/mpdclient.c
index 496d904129968038ea4e106030483682a56149ed..4a12515752b9037366d99f1662022ea4269289e3 100644 (file)
--- a/src/mpdclient.c
+++ b/src/mpdclient.c
c = g_malloc0(sizeof(mpdclient_t));
playlist_init(&c->playlist);
+ c->volume = MPD_STATUS_NO_VOLUME;
return c;
}
{
gint retval = 0;
+ c->volume = MPD_STATUS_NO_VOLUME;
+
if (MPD_ERROR(c))
return -1;
mpdclient_browse_callback(c, BROWSE_DB_UPDATED, NULL);
c->updatingdb = c->status->updatingDb;
+ c->volume = c->status->volume;
/* check if the playlist needs an update */
if (c->playlist.id != c->status->playlist) {
return mpdclient_finish_command(c);
}
+gint mpdclient_cmd_volume_up(struct mpdclient *c)
+{
+ if (c->status == NULL || c->status->volume == MPD_STATUS_NO_VOLUME)
+ return 0;
+
+ if (c->volume == MPD_STATUS_NO_VOLUME)
+ c->volume = c->status->volume;
+
+ if (c->volume >= 100)
+ return 0;
+
+ return mpdclient_cmd_volume(c, ++c->volume);
+}
+
+gint mpdclient_cmd_volume_down(struct mpdclient *c)
+{
+ if (c->status == NULL || c->status->volume == MPD_STATUS_NO_VOLUME)
+ return 0;
+
+ if (c->volume == MPD_STATUS_NO_VOLUME)
+ c->volume = c->status->volume;
+
+ if (c->volume <= 0)
+ return 0;
+
+ return mpdclient_cmd_volume(c, --c->volume);
+}
+
gint
mpdclient_cmd_add_path(mpdclient_t *c, gchar *path_utf8)
{
diff --git a/src/mpdclient.h b/src/mpdclient.h
index c2ba4767356bb1441c168c7409bb5ef0da620d27..e74722e607e01409273ca410f45c2399b8a9500e 100644 (file)
--- a/src/mpdclient.h
+++ b/src/mpdclient.h
gboolean need_update;
+ int volume;
int updatingdb;
} mpdclient_t;
gint mpdclient_cmd_crossfade(mpdclient_t *c, gint value);
gint mpdclient_cmd_db_update(mpdclient_t *c, gchar *path);
gint mpdclient_cmd_volume(mpdclient_t *c, gint value);
+gint mpdclient_cmd_volume_up(struct mpdclient *c);
+gint mpdclient_cmd_volume_down(struct mpdclient *c);
gint mpdclient_cmd_add_path(mpdclient_t *c, gchar *path);
gint mpdclient_cmd_add(mpdclient_t *c, struct mpd_song *song);
diff --git a/src/screen.c b/src/screen.c
index 200f9dbb67d27f188f264f9d3877462d01b6e60b..c4e156acd2cf44deba4b7ec4936c48a8f469500f 100644 (file)
--- a/src/screen.c
+++ b/src/screen.c
screen_status_printf(_("Database update running..."));
break;
case CMD_VOLUME_UP:
- if( c->status->volume!=MPD_STATUS_NO_VOLUME && c->status->volume<100 )
- mpdclient_cmd_volume(c, ++c->status->volume);
+ mpdclient_cmd_volume_up(c);
break;
case CMD_VOLUME_DOWN:
- if( c->status->volume!=MPD_STATUS_NO_VOLUME && c->status->volume>0 )
- mpdclient_cmd_volume(c, --c->status->volume);
+ mpdclient_cmd_volume_down(c);
break;
default: