diff options
Diffstat (limited to 'src/plugins/flac_extractor.c')
-rw-r--r-- | src/plugins/flac_extractor.c | 92 |
1 files changed, 46 insertions, 46 deletions
diff --git a/src/plugins/flac_extractor.c b/src/plugins/flac_extractor.c index 3e88516..41a27b4 100644 --- a/src/plugins/flac_extractor.c +++ b/src/plugins/flac_extractor.c | |||
@@ -46,12 +46,12 @@ | |||
46 | * @return status code (error, end-of-file or success) | 46 | * @return status code (error, end-of-file or success) |
47 | */ | 47 | */ |
48 | static FLAC__StreamDecoderReadStatus | 48 | static FLAC__StreamDecoderReadStatus |
49 | flac_read (const FLAC__StreamDecoder *decoder, | 49 | flac_read (const FLAC__StreamDecoder *decoder, |
50 | FLAC__byte buffer[], | 50 | FLAC__byte buffer[], |
51 | size_t *bytes, | 51 | size_t *bytes, |
52 | void *client_data) | 52 | void *client_data) |
53 | { | 53 | { |
54 | struct EXTRACTOR_ExtractContext *ec = client_data; | 54 | struct EXTRACTOR_ExtractContext *ec = client_data; |
55 | void *data; | 55 | void *data; |
56 | ssize_t ret; | 56 | ssize_t ret; |
57 | 57 | ||
@@ -81,7 +81,7 @@ flac_read (const FLAC__StreamDecoder *decoder, | |||
81 | * @param client_data the 'struct EXTRACTOR_ExtractContext' | 81 | * @param client_data the 'struct EXTRACTOR_ExtractContext' |
82 | * @return status code (error or success) | 82 | * @return status code (error or success) |
83 | */ | 83 | */ |
84 | static FLAC__StreamDecoderSeekStatus | 84 | static FLAC__StreamDecoderSeekStatus |
85 | flac_seek (const FLAC__StreamDecoder *decoder, | 85 | flac_seek (const FLAC__StreamDecoder *decoder, |
86 | FLAC__uint64 absolute_byte_offset, | 86 | FLAC__uint64 absolute_byte_offset, |
87 | void *client_data) | 87 | void *client_data) |
@@ -103,9 +103,9 @@ flac_seek (const FLAC__StreamDecoder *decoder, | |||
103 | * @param client_data the 'struct EXTRACTOR_ExtractContext' | 103 | * @param client_data the 'struct EXTRACTOR_ExtractContext' |
104 | * @return status code (error or success) | 104 | * @return status code (error or success) |
105 | */ | 105 | */ |
106 | static FLAC__StreamDecoderTellStatus | 106 | static FLAC__StreamDecoderTellStatus |
107 | flac_tell (const FLAC__StreamDecoder *decoder, | 107 | flac_tell (const FLAC__StreamDecoder *decoder, |
108 | FLAC__uint64 *absolute_byte_offset, | 108 | FLAC__uint64 *absolute_byte_offset, |
109 | void *client_data) | 109 | void *client_data) |
110 | { | 110 | { |
111 | struct EXTRACTOR_ExtractContext *ec = client_data; | 111 | struct EXTRACTOR_ExtractContext *ec = client_data; |
@@ -113,7 +113,7 @@ flac_tell (const FLAC__StreamDecoder *decoder, | |||
113 | *absolute_byte_offset = ec->seek (ec->cls, | 113 | *absolute_byte_offset = ec->seek (ec->cls, |
114 | 0, | 114 | 0, |
115 | SEEK_CUR); | 115 | SEEK_CUR); |
116 | return FLAC__STREAM_DECODER_TELL_STATUS_OK; | 116 | return FLAC__STREAM_DECODER_TELL_STATUS_OK; |
117 | } | 117 | } |
118 | 118 | ||
119 | 119 | ||
@@ -125,13 +125,13 @@ flac_tell (const FLAC__StreamDecoder *decoder, | |||
125 | * @param client_data the 'struct EXTRACTOR_ExtractContext' | 125 | * @param client_data the 'struct EXTRACTOR_ExtractContext' |
126 | * @return true at EOF, false if not | 126 | * @return true at EOF, false if not |
127 | */ | 127 | */ |
128 | static FLAC__StreamDecoderLengthStatus | 128 | static FLAC__StreamDecoderLengthStatus |
129 | flac_length (const FLAC__StreamDecoder *decoder, | 129 | flac_length (const FLAC__StreamDecoder *decoder, |
130 | FLAC__uint64 *stream_length, | 130 | FLAC__uint64 *stream_length, |
131 | void *client_data) | 131 | void *client_data) |
132 | { | 132 | { |
133 | struct EXTRACTOR_ExtractContext *ec = client_data; | 133 | struct EXTRACTOR_ExtractContext *ec = client_data; |
134 | 134 | ||
135 | *stream_length = ec->get_size (ec->cls); | 135 | *stream_length = ec->get_size (ec->cls); |
136 | return FLAC__STREAM_DECODER_LENGTH_STATUS_OK; | 136 | return FLAC__STREAM_DECODER_LENGTH_STATUS_OK; |
137 | } | 137 | } |
@@ -146,8 +146,8 @@ flac_length (const FLAC__StreamDecoder *decoder, | |||
146 | * @return true at EOF, false if not | 146 | * @return true at EOF, false if not |
147 | */ | 147 | */ |
148 | static FLAC__bool | 148 | static FLAC__bool |
149 | flac_eof (const FLAC__StreamDecoder *decoder, | 149 | flac_eof (const FLAC__StreamDecoder *decoder, |
150 | void *client_data) | 150 | void *client_data) |
151 | { | 151 | { |
152 | struct EXTRACTOR_ExtractContext *ec = client_data; | 152 | struct EXTRACTOR_ExtractContext *ec = client_data; |
153 | uint64_t size; | 153 | uint64_t size; |
@@ -175,9 +175,9 @@ flac_eof (const FLAC__StreamDecoder *decoder, | |||
175 | */ | 175 | */ |
176 | static FLAC__StreamDecoderWriteStatus | 176 | static FLAC__StreamDecoderWriteStatus |
177 | flac_write (const FLAC__StreamDecoder *decoder, | 177 | flac_write (const FLAC__StreamDecoder *decoder, |
178 | const FLAC__Frame *frame, | 178 | const FLAC__Frame *frame, |
179 | const FLAC__int32 *const buffer[], | 179 | const FLAC__int32 *const buffer[], |
180 | void *client_data) | 180 | void *client_data) |
181 | { | 181 | { |
182 | return FLAC__STREAM_DECODER_WRITE_STATUS_CONTINUE; | 182 | return FLAC__STREAM_DECODER_WRITE_STATUS_CONTINUE; |
183 | } | 183 | } |
@@ -217,7 +217,7 @@ static struct Matches tmap[] = { | |||
217 | {"GENRE", EXTRACTOR_METATYPE_GENRE}, | 217 | {"GENRE", EXTRACTOR_METATYPE_GENRE}, |
218 | {"DATE", EXTRACTOR_METATYPE_CREATION_DATE}, | 218 | {"DATE", EXTRACTOR_METATYPE_CREATION_DATE}, |
219 | {"LOCATION", EXTRACTOR_METATYPE_LOCATION_SUBLOCATION}, | 219 | {"LOCATION", EXTRACTOR_METATYPE_LOCATION_SUBLOCATION}, |
220 | {"CONTACT", EXTRACTOR_METATYPE_CONTACT_INFORMATION}, | 220 | {"CONTACT", EXTRACTOR_METATYPE_CONTACT_INFORMATION}, |
221 | {"TRACKNUMBER", EXTRACTOR_METATYPE_TRACK_NUMBER}, | 221 | {"TRACKNUMBER", EXTRACTOR_METATYPE_TRACK_NUMBER}, |
222 | {"ISRC", EXTRACTOR_METATYPE_ISRC}, | 222 | {"ISRC", EXTRACTOR_METATYPE_ISRC}, |
223 | {NULL, 0} | 223 | {NULL, 0} |
@@ -241,7 +241,7 @@ static struct Matches tmap[] = { | |||
241 | * @return NULL on error, otherwise 0-terminated version of 's' | 241 | * @return NULL on error, otherwise 0-terminated version of 's' |
242 | */ | 242 | */ |
243 | static char * | 243 | static char * |
244 | xstrndup (const char *s, | 244 | xstrndup (const char *s, |
245 | size_t n) | 245 | size_t n) |
246 | { | 246 | { |
247 | char * d; | 247 | char * d; |
@@ -281,7 +281,7 @@ check (const char *type, | |||
281 | type, | 281 | type, |
282 | type_length)) ) | 282 | type_length)) ) |
283 | continue; | 283 | continue; |
284 | if (NULL == | 284 | if (NULL == |
285 | (tmp = xstrndup (value, | 285 | (tmp = xstrndup (value, |
286 | value_length))) | 286 | value_length))) |
287 | continue; | 287 | continue; |
@@ -299,10 +299,10 @@ check (const char *type, | |||
299 | * @param metadata meta data that was found | 299 | * @param metadata meta data that was found |
300 | * @param client_data the 'struct EXTRACTOR_ExtractContext' | 300 | * @param client_data the 'struct EXTRACTOR_ExtractContext' |
301 | */ | 301 | */ |
302 | static void | 302 | static void |
303 | flac_metadata (const FLAC__StreamDecoder *decoder, | 303 | flac_metadata (const FLAC__StreamDecoder *decoder, |
304 | const FLAC__StreamMetadata *metadata, | 304 | const FLAC__StreamMetadata *metadata, |
305 | void *client_data) | 305 | void *client_data) |
306 | { | 306 | { |
307 | struct EXTRACTOR_ExtractContext *ec = client_data; | 307 | struct EXTRACTOR_ExtractContext *ec = client_data; |
308 | enum EXTRACTOR_MetaType type; | 308 | enum EXTRACTOR_MetaType type; |
@@ -313,29 +313,29 @@ flac_metadata (const FLAC__StreamDecoder *decoder, | |||
313 | unsigned int len; | 313 | unsigned int len; |
314 | unsigned int ilen; | 314 | unsigned int ilen; |
315 | char buf[128]; | 315 | char buf[128]; |
316 | 316 | ||
317 | switch (metadata->type) | 317 | switch (metadata->type) |
318 | { | 318 | { |
319 | case FLAC__METADATA_TYPE_STREAMINFO: | 319 | case FLAC__METADATA_TYPE_STREAMINFO: |
320 | { | 320 | { |
321 | snprintf (buf, sizeof (buf), | 321 | snprintf (buf, sizeof (buf), |
322 | _("%u Hz, %u channels"), | 322 | _("%u Hz, %u channels"), |
323 | metadata->data.stream_info.sample_rate, | 323 | metadata->data.stream_info.sample_rate, |
324 | metadata->data.stream_info.channels); | 324 | metadata->data.stream_info.channels); |
325 | ADD (EXTRACTOR_METATYPE_RESOURCE_TYPE, buf); | 325 | ADD (EXTRACTOR_METATYPE_RESOURCE_TYPE, buf); |
326 | break; | 326 | break; |
327 | } | 327 | } |
328 | case FLAC__METADATA_TYPE_APPLICATION: | 328 | case FLAC__METADATA_TYPE_APPLICATION: |
329 | /* FIXME: could find out generator application here: | 329 | /* FIXME: could find out generator application here: |
330 | http://flac.sourceforge.net/api/structFLAC____StreamMetadata__Application.html and | 330 | http://flac.sourceforge.net/api/structFLAC____StreamMetadata__Application.html and |
331 | http://flac.sourceforge.net/id.html | 331 | http://flac.sourceforge.net/id.html |
332 | */ | 332 | */ |
333 | break; | 333 | break; |
334 | case FLAC__METADATA_TYPE_VORBIS_COMMENT: | 334 | case FLAC__METADATA_TYPE_VORBIS_COMMENT: |
335 | { | 335 | { |
336 | vc = &metadata->data.vorbis_comment; | 336 | vc = &metadata->data.vorbis_comment; |
337 | count = vc->num_comments; | 337 | count = vc->num_comments; |
338 | while (count-- > 0) | 338 | while (count-- > 0) |
339 | { | 339 | { |
340 | entry = &vc->comments[count]; | 340 | entry = &vc->comments[count]; |
341 | eq = (const char*) entry->entry; | 341 | eq = (const char*) entry->entry; |
@@ -355,7 +355,7 @@ flac_metadata (const FLAC__StreamDecoder *decoder, | |||
355 | ilen, | 355 | ilen, |
356 | eq, | 356 | eq, |
357 | len - ilen, | 357 | len - ilen, |
358 | ec); | 358 | ec); |
359 | } | 359 | } |
360 | break; | 360 | break; |
361 | } | 361 | } |
@@ -366,11 +366,11 @@ flac_metadata (const FLAC__StreamDecoder *decoder, | |||
366 | case FLAC__STREAM_METADATA_PICTURE_TYPE_OTHER: | 366 | case FLAC__STREAM_METADATA_PICTURE_TYPE_OTHER: |
367 | case FLAC__STREAM_METADATA_PICTURE_TYPE_FILE_ICON_STANDARD: | 367 | case FLAC__STREAM_METADATA_PICTURE_TYPE_FILE_ICON_STANDARD: |
368 | case FLAC__STREAM_METADATA_PICTURE_TYPE_FILE_ICON: | 368 | case FLAC__STREAM_METADATA_PICTURE_TYPE_FILE_ICON: |
369 | type = EXTRACTOR_METATYPE_THUMBNAIL; | 369 | type = EXTRACTOR_METATYPE_THUMBNAIL; |
370 | break; | 370 | break; |
371 | case FLAC__STREAM_METADATA_PICTURE_TYPE_FRONT_COVER: | 371 | case FLAC__STREAM_METADATA_PICTURE_TYPE_FRONT_COVER: |
372 | case FLAC__STREAM_METADATA_PICTURE_TYPE_BACK_COVER: | 372 | case FLAC__STREAM_METADATA_PICTURE_TYPE_BACK_COVER: |
373 | type = EXTRACTOR_METATYPE_COVER_PICTURE; | 373 | type = EXTRACTOR_METATYPE_COVER_PICTURE; |
374 | break; | 374 | break; |
375 | case FLAC__STREAM_METADATA_PICTURE_TYPE_LEAD_ARTIST: | 375 | case FLAC__STREAM_METADATA_PICTURE_TYPE_LEAD_ARTIST: |
376 | case FLAC__STREAM_METADATA_PICTURE_TYPE_ARTIST: | 376 | case FLAC__STREAM_METADATA_PICTURE_TYPE_ARTIST: |
@@ -378,13 +378,13 @@ flac_metadata (const FLAC__StreamDecoder *decoder, | |||
378 | case FLAC__STREAM_METADATA_PICTURE_TYPE_BAND: | 378 | case FLAC__STREAM_METADATA_PICTURE_TYPE_BAND: |
379 | case FLAC__STREAM_METADATA_PICTURE_TYPE_COMPOSER: | 379 | case FLAC__STREAM_METADATA_PICTURE_TYPE_COMPOSER: |
380 | case FLAC__STREAM_METADATA_PICTURE_TYPE_LYRICIST: | 380 | case FLAC__STREAM_METADATA_PICTURE_TYPE_LYRICIST: |
381 | type = EXTRACTOR_METATYPE_CONTRIBUTOR_PICTURE; | 381 | type = EXTRACTOR_METATYPE_CONTRIBUTOR_PICTURE; |
382 | break; | 382 | break; |
383 | case FLAC__STREAM_METADATA_PICTURE_TYPE_RECORDING_LOCATION: | 383 | case FLAC__STREAM_METADATA_PICTURE_TYPE_RECORDING_LOCATION: |
384 | case FLAC__STREAM_METADATA_PICTURE_TYPE_DURING_RECORDING: | 384 | case FLAC__STREAM_METADATA_PICTURE_TYPE_DURING_RECORDING: |
385 | case FLAC__STREAM_METADATA_PICTURE_TYPE_DURING_PERFORMANCE: | 385 | case FLAC__STREAM_METADATA_PICTURE_TYPE_DURING_PERFORMANCE: |
386 | case FLAC__STREAM_METADATA_PICTURE_TYPE_VIDEO_SCREEN_CAPTURE: | 386 | case FLAC__STREAM_METADATA_PICTURE_TYPE_VIDEO_SCREEN_CAPTURE: |
387 | type = EXTRACTOR_METATYPE_EVENT_PICTURE; | 387 | type = EXTRACTOR_METATYPE_EVENT_PICTURE; |
388 | break; | 388 | break; |
389 | case FLAC__STREAM_METADATA_PICTURE_TYPE_BAND_LOGOTYPE: | 389 | case FLAC__STREAM_METADATA_PICTURE_TYPE_BAND_LOGOTYPE: |
390 | case FLAC__STREAM_METADATA_PICTURE_TYPE_PUBLISHER_LOGOTYPE: | 390 | case FLAC__STREAM_METADATA_PICTURE_TYPE_PUBLISHER_LOGOTYPE: |
@@ -396,10 +396,10 @@ flac_metadata (const FLAC__StreamDecoder *decoder, | |||
396 | case FLAC__STREAM_METADATA_PICTURE_TYPE_ILLUSTRATION: | 396 | case FLAC__STREAM_METADATA_PICTURE_TYPE_ILLUSTRATION: |
397 | default: | 397 | default: |
398 | type = EXTRACTOR_METATYPE_PICTURE; | 398 | type = EXTRACTOR_METATYPE_PICTURE; |
399 | break; | 399 | break; |
400 | } | 400 | } |
401 | ec->proc (ec->cls, | 401 | ec->proc (ec->cls, |
402 | "flac", | 402 | "flac", |
403 | type, | 403 | type, |
404 | EXTRACTOR_METAFORMAT_BINARY, | 404 | EXTRACTOR_METAFORMAT_BINARY, |
405 | metadata->data.picture.mime_type, | 405 | metadata->data.picture.mime_type, |
@@ -411,9 +411,10 @@ flac_metadata (const FLAC__StreamDecoder *decoder, | |||
411 | case FLAC__METADATA_TYPE_SEEKTABLE: | 411 | case FLAC__METADATA_TYPE_SEEKTABLE: |
412 | case FLAC__METADATA_TYPE_CUESHEET: | 412 | case FLAC__METADATA_TYPE_CUESHEET: |
413 | case FLAC__METADATA_TYPE_UNDEFINED: | 413 | case FLAC__METADATA_TYPE_UNDEFINED: |
414 | case FLAC__MAX_METADATA_TYPE: | ||
414 | break; | 415 | break; |
415 | } | 416 | } |
416 | } | 417 | } |
417 | 418 | ||
418 | 419 | ||
419 | /** | 420 | /** |
@@ -424,9 +425,9 @@ flac_metadata (const FLAC__StreamDecoder *decoder, | |||
424 | * @param client_data our 'struct EXTRACTOR_ExtractContext' | 425 | * @param client_data our 'struct EXTRACTOR_ExtractContext' |
425 | */ | 426 | */ |
426 | static void | 427 | static void |
427 | flac_error (const FLAC__StreamDecoder *decoder, | 428 | flac_error (const FLAC__StreamDecoder *decoder, |
428 | FLAC__StreamDecoderErrorStatus status, | 429 | FLAC__StreamDecoderErrorStatus status, |
429 | void *client_data) | 430 | void *client_data) |
430 | { | 431 | { |
431 | /* ignore errors */ | 432 | /* ignore errors */ |
432 | } | 433 | } |
@@ -437,7 +438,7 @@ flac_error (const FLAC__StreamDecoder *decoder, | |||
437 | * | 438 | * |
438 | * @param ec extraction context provided to the plugin | 439 | * @param ec extraction context provided to the plugin |
439 | */ | 440 | */ |
440 | void | 441 | void |
441 | EXTRACTOR_flac_extract_method (struct EXTRACTOR_ExtractContext *ec) | 442 | EXTRACTOR_flac_extract_method (struct EXTRACTOR_ExtractContext *ec) |
442 | { | 443 | { |
443 | FLAC__StreamDecoder * decoder; | 444 | FLAC__StreamDecoder * decoder; |
@@ -448,7 +449,7 @@ EXTRACTOR_flac_extract_method (struct EXTRACTOR_ExtractContext *ec) | |||
448 | FLAC__stream_decoder_set_metadata_ignore_all (decoder); | 449 | FLAC__stream_decoder_set_metadata_ignore_all (decoder); |
449 | if (false == FLAC__stream_decoder_set_metadata_respond_all (decoder)) | 450 | if (false == FLAC__stream_decoder_set_metadata_respond_all (decoder)) |
450 | { | 451 | { |
451 | FLAC__stream_decoder_delete (decoder); | 452 | FLAC__stream_decoder_delete (decoder); |
452 | return; | 453 | return; |
453 | } | 454 | } |
454 | if (FLAC__STREAM_DECODER_INIT_STATUS_OK != | 455 | if (FLAC__STREAM_DECODER_INIT_STATUS_OK != |
@@ -463,17 +464,17 @@ EXTRACTOR_flac_extract_method (struct EXTRACTOR_ExtractContext *ec) | |||
463 | &flac_error, | 464 | &flac_error, |
464 | ec)) | 465 | ec)) |
465 | { | 466 | { |
466 | FLAC__stream_decoder_delete (decoder); | 467 | FLAC__stream_decoder_delete (decoder); |
467 | return; | 468 | return; |
468 | } | 469 | } |
469 | if (FLAC__STREAM_DECODER_SEARCH_FOR_METADATA != FLAC__stream_decoder_get_state(decoder)) | 470 | if (FLAC__STREAM_DECODER_SEARCH_FOR_METADATA != FLAC__stream_decoder_get_state(decoder)) |
470 | { | 471 | { |
471 | FLAC__stream_decoder_delete (decoder); | 472 | FLAC__stream_decoder_delete (decoder); |
472 | return; | 473 | return; |
473 | } | 474 | } |
474 | if (! FLAC__stream_decoder_process_until_end_of_metadata(decoder)) | 475 | if (! FLAC__stream_decoder_process_until_end_of_metadata(decoder)) |
475 | { | 476 | { |
476 | FLAC__stream_decoder_delete (decoder); | 477 | FLAC__stream_decoder_delete (decoder); |
477 | return; | 478 | return; |
478 | } | 479 | } |
479 | switch (FLAC__stream_decoder_get_state (decoder)) | 480 | switch (FLAC__stream_decoder_get_state (decoder)) |
@@ -487,9 +488,8 @@ EXTRACTOR_flac_extract_method (struct EXTRACTOR_ExtractContext *ec) | |||
487 | /* not so sure... */ | 488 | /* not so sure... */ |
488 | break; | 489 | break; |
489 | } | 490 | } |
490 | FLAC__stream_decoder_finish (decoder); | 491 | FLAC__stream_decoder_finish (decoder); |
491 | FLAC__stream_decoder_delete (decoder); | 492 | FLAC__stream_decoder_delete (decoder); |
492 | } | 493 | } |
493 | 494 | ||
494 | /* end of flac_extractor.c */ | 495 | /* end of flac_extractor.c */ |
495 | |||