Author: Pedro Lucas Porcellis <porcellis@eletrotupi.com>
all: use MPD's enum instead of parsing tags We should unify the conversion between a mpd_song into a seamus_song somewhere down the line
src/queue.c | 7 ++----- src/status.c | 14 ++++++--------
diff --git a/src/queue.c b/src/queue.c index 1ee4a3f74e7e5a566630ced018cb9d7232ced6df..40ec7042297d86ef805f80b37222095280fdb544 100644 --- a/src/queue.c +++ b/src/queue.c @@ -26,11 +26,8 @@ if (type == MPD_ENTITY_TYPE_SONG) { struct mpd_song *song = mpd_entity_get_song(entity); - enum mpd_tag_type tag_title = mpd_tag_name_iparse("Title"); - const char *stitle = mpd_song_get_tag(song, tag_title, 0); - - enum mpd_tag_type tag_artist = mpd_tag_name_iparse("AlbumArtist"); - const char *sartist = mpd_song_get_tag(song, tag_artist, 0); + const char *stitle = mpd_song_get_tag(song, MPD_TAG_TITLE, 0); + const char *sartist = mpd_song_get_tag(song, MPD_TAG_ALBUM_ARTIST, 0); struct seamus_song *new = &seamus->queue[index]; memset(new, 0, sizeof(*new)); diff --git a/src/status.c b/src/status.c index 211c8ceaf1f8073009fba678a940be3fb1ee3220..2fafb115dace17a109b58b86693ec62f89e1d240 100644 --- a/src/status.c +++ b/src/status.c @@ -31,11 +31,8 @@ state = "[paused]"; } if (song != NULL) { - enum mpd_tag_type tag_artist = mpd_tag_name_iparse("Artist"); - enum mpd_tag_type tag_title = mpd_tag_name_iparse("Title"); - - const char *title = mpd_song_get_tag(song, tag_title, 0); - const char *artist = mpd_song_get_tag(song, tag_artist, 0); + const char *title = mpd_song_get_tag(song, MPD_TAG_TITLE, 0); + const char *artist = mpd_song_get_tag(song, MPD_TAG_ARTIST, 0); char *elapsed_time = (char*) malloc(13 * sizeof(char)); @@ -63,11 +60,12 @@ ) ); char *str = malloc(strsz); - if (s->current_status == NULL) { - s->current_status = malloc(strsz); - } else { + + if (s->current_status != NULL) { free(s->current_status); } + + s->current_status = malloc(strsz); sprintf(str, "%s %s - %s: %s/%s", state,