diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/metadataChunk.c | 16 | ||||
-rw-r--r-- | src/player.c | 10 | ||||
-rw-r--r-- | src/playlist.c | 4 |
3 files changed, 17 insertions, 13 deletions
diff --git a/src/metadataChunk.c b/src/metadataChunk.c index 1deab3d90..9a4c35e10 100644 --- a/src/metadataChunk.c +++ b/src/metadataChunk.c @@ -11,13 +11,21 @@ void initMetadataChunk(MetadataChunk * chunk) { chunk->title = -1; } +#define dupElementToTag(string, element) { \ + if(element >= 0 && element < METADATA_BUFFER_LENGTH) { \ + string = strdup(chunk->buffer+element); \ + } \ +} + MpdTag * metadataChunkToMpdTagDup(MetadataChunk * chunk) { MpdTag * ret = newMpdTag(); - if(chunk->name >= 0) ret->name = strdup(chunk->buffer+chunk->name); - if(chunk->artist >= 0) ret->artist = strdup(chunk->buffer+chunk->artist); - if(chunk->album >= 0) ret->album = strdup(chunk->buffer+chunk->album); - if(chunk->title >= 0) ret->title = strdup(chunk->buffer+chunk->title); + chunk->buffer[METADATA_BUFFER_LENGTH] = '\0'; + + dupElementToTag(ret->name, chunk->name); + dupElementToTag(ret->title, chunk->title); + dupElementToTag(ret->artist, chunk->artist); + dupElementToTag(ret->album, chunk->album); return ret; } diff --git a/src/player.c b/src/player.c index e6da9aeb9..3ddd21062 100644 --- a/src/player.c +++ b/src/player.c @@ -478,16 +478,16 @@ Song * playerCurrentDecodeSong() { sizeof(MetadataChunk))))) { printf("metadata in the PLAYER!\n"); + if(prev) free(prev); + prev = malloc(sizeof(MetadataChunk)); + memcpy(prev, &(pc->metadataChunk), sizeof(MetadataChunk)); + resetPlayerMetadata(); if(song) freeJustSong(song); song = newNullSong(); if(song->utf8url) free(song->utf8url); song->utf8url = strdup(pc->currentUrl); - song->tag = metadataChunkToMpdTagDup(&(pc->metadataChunk)); + song->tag = metadataChunkToMpdTagDup(prev); validateUtf8Tag(song->tag); - if(prev) free(prev); - prev = malloc(sizeof(MetadataChunk)); - memcpy(prev, &(pc->metadataChunk), sizeof(MetadataChunk)); - resetPlayerMetadata(); return song; } diff --git a/src/playlist.c b/src/playlist.c index 4b6fa5205..dd261cfd2 100644 --- a/src/playlist.c +++ b/src/playlist.c @@ -802,19 +802,15 @@ void syncCurrentPlayerDecodeMetadata() { songNum = playlist.order[playlist.current]; song = playlist.songs[songNum]; - printf("HERE 1\n"); - if(song->type == SONG_TYPE_URL && 0 == strcmp(song->utf8url, songPlayer->utf8url) && !mpdTagsAreEqual(song->tag, songPlayer->tag)) { - printf("HERE 1-1\n"); if(song->tag) freeMpdTag(song->tag); song->tag = mpdTagDup(songPlayer->tag); playlist.songMod[songNum] = playlist.version; incrPlaylistVersion(); } - printf("HERE 2\n"); } void syncPlayerAndPlaylist() { |