aboutsummaryrefslogtreecommitdiffstats
path: root/mpc.c
diff options
context:
space:
mode:
authorKalle Wallin <kaw@linux.se>2004-04-22 20:34:52 +0000
committerKalle Wallin <kaw@linux.se>2004-04-22 20:34:52 +0000
commit9cd22a2d5703c1f8159e0614a3c1c4dd086a1158 (patch)
treeead61a4a2c871186e9a7299fca556f6a92cae24f /mpc.c
parent4314bb955b36d2801340b5b4859a7d4c93794cde (diff)
downloadmpd-9cd22a2d5703c1f8159e0614a3c1c4dd086a1158.tar.gz
mpd-9cd22a2d5703c1f8159e0614a3c1c4dd086a1158.tar.xz
mpd-9cd22a2d5703c1f8159e0614a3c1c4dd086a1158.zip
Changed the way songs are added/deleted from playlist (#0000220).
git-svn-id: https://svn.musicpd.org/ncmpc/trunk@875 09075e82-0dd4-0310-85a5-a0d7c8717e4f
Diffstat (limited to 'mpc.c')
-rw-r--r--mpc.c53
1 files changed, 14 insertions, 39 deletions
diff --git a/mpc.c b/mpc.c
index 00a044462..0a80af4dd 100644
--- a/mpc.c
+++ b/mpc.c
@@ -13,43 +13,11 @@
#define MAX_SONG_LENGTH 1024
-void
-mpc_update_song(mpd_client_t *c)
-{
- mpd_InfoEntity *entity;
-
- if( mpc_error(c) )
- return;
-
- if( c->song )
- {
- mpd_freeSong(c->song);
- c->song = NULL;
- }
-
- mpd_sendPlaylistInfoCommand(c->connection, c->status->song);
- if( mpc_error(c) )
- return;
- while( (entity=mpd_getNextInfoEntity(c->connection)) )
- {
- mpd_Song *song = entity->info.song;
-
- if(c->connection->error)
- {
- fprintf(stderr,"error: %s\n",c->connection->errorStr);
- exit(EXIT_FAILURE);
- }
- if(entity->type!=MPD_INFO_ENTITY_TYPE_SONG) {
- mpd_freeInfoEntity(entity);
- fprintf(stderr,
- "error: type != MPD_INFO_ENTITY_TYPE_SONG [%d]\n",
- entity->type);
- exit(EXIT_FAILURE);
- }
- c->song = mpd_songDup(song);
- mpd_freeInfoEntity(entity);
- }
-}
+#ifdef DEBUG
+#define D(x) x
+#else
+#define D(x)
+#endif
int
mpc_close(mpd_client_t *c)
@@ -161,6 +129,9 @@ mpc_free_playlist(mpd_client_t *c)
c->playlist=NULL;
c->playlist_length=0;
+ c->song_id = -1;
+ c->song = NULL;
+
return 0;
}
@@ -169,7 +140,7 @@ mpc_update_playlist(mpd_client_t *c)
{
mpd_InfoEntity *entity;
- // fprintf(stderr, "mpc_update_playlist(): status->playlist = %d\n", c->status->playlist);
+ D(fprintf(stderr, "mpc_update_playlist() [%d]\n", c->status->playlist));
if( mpc_error(c) )
return -1;
@@ -195,6 +166,9 @@ mpc_update_playlist(mpd_client_t *c)
c->playlist_id = c->status->playlist;
c->playlist_updated = 1;
c->song_id = -1;
+ c->song = NULL;
+
+ mpc_filelist_set_selected(c);
return 0;
}
@@ -222,6 +196,7 @@ mpc_playlist_get_song(mpd_client_t *c, int n)
return (mpd_Song *) g_list_nth_data(c->playlist, n);
}
+
char *
mpc_get_song_name(mpd_Song *song)
{
@@ -270,7 +245,7 @@ mpc_update(mpd_client_t *c)
if( c->playlist_id!=c->status->playlist )
mpc_update_playlist(c);
- if( c->status->song != c->song_id )
+ if( !c->song || c->status->song != c->song_id )
{
c->song = mpc_playlist_get_song(c, c->status->song);
c->song_id = c->status->song;