diff options
Diffstat (limited to 'decoder.c')
-rw-r--r-- | decoder.c | 28 |
1 files changed, 28 insertions, 0 deletions
@@ -13,3 +13,31 @@ gssize decoder_decode(struct decoder *decoder, const guchar *inbuf, void decoder_close(struct decoder *decoder) { decoder->decoder->close(decoder->data); } + +extern const struct decoder_plugin decoder_mpg123_decoder; + +static const struct decoder_plugin *decoder_plugins[] = { + &decoder_mpg123_decoder, + NULL, +}; + +const struct decoder_plugin *decoder_find(const gchar *filename) { + gchar *ext = g_strrstr(filename, "."); + if(ext == NULL) { + g_warning("decoder_find: no file extension found"); + return NULL; + } + // exclude the dot + ext++; + + for(int i = 0; decoder_plugins[i]; i++) { + const struct decoder_plugin *plugin = decoder_plugins[i]; + for(int j = 0; plugin[i].extensions[j]; j++) { + if(g_strcmp0(plugin[i].extensions[j], ext) == 0) { + return plugin; + } + } + } + + return NULL; +} |