Mercurial > audlegacy-plugins
comparison src/demac/plugin.c @ 2666:053341c248ef
"Fix" demac plugin not to arbitrarily determine that all files belong to it...
this plugin could use some serious cleanups, tho.
| author | Matti Hamalainen <ccr@tnsp.org> |
|---|---|
| date | Fri, 30 May 2008 05:17:45 +0300 |
| parents | bd3a24b39058 |
| children | 3134a0987162 |
comparison
equal
deleted
inserted
replaced
| 2665:3f931f933750 | 2666:053341c248ef |
|---|---|
| 272 g_free(delem->data); | 272 g_free(delem->data); |
| 273 } | 273 } |
| 274 | 274 |
| 275 Tuple *demac_probe_for_tuple (gchar *uri, VFSFile *vfd) { | 275 Tuple *demac_probe_for_tuple (gchar *uri, VFSFile *vfd) { |
| 276 AUDDBG("** demac: plugin.c: demac_probe_for_tuple()\n"); | 276 AUDDBG("** demac: plugin.c: demac_probe_for_tuple()\n"); |
| 277 Tuple *tpl = aud_tuple_new_from_filename(uri); | |
| 278 gchar codec_string[32]; | 277 gchar codec_string[32]; |
| 279 | 278 |
| 280 if (aud_vfs_is_streaming(vfd)) { | 279 if (aud_vfs_is_streaming(vfd)) { |
| 281 /* This plugin does not support streams yet */ | 280 /* This plugin does not support streams yet */ |
| 282 return NULL; | 281 return NULL; |
| 283 } | 282 } |
| 284 | 283 |
| 284 APEContext *ctx = calloc(sizeof(APEContext), 1); | |
| 285 aud_vfs_rewind(vfd); | |
| 286 if (ape_read_header(ctx, vfd, 1) < 0) { | |
| 287 free(ctx); | |
| 288 aud_vfs_rewind(vfd); | |
| 289 return NULL; | |
| 290 } | |
| 291 | |
| 292 Tuple *tpl = aud_tuple_new_from_filename(uri); | |
| 285 mowgli_dictionary_t *tag = NULL; | 293 mowgli_dictionary_t *tag = NULL; |
| 286 gchar *item; | 294 gchar *item; |
| 287 if ((tag = parse_apev2_tag(vfd)) != NULL) { | 295 if ((tag = parse_apev2_tag(vfd)) != NULL) { |
| 288 if((item = mowgli_dictionary_retrieve(tag, "Artist")) != NULL) aud_tuple_associate_string(tpl, FIELD_ARTIST, NULL, item); | 296 if((item = mowgli_dictionary_retrieve(tag, "Artist")) != NULL) aud_tuple_associate_string(tpl, FIELD_ARTIST, NULL, item); |
| 289 if((item = mowgli_dictionary_retrieve(tag, "Title")) != NULL) aud_tuple_associate_string(tpl, FIELD_TITLE, NULL, item); | 297 if((item = mowgli_dictionary_retrieve(tag, "Title")) != NULL) aud_tuple_associate_string(tpl, FIELD_TITLE, NULL, item); |
| 292 if((item = mowgli_dictionary_retrieve(tag, "Genre")) != NULL) aud_tuple_associate_string(tpl, FIELD_GENRE, NULL, item); | 300 if((item = mowgli_dictionary_retrieve(tag, "Genre")) != NULL) aud_tuple_associate_string(tpl, FIELD_GENRE, NULL, item); |
| 293 if((item = mowgli_dictionary_retrieve(tag, "Track")) != NULL) aud_tuple_associate_int(tpl, FIELD_TRACK_NUMBER, NULL, atoi(item)); | 301 if((item = mowgli_dictionary_retrieve(tag, "Track")) != NULL) aud_tuple_associate_int(tpl, FIELD_TRACK_NUMBER, NULL, atoi(item)); |
| 294 if((item = mowgli_dictionary_retrieve(tag, "Year")) != NULL) aud_tuple_associate_int(tpl, FIELD_YEAR, NULL, atoi(item)); | 302 if((item = mowgli_dictionary_retrieve(tag, "Year")) != NULL) aud_tuple_associate_int(tpl, FIELD_YEAR, NULL, atoi(item)); |
| 295 } | 303 } |
| 296 | 304 |
| 297 APEContext *ctx = calloc(sizeof(APEContext), 1); | |
| 298 aud_vfs_rewind(vfd); | |
| 299 ape_read_header(ctx, vfd, 1); | |
| 300 aud_tuple_associate_int(tpl, FIELD_LENGTH, NULL, ctx->duration); | 305 aud_tuple_associate_int(tpl, FIELD_LENGTH, NULL, ctx->duration); |
| 301 g_sprintf(codec_string, "Monkey's Audio v%4.2f", (float)ctx->fileversion/1000.0); | 306 g_snprintf(codec_string, sizeof(codec_string), "Monkey's Audio v%4.2f", (float)ctx->fileversion/1000.0); |
| 302 AUDDBG("** demac: plugin.c: Codec: %s\n", codec_string); | 307 AUDDBG("** demac: plugin.c: Codec: %s\n", codec_string); |
| 303 aud_tuple_associate_string(tpl, FIELD_CODEC, NULL, codec_string); | 308 aud_tuple_associate_string(tpl, FIELD_CODEC, NULL, codec_string); |
| 304 aud_tuple_associate_string(tpl, FIELD_QUALITY, NULL, "lossless"); | 309 aud_tuple_associate_string(tpl, FIELD_QUALITY, NULL, "lossless"); |
| 305 aud_tuple_associate_string(tpl, FIELD_MIMETYPE, NULL, "audio/x-ape"); | 310 aud_tuple_associate_string(tpl, FIELD_MIMETYPE, NULL, "audio/x-ape"); |
| 306 | 311 |
