diff options
author | Warren Dukes <warren.dukes@gmail.com> | 2004-06-06 19:41:03 +0000 |
---|---|---|
committer | Warren Dukes <warren.dukes@gmail.com> | 2004-06-06 19:41:03 +0000 |
commit | b29f73c819ff8445b71963d883364e315b7a12d8 (patch) | |
tree | 772690e7472972ea3e78bb7b354ff4b903a8e4f3 /src/metadataChunk.c | |
parent | 4e53282469de4fea4b8daaec67298bd3394f34bd (diff) | |
download | mpd-b29f73c819ff8445b71963d883364e315b7a12d8.tar.gz mpd-b29f73c819ff8445b71963d883364e315b7a12d8.tar.xz mpd-b29f73c819ff8445b71963d883364e315b7a12d8.zip |
mechanism for updating metadata while decoding
vorbis comments are updated on the fly for streams
need to decode icy metadata
buffering of metadata needs to be hardened, to ensure that player has already read a particular metachunk or passed over it
git-svn-id: https://svn.musicpd.org/mpd/trunk@1358 09075e82-0dd4-0310-85a5-a0d7c8717e4f
Diffstat (limited to 'src/metadataChunk.c')
-rw-r--r-- | src/metadataChunk.c | 46 |
1 files changed, 46 insertions, 0 deletions
diff --git a/src/metadataChunk.c b/src/metadataChunk.c new file mode 100644 index 000000000..1deab3d90 --- /dev/null +++ b/src/metadataChunk.c @@ -0,0 +1,46 @@ +#include "metadataChunk.h" + +#include <string.h> + +void initMetadataChunk(MetadataChunk * chunk) { + memset(chunk, 0, sizeof(MetadataChunk)); + + chunk->name = -1; + chunk->artist = -1; + chunk->album = -1; + chunk->title = -1; +} + +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); + + return ret; +} + +#define copyStringToChunk(string, element) { \ + if(string && (slen = strlen(string)) && \ + pos < METADATA_BUFFER_LENGTH-1) \ + { \ + strncpy(chunk->buffer+pos, string, \ + METADATA_BUFFER_LENGTH-1-pos); \ + element = pos; \ + pos += slen+1; \ + } \ +} + +void copyMpdTagToMetadataChunk(MpdTag * tag, MetadataChunk * chunk) { + int pos = 0; + int slen; + + initMetadataChunk(chunk); + + copyStringToChunk(tag->name, chunk->name); + copyStringToChunk(tag->title, chunk->title); + copyStringToChunk(tag->artist, chunk->artist); + copyStringToChunk(tag->album, chunk->album); +} |