aboutsummaryrefslogtreecommitdiff
path: root/src/tag_id3.c
diff options
context:
space:
mode:
authorMax Kellermann <max@duempel.org>2009-03-02 18:00:46 +0100
committerMax Kellermann <max@duempel.org>2009-03-02 18:00:46 +0100
commit336f624277933a34a049d1d5e88f1357bf8048d8 (patch)
tree701b28f6e07824758ece375cccb7f53f40fe553a /src/tag_id3.c
parent72176db429c0341c041a95c5daa50de7aece2da2 (diff)
tag_id3: parse ID3 tags in RIFF/WAV files
Added a small RIFF parser library. Look for an "id3" chunk, and let libid3tag parse it.
Diffstat (limited to 'src/tag_id3.c')
-rw-r--r--src/tag_id3.c32
1 files changed, 32 insertions, 0 deletions
diff --git a/src/tag_id3.c b/src/tag_id3.c
index f919111d..7cf82c10 100644
--- a/src/tag_id3.c
+++ b/src/tag_id3.c
@@ -18,6 +18,7 @@
#include "tag_id3.h"
#include "tag.h"
+#include "riff.h"
#include "conf.h"
#include <glib.h>
@@ -424,6 +425,35 @@ static struct id3_tag *findId3TagFromEnd(FILE * stream)
return tag;
}
+static struct id3_tag *
+tag_id3_riff_load(FILE *file)
+{
+ size_t size;
+ void *buffer;
+ size_t ret;
+ struct id3_tag *tag;
+
+ size = riff_seek_id3(file);
+ if (size == 0)
+ return NULL;
+
+ if (size > 65536)
+ /* too large, don't allocate so much memory */
+ return NULL;
+
+ buffer = g_malloc(size);
+ ret = fread(buffer, size, 1, file);
+ if (ret != 1) {
+ g_warning("Failed to read RIFF chunk");
+ g_free(buffer);
+ return NULL;
+ }
+
+ tag = id3_tag_parse(buffer, size);
+ g_free(buffer);
+ return tag;
+}
+
struct tag *tag_id3_load(const char *file)
{
struct tag *ret;
@@ -438,6 +468,8 @@ struct tag *tag_id3_load(const char *file)
}
tag = findId3TagFromBeginning(stream);
+ if (tag == NULL)
+ tag = tag_id3_riff_load(stream);
if (!tag)
tag = findId3TagFromEnd(stream);