From cde6a3a00c15f90062c8d4f46df07312cbcfa718 Mon Sep 17 00:00:00 2001 From: Max Kellermann Date: Mon, 29 Jul 2013 07:32:36 +0200 Subject: tag_handler: convert to C++ --- src/ApeTag.cxx | 2 +- src/SongUpdate.cxx | 5 +- src/TagHandler.cxx | 61 +++++++++++++++++ src/TagHandler.hxx | 101 +++++++++++++++++++++++++++++ src/TagId3.cxx | 2 +- src/UpdateContainer.cxx | 5 +- src/decoder/AdPlugDecoderPlugin.cxx | 2 +- src/decoder/AudiofileDecoderPlugin.cxx | 2 +- src/decoder/DsdLib.cxx | 2 +- src/decoder/DsdiffDecoderPlugin.cxx | 4 +- src/decoder/DsfDecoderPlugin.cxx | 2 +- src/decoder/FaadDecoderPlugin.cxx | 2 +- src/decoder/FfmpegDecoderPlugin.cxx | 2 +- src/decoder/FfmpegMetaData.cxx | 2 +- src/decoder/FlacMetadata.cxx | 2 +- src/decoder/GmeDecoderPlugin.cxx | 2 +- src/decoder/MadDecoderPlugin.cxx | 2 +- src/decoder/MikmodDecoderPlugin.cxx | 2 +- src/decoder/ModplugDecoderPlugin.cxx | 2 +- src/decoder/MpcdecDecoderPlugin.cxx | 2 +- src/decoder/Mpg123DecoderPlugin.cxx | 2 +- src/decoder/OpusDecoderPlugin.cxx | 2 +- src/decoder/OpusTags.cxx | 2 +- src/decoder/SndfileDecoderPlugin.cxx | 2 +- src/decoder/VorbisComments.cxx | 2 +- src/decoder/VorbisDecoderPlugin.cxx | 2 +- src/decoder/WavpackDecoderPlugin.cxx | 2 +- src/decoder/WildmidiDecoderPlugin.cxx | 2 +- src/decoder/sidplay_decoder_plugin.cxx | 2 +- src/playlist/EmbeddedCuePlaylistPlugin.cxx | 2 +- src/tag_handler.c | 60 ----------------- src/tag_handler.h | 101 ----------------------------- 32 files changed, 191 insertions(+), 196 deletions(-) create mode 100644 src/TagHandler.cxx create mode 100644 src/TagHandler.hxx delete mode 100644 src/tag_handler.c delete mode 100644 src/tag_handler.h (limited to 'src') diff --git a/src/ApeTag.cxx b/src/ApeTag.cxx index 1195ffe5f..7713310c1 100644 --- a/src/ApeTag.cxx +++ b/src/ApeTag.cxx @@ -22,7 +22,7 @@ #include "ApeLoader.hxx" #include "tag.h" #include "tag_table.h" -#include "tag_handler.h" +#include "TagHandler.hxx" const struct tag_table ape_tags[] = { { "album artist", TAG_ALBUM_ARTIST }, diff --git a/src/SongUpdate.cxx b/src/SongUpdate.cxx index 8285cdd99..13d08fecc 100644 --- a/src/SongUpdate.cxx +++ b/src/SongUpdate.cxx @@ -28,13 +28,10 @@ #include "input_stream.h" #include "DecoderPlugin.hxx" #include "DecoderList.hxx" +#include "TagHandler.hxx" #include "TagId3.hxx" #include "ApeTag.hxx" -extern "C" { -#include "tag_handler.h" -} - #include #include diff --git a/src/TagHandler.cxx b/src/TagHandler.cxx new file mode 100644 index 000000000..6f95c7e94 --- /dev/null +++ b/src/TagHandler.cxx @@ -0,0 +1,61 @@ +/* + * Copyright (C) 2003-2013 The Music Player Daemon Project + * http://www.musicpd.org + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License along + * with this program; if not, write to the Free Software Foundation, Inc., + * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. + */ + +#include "config.h" +#include "TagHandler.hxx" + +#include + +static void +add_tag_duration(unsigned seconds, void *ctx) +{ + struct tag *tag = (struct tag *)ctx; + + tag->time = seconds; +} + +static void +add_tag_tag(enum tag_type type, const char *value, void *ctx) +{ + struct tag *tag = (struct tag *)ctx; + + tag_add_item(tag, type, value); +} + +const struct tag_handler add_tag_handler = { + add_tag_duration, + add_tag_tag, + nullptr, +}; + +static void +full_tag_pair(const char *name, G_GNUC_UNUSED const char *value, void *ctx) +{ + struct tag *tag = (struct tag *)ctx; + + if (g_ascii_strcasecmp(name, "cuesheet") == 0) + tag->has_playlist = true; +} + +const struct tag_handler full_tag_handler = { + add_tag_duration, + add_tag_tag, + full_tag_pair, +}; + diff --git a/src/TagHandler.hxx b/src/TagHandler.hxx new file mode 100644 index 000000000..967b91de7 --- /dev/null +++ b/src/TagHandler.hxx @@ -0,0 +1,101 @@ +/* + * Copyright (C) 2003-2013 The Music Player Daemon Project + * http://www.musicpd.org + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License along + * with this program; if not, write to the Free Software Foundation, Inc., + * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. + */ + +#ifndef MPD_TAG_HANDLER_HXX +#define MPD_TAG_HANDLER_HXX + +#include "check.h" +#include "tag.h" + +#include + +/** + * A callback table for receiving metadata of a song. + */ +struct tag_handler { + /** + * Declare the duration of a song, in seconds. Do not call + * this when the duration could not be determined, because + * there is no magic value for "unknown duration". + */ + void (*duration)(unsigned seconds, void *ctx); + + /** + * A tag has been read. + * + * @param the value of the tag; the pointer will become + * invalid after returning + */ + void (*tag)(enum tag_type type, const char *value, void *ctx); + + /** + * A name-value pair has been read. It is the codec specific + * representation of tags. + */ + void (*pair)(const char *key, const char *value, void *ctx); +}; + +static inline void +tag_handler_invoke_duration(const struct tag_handler *handler, void *ctx, + unsigned seconds) +{ + assert(handler != nullptr); + + if (handler->duration != nullptr) + handler->duration(seconds, ctx); +} + +static inline void +tag_handler_invoke_tag(const struct tag_handler *handler, void *ctx, + enum tag_type type, const char *value) +{ + assert(handler != nullptr); + assert((unsigned)type < TAG_NUM_OF_ITEM_TYPES); + assert(value != nullptr); + + if (handler->tag != nullptr) + handler->tag(type, value, ctx); +} + +static inline void +tag_handler_invoke_pair(const struct tag_handler *handler, void *ctx, + const char *name, const char *value) +{ + assert(handler != nullptr); + assert(name != nullptr); + assert(value != nullptr); + + if (handler->pair != nullptr) + handler->pair(name, value, ctx); +} + +/** + * This #tag_handler implementation adds tag values to a #tag object + * (casted from the context pointer). + */ +extern const struct tag_handler add_tag_handler; + +/** + * This #tag_handler implementation adds tag values to a #tag object + * (casted from the context pointer), and supports the has_playlist + * attribute. + */ +extern const struct tag_handler full_tag_handler; + +#endif diff --git a/src/TagId3.cxx b/src/TagId3.cxx index d6bef2fa9..c5719f481 100644 --- a/src/TagId3.cxx +++ b/src/TagId3.cxx @@ -19,7 +19,7 @@ #include "config.h" #include "TagId3.hxx" -#include "tag_handler.h" +#include "TagHandler.hxx" #include "tag_table.h" #include "tag.h" diff --git a/src/UpdateContainer.cxx b/src/UpdateContainer.cxx index 92b727ce7..9da58567c 100644 --- a/src/UpdateContainer.cxx +++ b/src/UpdateContainer.cxx @@ -27,10 +27,7 @@ #include "DecoderPlugin.hxx" #include "Mapper.hxx" #include "fs/Path.hxx" - -extern "C" { -#include "tag_handler.h" -} +#include "TagHandler.hxx" #include diff --git a/src/decoder/AdPlugDecoderPlugin.cxx b/src/decoder/AdPlugDecoderPlugin.cxx index e752295f5..d1ed07891 100644 --- a/src/decoder/AdPlugDecoderPlugin.cxx +++ b/src/decoder/AdPlugDecoderPlugin.cxx @@ -19,7 +19,7 @@ #include "config.h" #include "AdPlugDecoderPlugin.h" -#include "tag_handler.h" +#include "TagHandler.hxx" #include "DecoderAPI.hxx" extern "C" { diff --git a/src/decoder/AudiofileDecoderPlugin.cxx b/src/decoder/AudiofileDecoderPlugin.cxx index 4eb5c14a6..ee7d0da14 100644 --- a/src/decoder/AudiofileDecoderPlugin.cxx +++ b/src/decoder/AudiofileDecoderPlugin.cxx @@ -21,7 +21,7 @@ #include "AudiofileDecoderPlugin.hxx" #include "DecoderAPI.hxx" #include "audio_check.h" -#include "tag_handler.h" +#include "TagHandler.hxx" #include #include diff --git a/src/decoder/DsdLib.cxx b/src/decoder/DsdLib.cxx index 5337612a9..cc23c490b 100644 --- a/src/decoder/DsdLib.cxx +++ b/src/decoder/DsdLib.cxx @@ -27,7 +27,7 @@ #include "DsdLib.hxx" #include "DecoderAPI.hxx" #include "util/bit_reverse.h" -#include "tag_handler.h" +#include "TagHandler.hxx" #include "TagId3.hxx" #include diff --git a/src/decoder/DsdiffDecoderPlugin.cxx b/src/decoder/DsdiffDecoderPlugin.cxx index 9934e4a37..fb542c3b7 100644 --- a/src/decoder/DsdiffDecoderPlugin.cxx +++ b/src/decoder/DsdiffDecoderPlugin.cxx @@ -31,9 +31,9 @@ #include "DecoderAPI.hxx" #include "audio_check.h" #include "util/bit_reverse.h" -#include "tag_handler.h" +#include "TagHandler.hxx" #include "DsdLib.hxx" -#include "tag_handler.h" +#include "TagHandler.hxx" #include #include /* for SEEK_SET, SEEK_CUR */ diff --git a/src/decoder/DsfDecoderPlugin.cxx b/src/decoder/DsfDecoderPlugin.cxx index 545f12975..c19669dd6 100644 --- a/src/decoder/DsfDecoderPlugin.cxx +++ b/src/decoder/DsfDecoderPlugin.cxx @@ -33,7 +33,7 @@ #include "audio_check.h" #include "util/bit_reverse.h" #include "DsdLib.hxx" -#include "tag_handler.h" +#include "TagHandler.hxx" #include #include /* for SEEK_SET, SEEK_CUR */ diff --git a/src/decoder/FaadDecoderPlugin.cxx b/src/decoder/FaadDecoderPlugin.cxx index 4636d08cb..4c21ae7c9 100644 --- a/src/decoder/FaadDecoderPlugin.cxx +++ b/src/decoder/FaadDecoderPlugin.cxx @@ -22,7 +22,7 @@ #include "DecoderAPI.hxx" #include "DecoderBuffer.hxx" #include "audio_check.h" -#include "tag_handler.h" +#include "TagHandler.hxx" #include diff --git a/src/decoder/FfmpegDecoderPlugin.cxx b/src/decoder/FfmpegDecoderPlugin.cxx index 8b9810233..5930f7fa7 100644 --- a/src/decoder/FfmpegDecoderPlugin.cxx +++ b/src/decoder/FfmpegDecoderPlugin.cxx @@ -24,7 +24,7 @@ #include "FfmpegDecoderPlugin.hxx" #include "DecoderAPI.hxx" #include "FfmpegMetaData.hxx" -#include "tag_handler.h" +#include "TagHandler.hxx" #include "InputStream.hxx" extern "C" { diff --git a/src/decoder/FfmpegMetaData.cxx b/src/decoder/FfmpegMetaData.cxx index 2d7ebbca3..509aaf947 100644 --- a/src/decoder/FfmpegMetaData.cxx +++ b/src/decoder/FfmpegMetaData.cxx @@ -23,7 +23,7 @@ #include "config.h" #include "FfmpegMetaData.hxx" #include "tag_table.h" -#include "tag_handler.h" +#include "TagHandler.hxx" #undef G_LOG_DOMAIN #define G_LOG_DOMAIN "ffmpeg" diff --git a/src/decoder/FlacMetadata.cxx b/src/decoder/FlacMetadata.cxx index 694c88c8f..02a5f509e 100644 --- a/src/decoder/FlacMetadata.cxx +++ b/src/decoder/FlacMetadata.cxx @@ -25,7 +25,7 @@ extern "C" { } #include "tag.h" -#include "tag_handler.h" +#include "TagHandler.hxx" #include "tag_table.h" #include "replay_gain_info.h" diff --git a/src/decoder/GmeDecoderPlugin.cxx b/src/decoder/GmeDecoderPlugin.cxx index 108a589a1..14367e311 100644 --- a/src/decoder/GmeDecoderPlugin.cxx +++ b/src/decoder/GmeDecoderPlugin.cxx @@ -21,7 +21,7 @@ #include "GmeDecoderPlugin.hxx" #include "DecoderAPI.hxx" #include "audio_check.h" -#include "tag_handler.h" +#include "TagHandler.hxx" #include "util/UriUtil.hxx" #include diff --git a/src/decoder/MadDecoderPlugin.cxx b/src/decoder/MadDecoderPlugin.cxx index f8dd03701..0d74caf91 100644 --- a/src/decoder/MadDecoderPlugin.cxx +++ b/src/decoder/MadDecoderPlugin.cxx @@ -23,7 +23,7 @@ #include "conf.h" #include "TagId3.hxx" #include "TagRva2.hxx" -#include "tag_handler.h" +#include "TagHandler.hxx" #include "audio_check.h" #include diff --git a/src/decoder/MikmodDecoderPlugin.cxx b/src/decoder/MikmodDecoderPlugin.cxx index 538dfd599..d332664ee 100644 --- a/src/decoder/MikmodDecoderPlugin.cxx +++ b/src/decoder/MikmodDecoderPlugin.cxx @@ -21,7 +21,7 @@ #include "MikmodDecoderPlugin.hxx" #include "DecoderAPI.hxx" #include "mpd_error.h" -#include "tag_handler.h" +#include "TagHandler.hxx" #include #include diff --git a/src/decoder/ModplugDecoderPlugin.cxx b/src/decoder/ModplugDecoderPlugin.cxx index a08c96f97..2ba3b0f49 100644 --- a/src/decoder/ModplugDecoderPlugin.cxx +++ b/src/decoder/ModplugDecoderPlugin.cxx @@ -20,7 +20,7 @@ #include "config.h" #include "ModplugDecoderPlugin.hxx" #include "DecoderAPI.hxx" -#include "tag_handler.h" +#include "TagHandler.hxx" #include #include diff --git a/src/decoder/MpcdecDecoderPlugin.cxx b/src/decoder/MpcdecDecoderPlugin.cxx index 17130f1a8..482610e2d 100644 --- a/src/decoder/MpcdecDecoderPlugin.cxx +++ b/src/decoder/MpcdecDecoderPlugin.cxx @@ -21,7 +21,7 @@ #include "MpcdecDecoderPlugin.hxx" #include "DecoderAPI.hxx" #include "audio_check.h" -#include "tag_handler.h" +#include "TagHandler.hxx" #ifdef MPC_IS_OLD_API #include diff --git a/src/decoder/Mpg123DecoderPlugin.cxx b/src/decoder/Mpg123DecoderPlugin.cxx index ab21a9bac..a22f926f5 100644 --- a/src/decoder/Mpg123DecoderPlugin.cxx +++ b/src/decoder/Mpg123DecoderPlugin.cxx @@ -21,7 +21,7 @@ #include "Mpg123DecoderPlugin.hxx" #include "DecoderAPI.hxx" #include "audio_check.h" -#include "tag_handler.h" +#include "TagHandler.hxx" #include diff --git a/src/decoder/OpusDecoderPlugin.cxx b/src/decoder/OpusDecoderPlugin.cxx index f1304a1b7..063d13d79 100644 --- a/src/decoder/OpusDecoderPlugin.cxx +++ b/src/decoder/OpusDecoderPlugin.cxx @@ -27,7 +27,7 @@ #include "DecoderAPI.hxx" #include "OggCodec.hxx" #include "audio_check.h" -#include "tag_handler.h" +#include "TagHandler.hxx" #include "InputStream.hxx" #include diff --git a/src/decoder/OpusTags.cxx b/src/decoder/OpusTags.cxx index cb35a6247..fec47a28d 100644 --- a/src/decoder/OpusTags.cxx +++ b/src/decoder/OpusTags.cxx @@ -21,7 +21,7 @@ #include "OpusTags.hxx" #include "OpusReader.hxx" #include "XiphTags.h" -#include "tag_handler.h" +#include "TagHandler.hxx" #include #include diff --git a/src/decoder/SndfileDecoderPlugin.cxx b/src/decoder/SndfileDecoderPlugin.cxx index 0a40971a4..186f357ff 100644 --- a/src/decoder/SndfileDecoderPlugin.cxx +++ b/src/decoder/SndfileDecoderPlugin.cxx @@ -21,7 +21,7 @@ #include "SndfileDecoderPlugin.hxx" #include "DecoderAPI.hxx" #include "audio_check.h" -#include "tag_handler.h" +#include "TagHandler.hxx" #include diff --git a/src/decoder/VorbisComments.cxx b/src/decoder/VorbisComments.cxx index 10fe22369..47e853762 100644 --- a/src/decoder/VorbisComments.cxx +++ b/src/decoder/VorbisComments.cxx @@ -22,7 +22,7 @@ #include "XiphTags.h" #include "tag.h" #include "tag_table.h" -#include "tag_handler.h" +#include "TagHandler.hxx" #include "replay_gain_info.h" #include diff --git a/src/decoder/VorbisDecoderPlugin.cxx b/src/decoder/VorbisDecoderPlugin.cxx index bc3c1edce..438ba5949 100644 --- a/src/decoder/VorbisDecoderPlugin.cxx +++ b/src/decoder/VorbisDecoderPlugin.cxx @@ -29,7 +29,7 @@ extern "C" { #include "audio_check.h" } -#include "tag_handler.h" +#include "TagHandler.hxx" #ifndef HAVE_TREMOR #define OV_EXCLUDE_STATIC_CALLBACKS diff --git a/src/decoder/WavpackDecoderPlugin.cxx b/src/decoder/WavpackDecoderPlugin.cxx index a1512ee63..dbec7e82c 100644 --- a/src/decoder/WavpackDecoderPlugin.cxx +++ b/src/decoder/WavpackDecoderPlugin.cxx @@ -26,7 +26,7 @@ extern "C" { #include "audio_check.h" } -#include "tag_handler.h" +#include "TagHandler.hxx" #include "ApeTag.hxx" #include diff --git a/src/decoder/WildmidiDecoderPlugin.cxx b/src/decoder/WildmidiDecoderPlugin.cxx index c6979132b..721229f87 100644 --- a/src/decoder/WildmidiDecoderPlugin.cxx +++ b/src/decoder/WildmidiDecoderPlugin.cxx @@ -20,7 +20,7 @@ #include "config.h" #include "WildmidiDecoderPlugin.hxx" #include "DecoderAPI.hxx" -#include "tag_handler.h" +#include "TagHandler.hxx" #include "glib_compat.h" #include diff --git a/src/decoder/sidplay_decoder_plugin.cxx b/src/decoder/sidplay_decoder_plugin.cxx index eec9437d1..565274d83 100644 --- a/src/decoder/sidplay_decoder_plugin.cxx +++ b/src/decoder/sidplay_decoder_plugin.cxx @@ -21,7 +21,7 @@ #include "../DecoderAPI.hxx" extern "C" { -#include "tag_handler.h" +#include "TagHandler.hxx" } #include diff --git a/src/playlist/EmbeddedCuePlaylistPlugin.cxx b/src/playlist/EmbeddedCuePlaylistPlugin.cxx index c45e1d718..8a5eb10d7 100644 --- a/src/playlist/EmbeddedCuePlaylistPlugin.cxx +++ b/src/playlist/EmbeddedCuePlaylistPlugin.cxx @@ -27,7 +27,7 @@ #include "EmbeddedCuePlaylistPlugin.hxx" #include "PlaylistPlugin.hxx" #include "tag.h" -#include "tag_handler.h" +#include "TagHandler.hxx" #include "TagId3.hxx" #include "ApeTag.hxx" #include "Song.hxx" diff --git a/src/tag_handler.c b/src/tag_handler.c deleted file mode 100644 index 316715e87..000000000 --- a/src/tag_handler.c +++ /dev/null @@ -1,60 +0,0 @@ -/* - * Copyright (C) 2003-2011 The Music Player Daemon Project - * http://www.musicpd.org - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License along - * with this program; if not, write to the Free Software Foundation, Inc., - * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. - */ - -#include "config.h" -#include "tag_handler.h" - -#include - -static void -add_tag_duration(unsigned seconds, void *ctx) -{ - struct tag *tag = ctx; - - tag->time = seconds; -} - -static void -add_tag_tag(enum tag_type type, const char *value, void *ctx) -{ - struct tag *tag = ctx; - - tag_add_item(tag, type, value); -} - -const struct tag_handler add_tag_handler = { - .duration = add_tag_duration, - .tag = add_tag_tag, -}; - -static void -full_tag_pair(const char *name, G_GNUC_UNUSED const char *value, void *ctx) -{ - struct tag *tag = ctx; - - if (g_ascii_strcasecmp(name, "cuesheet") == 0) - tag->has_playlist = true; -} - -const struct tag_handler full_tag_handler = { - .duration = add_tag_duration, - .tag = add_tag_tag, - .pair = full_tag_pair, -}; - diff --git a/src/tag_handler.h b/src/tag_handler.h deleted file mode 100644 index 7f15c2a48..000000000 --- a/src/tag_handler.h +++ /dev/null @@ -1,101 +0,0 @@ -/* - * Copyright (C) 2003-2011 The Music Player Daemon Project - * http://www.musicpd.org - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License along - * with this program; if not, write to the Free Software Foundation, Inc., - * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. - */ - -#ifndef MPD_TAG_HANDLER_H -#define MPD_TAG_HANDLER_H - -#include "check.h" -#include "tag.h" - -#include - -/** - * A callback table for receiving metadata of a song. - */ -struct tag_handler { - /** - * Declare the duration of a song, in seconds. Do not call - * this when the duration could not be determined, because - * there is no magic value for "unknown duration". - */ - void (*duration)(unsigned seconds, void *ctx); - - /** - * A tag has been read. - * - * @param the value of the tag; the pointer will become - * invalid after returning - */ - void (*tag)(enum tag_type type, const char *value, void *ctx); - - /** - * A name-value pair has been read. It is the codec specific - * representation of tags. - */ - void (*pair)(const char *key, const char *value, void *ctx); -}; - -static inline void -tag_handler_invoke_duration(const struct tag_handler *handler, void *ctx, - unsigned seconds) -{ - assert(handler != NULL); - - if (handler->duration != NULL) - handler->duration(seconds, ctx); -} - -static inline void -tag_handler_invoke_tag(const struct tag_handler *handler, void *ctx, - enum tag_type type, const char *value) -{ - assert(handler != NULL); - assert((unsigned)type < TAG_NUM_OF_ITEM_TYPES); - assert(value != NULL); - - if (handler->tag != NULL) - handler->tag(type, value, ctx); -} - -static inline void -tag_handler_invoke_pair(const struct tag_handler *handler, void *ctx, - const char *name, const char *value) -{ - assert(handler != NULL); - assert(name != NULL); - assert(value != NULL); - - if (handler->pair != NULL) - handler->pair(name, value, ctx); -} - -/** - * This #tag_handler implementation adds tag values to a #tag object - * (casted from the context pointer). - */ -extern const struct tag_handler add_tag_handler; - -/** - * This #tag_handler implementation adds tag values to a #tag object - * (casted from the context pointer), and supports the has_playlist - * attribute. - */ -extern const struct tag_handler full_tag_handler; - -#endif -- cgit v1.2.3