diff options
author | Kalle Wallin <kaw@linux.se> | 2004-04-22 20:34:52 +0000 |
---|---|---|
committer | Kalle Wallin <kaw@linux.se> | 2004-04-22 20:34:52 +0000 |
commit | 9cd22a2d5703c1f8159e0614a3c1c4dd086a1158 (patch) | |
tree | ead61a4a2c871186e9a7299fca556f6a92cae24f /mpc.c | |
parent | 4314bb955b36d2801340b5b4859a7d4c93794cde (diff) | |
download | mpd-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.c | 53 |
1 files changed, 14 insertions, 39 deletions
@@ -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; |