summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: 47c1290)
raw | patch | inline | side by side (parent: 47c1290)
author | Kalle Wallin <kaw@linux.se> | |
Sat, 20 Mar 2004 08:46:30 +0000 (08:46 +0000) | ||
committer | Kalle Wallin <kaw@linux.se> | |
Sat, 20 Mar 2004 08:46:30 +0000 (08:46 +0000) |
mpc.c | patch | blob | history |
index f62d9789c8c91549b9a975bcf59da17df292e3bc..0b12e27e14ed8b64e0a94234e620c3b92725f2da 100644 (file)
--- a/mpc.c
+++ b/mpc.c
{
mpd_InfoEntity *entity;
+ if( mpc_error(c) )
+ return;
+
if( c->song )
{
mpd_freeSong(c->song);
}
mpd_sendPlaylistInfoCommand(c->connection, c->status->song);
+ if( mpc_error(c) )
+ return;
while( (entity=mpd_getNextInfoEntity(c->connection)) )
{
mpd_Song *song = entity->info.song;
return c;
}
+int
+mpc_reconnect(mpd_client_t *c, char *host, int port)
+{
+ mpd_Connection *connection;
+
+ connection = mpd_newConnection(host, port, 10);
+ if( connection==NULL )
+ return -1;
+ if( connection->error )
+ {
+ mpd_closeConnection(connection);
+ return -1;
+ }
+
+ c->connection = connection;
+
+ return 0;
+}
+
+
int
mpc_error(mpd_client_t *c)
{
// fprintf(stderr, "mpc_update_playlist(): status->playlist = %d\n", c->status->playlist);
+ if( mpc_error(c) )
+ return -1;
+
if( c->playlist )
mpc_free_playlist(c);
c->playlist_length=0;
mpd_sendPlaylistInfoCommand(c->connection,-1);
+ if( mpc_error(c) )
+ return -1;
while( (entity=mpd_getNextInfoEntity(c->connection)) )
{
if(entity->type==MPD_INFO_ENTITY_TYPE_SONG)
int
mpc_update(mpd_client_t *c)
{
+ if( mpc_error(c) )
+ return -1;
+
if( c->status )
{
mpd_freeStatus(c->status);
}
c->status = mpd_getStatus(c->connection);
+ if( mpc_error(c) )
+ return -1;
- // if( c->playlist == NULL || c->playlist_id!=c->status->playlist )
if( c->playlist_id!=c->status->playlist )
mpc_update_playlist(c);
- // if( c->song == NULL || c->status->song != c->song_id )
if( c->status->song != c->song_id )
{
c->song = mpc_playlist_get_song(c, c->status->song);
{
mpd_InfoEntity *entity;
+ if( mpc_error(c) )
+ return -1;
+
if( c->filelist )
mpc_free_filelist(c);