1 --- mpd-0.12.1/src/inputPlugins/_flac_common.h.orig 2007-01-01 20:16:07.000000000 +0000
2 +++ mpd-0.12.1/src/inputPlugins/_flac_common.h 2007-01-01 21:10:31.000000000 +0000
4 #include "../inputStream.h"
5 #include "../outputBuffer.h"
7 -#include <FLAC/seekable_stream_decoder.h>
8 +#include <FLAC/export.h>
9 +#if !defined(FLAC_API_VERSION_CURRENT) || FLAC_API_VERSION_CURRENT <= 7
10 +# include <FLAC/seekable_stream_decoder.h>
11 +# define flac_decoder FLAC__SeekableStreamDecoder
12 +# define flac_new(x) FLAC__seekable_stream_decoder_new(x)
14 +# define flac_ogg_init(a,b,c,d,e,f,g,h,i,j) (0)
16 +# define flac_get_decode_position(x,y) \
17 + FLAC__seekable_stream_decoder_get_decode_position(x,y)
18 +# define flac_get_state(x) FLAC__seekable_stream_decoder_get_state(x)
19 +# define flac_process_single(x) FLAC__seekable_stream_decoder_process_single(x)
20 +# define flac_process_metadata(x) \
21 + FLAC__seekable_stream_decoder_process_until_end_of_metadata(x)
22 +# define flac_seek_absolute(x,y) \
23 + FLAC__seekable_stream_decoder_seek_absolute(x,y)
24 +# define flac_finish(x) FLAC__seekable_stream_decoder_finish(x)
25 +# define flac_delete(x) FLAC__seekable_stream_decoder_delete(x)
27 +# define flac_decoder_eof FLAC__SEEKABLE_STREAM_DECODER_END_OF_STREAM
29 +# define flac_read_status FLAC__SeekableStreamDecoderReadStatus
30 +# define flac_read_status_continue \
31 + FLAC__SEEKABLE_STREAM_DECODER_READ_STATUS_OK
32 +# define flac_read_status_eof FLAC__SEEKABLE_STREAM_DECODER_READ_STATUS_OK
33 +# define flac_read_status_abort \
34 + FLAC__SEEKABLE_STREAM_DECODER_READ_STATUS_ERROR
36 +# define flac_seek_status FLAC__SeekableStreamDecoderSeekStatus
37 +# define flac_seek_status_ok FLAC__SEEKABLE_STREAM_DECODER_SEEK_STATUS_OK
38 +# define flac_seek_status_error FLAC__SEEKABLE_STREAM_DECODER_SEEK_STATUS_ERROR
40 +# define flac_tell_status FLAC__SeekableStreamDecoderTellStatus
41 +# define flac_tell_status_ok FLAC__SEEKABLE_STREAM_DECODER_TELL_STATUS_OK
42 +# define flac_tell_status_error \
43 + FLAC__SEEKABLE_STREAM_DECODER_TELL_STATUS_ERROR
44 +# define flac_tell_status_unsupported \
45 + FLAC__SEEKABLE_STREAM_DECODER_TELL_STATUS_ERROR
47 +# define flac_length_status FLAC__SeekableStreamDecoderLengthStatus
48 +# define flac_length_status_ok FLAC__SEEKABLE_STREAM_DECODER_LENGTH_STATUS_OK
49 +# define flac_length_status_error \
50 + FLAC__SEEKABLE_STREAM_DECODER_LENGTH_STATUS_ERROR
51 +# define flac_length_status_unsupported \
52 + FLAC__SEEKABLE_STREAM_DECODER_LENGTH_STATUS_ERROR
55 +# include <OggFLAC/seekable_stream_decoder.h>
57 +#else /* FLAC_API_VERSION_CURRENT >= 7 */
59 + /* OggFLAC support is handled by our flac_plugin already, and
60 + * thus we *can* always have it if libFLAC was compiled with it */
61 +# ifndef HAVE_OGGFLAC
62 +# define HAVE_OGGFLAC 1
64 +# include "_ogg_common.h"
65 +# undef HAVE_OGGFLAC /* we don't need this defined anymore */
67 +# include <FLAC/stream_decoder.h>
68 +# define flac_decoder FLAC__StreamDecoder
69 +# define flac_new(x) FLAC__stream_decoder_new(x)
71 +# define flac_init(a,b,c,d,e,f,g,h,i,j) \
72 + (FLAC__stream_decoder_init_stream(a,b,c,d,e,f,g,h,i,j) \
73 + == FLAC__STREAM_DECODER_INIT_STATUS_OK)
74 +# define flac_ogg_init(a,b,c,d,e,f,g,h,i,j) \
75 + (FLAC__stream_decoder_init_ogg_stream(a,b,c,d,e,f,g,h,i,j) \
76 + == FLAC__STREAM_DECODER_INIT_STATUS_OK)
78 +# define flac_get_decode_position(x,y) \
79 + FLAC__stream_decoder_get_decode_position(x,y)
80 +# define flac_get_state(x) FLAC__stream_decoder_get_state(x)
81 +# define flac_process_single(x) FLAC__stream_decoder_process_single(x)
82 +# define flac_process_metadata(x) \
83 + FLAC__stream_decoder_process_until_end_of_metadata(x)
84 +# define flac_seek_absolute(x,y) FLAC__stream_decoder_seek_absolute(x,y)
85 +# define flac_finish(x) FLAC__stream_decoder_finish(x)
86 +# define flac_delete(x) FLAC__stream_decoder_delete(x)
88 +# define flac_decoder_eof FLAC__STREAM_DECODER_END_OF_STREAM
90 +# define flac_read_status FLAC__StreamDecoderReadStatus
91 +# define flac_read_status_continue \
92 + FLAC__STREAM_DECODER_READ_STATUS_CONTINUE
93 +# define flac_read_status_eof FLAC__STREAM_DECODER_READ_STATUS_END_OF_STREAM
94 +# define flac_read_status_abort FLAC__STREAM_DECODER_READ_STATUS_ABORT
96 +# define flac_seek_status FLAC__StreamDecoderSeekStatus
97 +# define flac_seek_status_ok FLAC__STREAM_DECODER_SEEK_STATUS_OK
98 +# define flac_seek_status_error FLAC__STREAM_DECODER_SEEK_STATUS_ERROR
99 +# define flac_seek_status_unsupported \
100 + FLAC__STREAM_DECODER_SEEK_STATUS_UNSUPPORTED
102 +# define flac_tell_status FLAC__StreamDecoderTellStatus
103 +# define flac_tell_status_ok FLAC__STREAM_DECODER_TELL_STATUS_OK
104 +# define flac_tell_status_error FLAC__STREAM_DECODER_TELL_STATUS_ERROR
105 +# define flac_tell_status_unsupported \
106 + FLAC__STREAM_DECODER_TELL_STATUS_UNSUPPORTED
108 +# define flac_length_status FLAC__StreamDecoderLengthStatus
109 +# define flac_length_status_ok FLAC__STREAM_DECODER_LENGTH_STATUS_OK
110 +# define flac_length_status_error FLAC__STREAM_DECODER_LENGTH_STATUS_ERROR
111 +# define flac_length_status_unsupported \
112 + FLAC__STREAM_DECODER_LENGTH_STATUS_UNSUPPORTED
114 +#endif /* FLAC_API_VERSION_CURRENT >= 7 */
116 #include <FLAC/metadata.h>
118 #define FLAC_CHUNK_SIZE 4080
119 --- mpd-0.12.1/src/inputPlugins/flac_plugin.c.orig 2007-01-01 20:17:35.000000000 +0000
120 +++ mpd-0.12.1/src/inputPlugins/flac_plugin.c 2007-01-01 21:08:32.000000000 +0000
122 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
125 -#include "../inputPlugin.h"
126 +#include "_flac_common.h"
130 -#include "_flac_common.h"
132 #include "../utils.h"
134 #include "../pcm_utils.h"
139 -#include <FLAC/seekable_stream_decoder.h>
140 -#include <FLAC/metadata.h>
143 -/* this code is based on flac123, from flac-tools */
144 +/* this code was based on flac123, from flac-tools */
146 -static void flacError(const FLAC__SeekableStreamDecoder *,
147 - FLAC__StreamDecoderErrorStatus, void *);
148 -static void flacPrintErroredState(FLAC__SeekableStreamDecoderState state);
149 -static void flacMetadata(const FLAC__SeekableStreamDecoder *,
150 - const FLAC__StreamMetadata *, void *);
151 -static FLAC__StreamDecoderWriteStatus flacWrite(const
152 - FLAC__SeekableStreamDecoder *,
153 - const FLAC__Frame *,
154 - const FLAC__int32 * const buf[],
156 -static FLAC__SeekableStreamDecoderReadStatus flacRead(const
157 - FLAC__SeekableStreamDecoder
158 - *, FLAC__byte buf[],
159 - unsigned *, void *);
160 -static FLAC__SeekableStreamDecoderSeekStatus flacSeek(const
161 - FLAC__SeekableStreamDecoder
162 - *, FLAC__uint64, void *);
163 -static FLAC__SeekableStreamDecoderTellStatus flacTell(const
164 - FLAC__SeekableStreamDecoder
167 -static FLAC__SeekableStreamDecoderLengthStatus flacLength(const
168 - FLAC__SeekableStreamDecoder
171 -static FLAC__bool flacEOF(const FLAC__SeekableStreamDecoder *, void *);
173 -static int flac_decode(OutputBuffer * cb, DecoderControl * dc,
174 - InputStream * inStream)
176 - FLAC__SeekableStreamDecoder *flacDec = NULL;
181 - init_FlacData(&data, cb, dc, inStream);
183 - if (!(flacDec = FLAC__seekable_stream_decoder_new())) {
187 - /*status&=FLAC__file_decoder_set_md5_checking(flacDec,1); */
188 - status &= FLAC__seekable_stream_decoder_set_read_callback(flacDec,
190 - status &= FLAC__seekable_stream_decoder_set_seek_callback(flacDec,
192 - status &= FLAC__seekable_stream_decoder_set_tell_callback(flacDec,
194 - status &= FLAC__seekable_stream_decoder_set_length_callback(flacDec,
197 - FLAC__seekable_stream_decoder_set_eof_callback(flacDec, flacEOF);
199 - FLAC__seekable_stream_decoder_set_write_callback(flacDec,
202 - FLAC__seekable_stream_decoder_set_metadata_callback(flacDec,
205 - FLAC__seekable_stream_decoder_set_metadata_respond(flacDec,
206 - FLAC__METADATA_TYPE_VORBIS_COMMENT);
208 - FLAC__seekable_stream_decoder_set_error_callback(flacDec,
211 - FLAC__seekable_stream_decoder_set_client_data(flacDec,
214 - ERROR("flac problem before init()\n");
215 - flacPrintErroredState(FLAC__seekable_stream_decoder_get_state
221 - if (FLAC__seekable_stream_decoder_init(flacDec) !=
222 - FLAC__SEEKABLE_STREAM_DECODER_OK) {
223 - ERROR("flac problem doing init()\n");
224 - flacPrintErroredState(FLAC__seekable_stream_decoder_get_state
230 - if (!FLAC__seekable_stream_decoder_process_until_end_of_metadata
232 - ERROR("flac problem reading metadata\n");
233 - flacPrintErroredState(FLAC__seekable_stream_decoder_get_state
239 - dc->state = DECODE_STATE_DECODE;
242 - FLAC__seekable_stream_decoder_process_single(flacDec);
243 - if (FLAC__seekable_stream_decoder_get_state(flacDec) !=
244 - FLAC__SEEKABLE_STREAM_DECODER_OK) {
248 - FLAC__uint64 sampleToSeek = dc->seekWhere *
249 - dc->audioFormat.sampleRate + 0.5;
250 - if (FLAC__seekable_stream_decoder_seek_absolute(flacDec,
253 - clearOutputBuffer(cb);
254 - data.time = ((float)sampleToSeek) /
255 - dc->audioFormat.sampleRate;
262 - /* I don't think we need this bit here! -shank */
263 - /*FLAC__file_decoder_process_until_end_of_file(flacDec); */
265 - flacPrintErroredState(FLAC__seekable_stream_decoder_get_state
267 - FLAC__seekable_stream_decoder_finish(flacDec);
269 - /* send last little bit */
270 - if (data.chunk_length > 0 && !dc->stop) {
271 - flacSendChunk(&data);
272 - flushOutputBuffer(data.cb);
280 - dc->state = DECODE_STATE_STOP;
284 - if (data.replayGainInfo)
285 - freeReplayGainInfo(data.replayGainInfo);
288 - FLAC__seekable_stream_decoder_delete(flacDec);
290 - closeInputStream(inStream);
295 -static FLAC__SeekableStreamDecoderReadStatus flacRead(const
296 - FLAC__SeekableStreamDecoder
301 +static flac_read_status flacRead(const flac_decoder * flacDec,
306 FlacData *data = (FlacData *) fdata;
312 - if (*bytes == 0 && !inputStreamAtEOF(data->inStream) && !data->dc->stop)
313 - return FLAC__SEEKABLE_STREAM_DECODER_READ_STATUS_ERROR;
315 - return FLAC__SEEKABLE_STREAM_DECODER_READ_STATUS_OK;
316 + if (r == 0 && !data->dc->stop) {
317 + if (inputStreamAtEOF(data->inStream))
318 + return flac_read_status_eof;
320 + return flac_read_status_abort;
322 + return flac_read_status_continue;
325 -static FLAC__SeekableStreamDecoderSeekStatus flacSeek(const
326 - FLAC__SeekableStreamDecoder
328 - FLAC__uint64 offset,
330 +static flac_seek_status flacSeek(const flac_decoder * flacDec,
331 + FLAC__uint64 offset,
334 FlacData *data = (FlacData *) fdata;
336 if (seekInputStream(data->inStream, offset, SEEK_SET) < 0) {
337 - return FLAC__SEEKABLE_STREAM_DECODER_SEEK_STATUS_ERROR;
338 + return flac_seek_status_error;
341 - return FLAC__SEEKABLE_STREAM_DECODER_SEEK_STATUS_OK;
342 + return flac_tell_status_ok;
345 -static FLAC__SeekableStreamDecoderTellStatus flacTell(const
346 - FLAC__SeekableStreamDecoder
348 - FLAC__uint64 * offset,
350 +static flac_tell_status flacTell(const flac_decoder * flacDec,
351 + FLAC__uint64 * offset,
354 FlacData *data = (FlacData *) fdata;
356 *offset = (long)(data->inStream->offset);
358 - return FLAC__SEEKABLE_STREAM_DECODER_TELL_STATUS_OK;
359 + return flac_tell_status_ok;
362 -static FLAC__SeekableStreamDecoderLengthStatus flacLength(const
363 - FLAC__SeekableStreamDecoder
365 - FLAC__uint64 * length,
367 +static flac_length_status flacLength(const flac_decoder * flacDec,
368 + FLAC__uint64 * length,
371 FlacData *data = (FlacData *) fdata;
373 *length = (size_t) (data->inStream->size);
375 - return FLAC__SEEKABLE_STREAM_DECODER_LENGTH_STATUS_OK;
376 + return flac_length_status_ok;
379 -static FLAC__bool flacEOF(const FLAC__SeekableStreamDecoder * flacDec,
381 +static FLAC__bool flacEOF(const flac_decoder * flacDec, void *fdata)
383 FlacData *data = (FlacData *) fdata;
385 @@ -264,52 +106,112 @@
389 -static void flacError(const FLAC__SeekableStreamDecoder * dec,
390 +static void flacError(const flac_decoder *dec,
391 FLAC__StreamDecoderErrorStatus status, void *fdata)
393 flac_error_common_cb("flac", status, (FlacData *) fdata);
396 +#if !defined(FLAC_API_VERSION_CURRENT) || FLAC_API_VERSION_CURRENT <= 7
397 static void flacPrintErroredState(FLAC__SeekableStreamDecoderState state)
399 + const char *str = ""; /* "" to silence compiler warning */
401 + case FLAC__SEEKABLE_STREAM_DECODER_OK:
402 + case FLAC__SEEKABLE_STREAM_DECODER_SEEKING:
403 + case FLAC__SEEKABLE_STREAM_DECODER_END_OF_STREAM:
405 case FLAC__SEEKABLE_STREAM_DECODER_MEMORY_ALLOCATION_ERROR:
406 - ERROR("flac allocation error\n");
407 + str = "allocation error";
409 case FLAC__SEEKABLE_STREAM_DECODER_READ_ERROR:
410 - ERROR("flac read error\n");
411 + str = "read error";
413 case FLAC__SEEKABLE_STREAM_DECODER_SEEK_ERROR:
414 - ERROR("flac seek error\n");
415 + str = "seek error";
417 case FLAC__SEEKABLE_STREAM_DECODER_STREAM_DECODER_ERROR:
418 - ERROR("flac seekable stream error\n");
419 + str = "seekable stream error";
421 case FLAC__SEEKABLE_STREAM_DECODER_ALREADY_INITIALIZED:
422 - ERROR("flac decoder already initialized\n");
423 + str = "decoder already initialized";
425 case FLAC__SEEKABLE_STREAM_DECODER_INVALID_CALLBACK:
426 - ERROR("invalid flac callback\n");
427 + str = "invalid callback";
429 case FLAC__SEEKABLE_STREAM_DECODER_UNINITIALIZED:
430 - ERROR("flac decoder uninitialized\n");
431 + str = "decoder uninitialized";
433 + ERROR("flac %s\n", str);
436 +static int flac_init(FLAC__SeekableStreamDecoder *dec,
437 + FLAC__SeekableStreamDecoderReadCallback read_cb,
438 + FLAC__SeekableStreamDecoderSeekCallback seek_cb,
439 + FLAC__SeekableStreamDecoderTellCallback tell_cb,
440 + FLAC__SeekableStreamDecoderLengthCallback length_cb,
441 + FLAC__SeekableStreamDecoderEofCallback eof_cb,
442 + FLAC__SeekableStreamDecoderWriteCallback write_cb,
443 + FLAC__SeekableStreamDecoderMetadataCallback metadata_cb,
444 + FLAC__SeekableStreamDecoderErrorCallback error_cb,
448 + s &= FLAC__seekable_stream_decoder_set_read_callback(dec, read_cb);
449 + s &= FLAC__seekable_stream_decoder_set_seek_callback(dec, seek_cb);
450 + s &= FLAC__seekable_stream_decoder_set_tell_callback(dec, tell_cb);
451 + s &= FLAC__seekable_stream_decoder_set_length_callback(dec, length_cb);
452 + s &= FLAC__seekable_stream_decoder_set_eof_callback(dec, eof_cb);
453 + s &= FLAC__seekable_stream_decoder_set_write_callback(dec, write_cb);
454 + s &= FLAC__seekable_stream_decoder_set_metadata_callback(dec,
456 + s &= FLAC__seekable_stream_decoder_set_metadata_respond(dec,
457 + FLAC__METADATA_TYPE_VORBIS_COMMENT);
458 + s &= FLAC__seekable_stream_decoder_set_error_callback(dec, error_cb);
459 + s &= FLAC__seekable_stream_decoder_set_client_data(dec, data);
460 + if (!s || (FLAC__seekable_stream_decoder_init(dec) !=
461 + FLAC__SEEKABLE_STREAM_DECODER_OK))
465 +#else /* FLAC_API_VERSION_CURRENT >= 7 */
466 +static void flacPrintErroredState(FLAC__StreamDecoderState state)
468 + const char *str = ""; /* "" to silence compiler warning */
470 + case FLAC__STREAM_DECODER_SEARCH_FOR_METADATA:
471 + case FLAC__STREAM_DECODER_READ_METADATA:
472 + case FLAC__STREAM_DECODER_SEARCH_FOR_FRAME_SYNC:
473 + case FLAC__STREAM_DECODER_READ_FRAME:
474 + case FLAC__STREAM_DECODER_END_OF_STREAM:
476 + case FLAC__STREAM_DECODER_OGG_ERROR:
477 + str = "error in the Ogg layer";
479 - case FLAC__SEEKABLE_STREAM_DECODER_OK:
480 - case FLAC__SEEKABLE_STREAM_DECODER_SEEKING:
481 - case FLAC__SEEKABLE_STREAM_DECODER_END_OF_STREAM:
482 + case FLAC__STREAM_DECODER_SEEK_ERROR:
483 + str = "seek error";
485 + case FLAC__STREAM_DECODER_ABORTED:
486 + str = "decoder aborted by read";
488 + case FLAC__STREAM_DECODER_MEMORY_ALLOCATION_ERROR:
489 + str = "allocation error";
491 + case FLAC__STREAM_DECODER_UNINITIALIZED:
492 + str = "decoder uninitialized";
494 + ERROR("flac %s\n", str);
496 +#endif /* FLAC_API_VERSION_CURRENT >= 7 */
498 -static void flacMetadata(const FLAC__SeekableStreamDecoder * dec,
499 +static void flacMetadata(const flac_decoder * dec,
500 const FLAC__StreamMetadata * block, void *vdata)
502 flac_metadata_common_cb(block, (FlacData *) vdata);
505 -static FLAC__StreamDecoderWriteStatus flacWrite(const
506 - FLAC__SeekableStreamDecoder *
507 - dec, const FLAC__Frame * frame,
508 +static FLAC__StreamDecoderWriteStatus flacWrite(const flac_decoder *dec,
509 + const FLAC__Frame * frame,
510 const FLAC__int32 * const buf[],
514 timeChange = ((float)samples) / frame->header.sample_rate;
515 data->time += timeChange;
517 - FLAC__seekable_stream_decoder_get_decode_position(dec, &newPosition);
518 + flac_get_decode_position(dec, &newPosition);
519 if (data->position) {
521 ((newPosition - data->position) * 8.0 / timeChange)
522 @@ -438,12 +340,174 @@
526 +static int flac_decode_internal(OutputBuffer * cb, DecoderControl * dc,
527 + InputStream * inStream, int is_ogg)
529 + flac_decoder *flacDec;
531 + const char *err = NULL;
533 + if (!(flacDec = flac_new()))
535 + init_FlacData(&data, cb, dc, inStream);
537 + if (!flac_ogg_init(flacDec, flacRead, flacSeek, flacTell,
538 + flacLength, flacEOF, flacWrite, flacMetadata,
539 + flacError, (void *)&data)) {
540 + err = "doing Ogg init()";
544 + if (!flac_init(flacDec, flacRead, flacSeek, flacTell,
545 + flacLength, flacEOF, flacWrite, flacMetadata,
546 + flacError, (void *)&data)) {
547 + err = "doing init()";
550 + if (!flac_process_metadata(flacDec)) {
551 + err = "problem reading metadata";
556 + dc->state = DECODE_STATE_DECODE;
559 + if (!flac_process_single(flacDec))
561 + if (flac_get_state(flacDec) == flac_decoder_eof)
564 + FLAC__uint64 sampleToSeek = dc->seekWhere *
565 + dc->audioFormat.sampleRate + 0.5;
566 + if (flac_seek_absolute(flacDec, sampleToSeek)) {
567 + clearOutputBuffer(cb);
568 + data.time = ((float)sampleToSeek) /
569 + dc->audioFormat.sampleRate;
577 + flacPrintErroredState(flac_get_state(flacDec));
578 + flac_finish(flacDec);
580 + /* send last little bit */
581 + if (data.chunk_length > 0 && !dc->stop) {
582 + flacSendChunk(&data);
583 + flushOutputBuffer(data.cb);
591 + dc->state = DECODE_STATE_STOP;
595 + if (data.replayGainInfo)
596 + freeReplayGainInfo(data.replayGainInfo);
599 + flac_delete(flacDec);
601 + closeInputStream(inStream);
604 + ERROR("flac %s\n", err);
610 +static int flac_decode(OutputBuffer * cb, DecoderControl * dc,
611 + InputStream * inStream)
613 + return flac_decode_internal(cb, dc, inStream, 0);
616 +#if !defined(FLAC_API_VERSION_CURRENT) || FLAC_API_VERSION_CURRENT <= 7
617 +# define flac_plugin_init NULL
618 +#else /* FLAC_API_VERSION_CURRENT >= 7 */
619 +/* some of this stuff is duplicated from oggflac_plugin.c */
620 +extern InputPlugin oggflacPlugin;
622 +static MpdTag *oggflac_tag_dup(char *file)
624 + MpdTag *ret = NULL;
625 + FLAC__Metadata_Iterator *it;
626 + FLAC__StreamMetadata *block;
627 + FLAC__Metadata_Chain *chain = FLAC__metadata_chain_new();
629 + if (!(FLAC__metadata_chain_read_ogg(chain, file)))
631 + it = FLAC__metadata_iterator_new();
632 + FLAC__metadata_iterator_init(it, chain);
634 + if (!(block = FLAC__metadata_iterator_get_block(it)))
636 + if (block->type == FLAC__METADATA_TYPE_VORBIS_COMMENT) {
637 + ret = copyVorbisCommentBlockToMpdTag(block, ret);
638 + } else if (block->type == FLAC__METADATA_TYPE_STREAMINFO) {
641 + ret->time = ((float)block->data.stream_info.
643 + block->data.stream_info.sample_rate + 0.5;
645 + } while (FLAC__metadata_iterator_next(it));
646 + FLAC__metadata_iterator_delete(it);
648 + FLAC__metadata_chain_delete(chain);
652 +static int oggflac_decode(OutputBuffer * cb, DecoderControl * dc,
653 + InputStream * inStream)
655 + return flac_decode_internal(cb, dc, inStream, 1);
658 +static unsigned int oggflac_try_decode(InputStream * inStream)
660 + return (ogg_stream_type_detect(inStream) == FLAC) ? 1 : 0;
663 +static char *oggflac_suffixes[] = { "ogg", NULL };
664 +static char *oggflac_mime_types[] = { "application/ogg", NULL };
666 +static int flac_plugin_init(void)
668 + if (!FLAC_API_SUPPORTS_OGG_FLAC) {
669 + DEBUG("libFLAC does not support OggFLAC\n");
672 + DEBUG("libFLAC supports OggFLAC, initializing OggFLAC support\n");
673 + assert(oggflacPlugin.name == NULL);
674 + oggflacPlugin.name = "oggflac";
675 + oggflacPlugin.tryDecodeFunc = oggflac_try_decode;
676 + oggflacPlugin.streamDecodeFunc = oggflac_decode;
677 + oggflacPlugin.tagDupFunc = oggflac_tag_dup;
678 + oggflacPlugin.streamTypes = INPUT_PLUGIN_STREAM_URL |
679 + INPUT_PLUGIN_STREAM_FILE;
680 + oggflacPlugin.suffixes = oggflac_suffixes;
681 + oggflacPlugin.mimeTypes = oggflac_mime_types;
682 + loadInputPlugin(&oggflacPlugin);
686 +#endif /* FLAC_API_VERSION_CURRENT >= 7 */
688 static char *flacSuffixes[] = { "flac", NULL };
689 static char *flac_mime_types[] = { "application/x-flac", NULL };
691 InputPlugin flacPlugin = {