diff options
author | Max Kellermann <max@duempel.org> | 2009-02-15 18:33:28 +0100 |
---|---|---|
committer | Max Kellermann <max@duempel.org> | 2009-02-15 18:33:28 +0100 |
commit | 3e3c524264ceedb9aff3291ed9f7b516250d428e (patch) | |
tree | d424a9eef99f3f01181fa5a039fc8609b978fa90 /src/decoder_plugin.h | |
parent | a28287073b6ced1ab2b3c7dcc0a1168d9e7ac7ea (diff) | |
download | mpd-3e3c524264ceedb9aff3291ed9f7b516250d428e.tar.gz mpd-3e3c524264ceedb9aff3291ed9f7b516250d428e.tar.xz mpd-3e3c524264ceedb9aff3291ed9f7b516250d428e.zip |
decoder_plugin: added inline wrapper functions
Increase code readability, always use the wrapper functions instead of
calling the plugin method pointers directly.
Diffstat (limited to 'src/decoder_plugin.h')
-rw-r--r-- | src/decoder_plugin.h | 55 |
1 files changed, 55 insertions, 0 deletions
diff --git a/src/decoder_plugin.h b/src/decoder_plugin.h index 3c05dc5b7..7034103ba 100644 --- a/src/decoder_plugin.h +++ b/src/decoder_plugin.h @@ -20,6 +20,7 @@ #define MPD_DECODER_PLUGIN_H #include <stdbool.h> +#include <stddef.h> struct input_stream; struct tag; @@ -77,4 +78,58 @@ struct decoder_plugin { const char *const*mime_types; }; +/** + * Initialize a decoder plugin. + * + * @return true if the plugin was initialized successfully, false if + * the plugin is not available + */ +static inline bool +decoder_plugin_init(const struct decoder_plugin *plugin) +{ + return plugin->init != NULL + ? plugin->init() + : true; +} + +/** + * Deinitialize a decoder plugin which was initialized successfully. + */ +static inline void +decoder_plugin_finish(const struct decoder_plugin *plugin) +{ + if (plugin->finish != NULL) + plugin->finish(); +} + +/** + * Decode a stream. + */ +static inline void +decoder_plugin_stream_decode(const struct decoder_plugin *plugin, + struct decoder *decoder, struct input_stream *is) +{ + plugin->stream_decode(decoder, is); +} + +/** + * Decode a file. + */ +static inline void +decoder_plugin_file_decode(const struct decoder_plugin *plugin, + struct decoder *decoder, const char *path_fs) +{ + plugin->file_decode(decoder, path_fs); +} + +/** + * Read the tag of a file. + */ +static inline struct tag * +decoder_plugin_tag_dup(const struct decoder_plugin *plugin, + const char *path_fs) +{ + return plugin->tag_dup(path_fs); +} + #endif |