From ffea273a28179d2b5bbc24f967517bcf80940c63 Mon Sep 17 00:00:00 2001 From: Max Kellermann Date: Sat, 11 Feb 2012 19:24:51 +0100 Subject: 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. --- src/decoder/wavpack_decoder_plugin.c | 27 +++++++++++++++++++++++++++ 1 file changed, 27 insertions(+) (limited to 'src/decoder/wavpack_decoder_plugin.c') 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; -- cgit v1.2.3