aboutsummaryrefslogtreecommitdiffstats
path: root/src/decoder/wavpack_decoder_plugin.c
diff options
context:
space:
mode:
authorMax Kellermann <max@duempel.org>2012-02-11 19:24:51 +0100
committerMax Kellermann <max@duempel.org>2012-02-12 13:41:48 +0100
commitffea273a28179d2b5bbc24f967517bcf80940c63 (patch)
tree5891ed63a60ba0eed7c2b4433ea72f566f982822 /src/decoder/wavpack_decoder_plugin.c
parent1783aac4384ccc53d9ad25c237d4286ccdbccbc0 (diff)
downloadmpd-ffea273a28179d2b5bbc24f967517bcf80940c63.tar.gz
mpd-ffea273a28179d2b5bbc24f967517bcf80940c63.tar.xz
mpd-ffea273a28179d2b5bbc24f967517bcf80940c63.zip
tag_handler: handle arbitrary name/value pairs
The new method pair() receives an arbitrary name/value pair. Support for this is being added to a few decoder plugins.
Diffstat (limited to '')
-rw-r--r--src/decoder/wavpack_decoder_plugin.c27
1 files changed, 27 insertions, 0 deletions
diff --git a/src/decoder/wavpack_decoder_plugin.c b/src/decoder/wavpack_decoder_plugin.c
index 7ba50ba32..88a4854b8 100644
--- a/src/decoder/wavpack_decoder_plugin.c
+++ b/src/decoder/wavpack_decoder_plugin.c
@@ -286,6 +286,19 @@ wavpack_scan_tag_item(WavpackContext *wpc, const char *name,
}
+static void
+wavpack_scan_pair(WavpackContext *wpc, const char *name,
+ const struct tag_handler *handler, void *handler_ctx)
+{
+ char buffer[1024];
+ int len = WavpackGetTagItem(wpc, name, buffer, sizeof(buffer));
+ if (len <= 0 || (unsigned)len >= sizeof(buffer))
+ return;
+
+ tag_handler_invoke_pair(handler, handler_ctx, name, buffer);
+
+}
+
/*
* Reads metainfo from the specified file.
*/
@@ -313,6 +326,20 @@ wavpack_scan_file(const char *fname,
wavpack_scan_tag_item(wpc, i->name, i->type,
handler, handler_ctx);
+ if (handler->pair != NULL) {
+ char name[64];
+
+ for (int i = 0, n = WavpackGetNumTagItems(wpc);
+ i < n; ++i) {
+ int len = WavpackGetTagItemIndexed(wpc, i, name,
+ sizeof(name));
+ if (len <= 0 || (unsigned)len >= sizeof(name))
+ continue;
+
+ wavpack_scan_pair(wpc, name, handler, handler_ctx);
+ }
+ }
+
WavpackCloseFile(wpc);
return true;