diff --git a/src/mpdclient.c b/src/mpdclient.c
index bffbce80eebc51d2115567358e1462c040c34378..4882d548f1b21563112626f59bfd7489134d8429 100644 (file)
--- a/src/mpdclient.c
+++ b/src/mpdclient.c
/* ncmpc (Ncurses MPD Client)
- * (c) 2004-2009 The Music Player Daemon Project
+ * (c) 2004-2010 The Music Player Daemon Project
* Project homepage: http://musicpd.org
* This program is free software; you can redistribute it and/or modify
mpdclient_connect(struct mpdclient *c,
const gchar *host,
gint port,
- gfloat _timeout,
+ unsigned timeout_ms,
const gchar *password)
{
/* close any open connection */
mpdclient_disconnect(c);
/* connect to MPD */
- c->connection = mpd_connection_new(host, port, _timeout * 1000);
+ c->connection = mpd_connection_new(host, port, timeout_ms);
if (c->connection == NULL)
g_error("Out of memory");
mpdclient_update(struct mpdclient *c)
{
struct mpd_connection *connection = mpdclient_get_connection(c);
- bool retval;
c->volume = -1;
/* check if the playlist needs an update */
if (c->playlist.version != mpd_status_get_queue_version(c->status)) {
+ bool retval;
+
if (c->source == NULL)
- c->events |= MPD_IDLE_PLAYLIST;
+ c->events |= MPD_IDLE_QUEUE;
if (!playlist_is_empty(&c->playlist))
retval = mpdclient_playlist_update_changes(c);
else
retval = mpdclient_playlist_update(c);
- } else
- retval = true;
+ if (!retval)
+ return false;
+ }
/* update the current song */
- if (!c->song || mpd_status_get_song_id(c->status)) {
+ if (!c->song || mpd_status_get_song_id(c->status) >= 0) {
c->song = playlist_get_song(&c->playlist,
mpd_status_get_song_pos(c->status));
}
- return retval;
+ return true;
}
struct mpd_connection *
struct mpd_connection *connection;
int length, current;
- if (c->status == NULL)
+ if (!mpdclient_is_playing(c))
return false;
length = mpd_status_get_queue_length(c->status);
current = mpd_status_get_song_pos(c->status);
- if (current < 0 ||
- (mpd_status_get_state(c->status) != MPD_STATE_PLAY &&
- mpd_status_get_state(c->status) != MPD_STATE_PAUSE) ||
- mpd_status_get_queue_length(c->status) < 2)
+ if (current < 0 || mpd_status_get_queue_length(c->status) < 2)
return true;
connection = mpdclient_get_connection(c);
reducing the UI latency */
playlist_clear(&c->playlist);
c->playlist.version = mpd_status_get_queue_version(status);
+ c->song = NULL;
}
c->events |= MPD_IDLE_QUEUE;
!mpd_response_next(connection))
return mpdclient_handle_error(c);
- c->events |= MPD_IDLE_PLAYLIST;
+ c->events |= MPD_IDLE_QUEUE;
status = mpdclient_recv_status(c);
if (status == NULL)
!mpd_command_list_end(connection))
return mpdclient_handle_error(c);
- c->events |= MPD_IDLE_PLAYLIST;
+ c->events |= MPD_IDLE_QUEUE;
status = mpdclient_recv_status(c);
if (status == NULL)
!mpd_command_list_end(connection))
return mpdclient_handle_error(c);
- c->events |= MPD_IDLE_PLAYLIST;
+ c->events |= MPD_IDLE_QUEUE;
status = mpdclient_recv_status(c);
if (status == NULL)