1 /* libFLAC - Free Lossless Audio Codec library
2  * Copyright (C) 2000-2009  Josh Coalson
3  * Copyright (C) 2011-2013  Xiph.Org Foundation
4  *
5  * Redistribution and use in source and binary forms, with or without
6  * modification, are permitted provided that the following conditions
7  * are met:
8  *
9  * - Redistributions of source code must retain the above copyright
10  * notice, this list of conditions and the following disclaimer.
11  *
12  * - Redistributions in binary form must reproduce the above copyright
13  * notice, this list of conditions and the following disclaimer in the
14  * documentation and/or other materials provided with the distribution.
15  *
16  * - Neither the name of the Xiph.org Foundation nor the names of its
17  * contributors may be used to endorse or promote products derived from
18  * this software without specific prior written permission.
19  *
20  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
21  * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
22  * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
23  * A PARTICULAR PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE FOUNDATION OR
24  * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
25  * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
26  * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
27  * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
28  * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
29  * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
30  * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
31  */
32 
33 module deimos.flac.stream_decoder;
34 
35 import deimos.flac.export_;
36 import deimos.flac.format;
37 import deimos.flac.ordinals;
38 
39 import core.stdc.config;
40 import core.stdc.stdio;
41 
42 version(Posix) {}
43 else version(Windows) {}
44 else static assert(0, "Unsupported OS.");
45 
46 extern(C):
47 nothrow:
48 
49 
50 /** \file include/FLAC/stream_decoder.h
51  *
52  *  \brief
53  *  This module contains the functions which implement the stream
54  *  decoder.
55  *
56  *  See the detailed documentation in the
57  *  \link flac_stream_decoder stream decoder \endlink module.
58  */
59 
60 /** \defgroup flac_decoder FLAC/ \*_decoder.h: decoder interfaces
61  *  \ingroup flac
62  *
63  *  \brief
64  *  This module describes the decoder layers provided by libFLAC.
65  *
66  * The stream decoder can be used to decode complete streams either from
67  * the client via callbacks, or directly from a file, depending on how
68  * it is initialized.  When decoding via callbacks, the client provides
69  * callbacks for reading FLAC data and writing decoded samples, and
70  * handling metadata and errors.  If the client also supplies seek-related
71  * callback, the decoder function for sample-accurate seeking within the
72  * FLAC input is also available.  When decoding from a file, the client
73  * needs only supply a filename or open \c FILE* and write/metadata/error
74  * callbacks; the rest of the callbacks are supplied internally.  For more
75  * info see the \link flac_stream_decoder stream decoder \endlink module.
76  */
77 
78 /** \defgroup flac_stream_decoder FLAC/stream_decoder.h: stream decoder interface
79  *  \ingroup flac_decoder
80  *
81  *  \brief
82  *  This module contains the functions which implement the stream
83  *  decoder.
84  *
85  * The stream decoder can decode native FLAC, and optionally Ogg FLAC
86  * (check FLAC_API_SUPPORTS_OGG_FLAC) streams and files.
87  *
88  * The basic usage of this decoder is as follows:
89  * - The program creates an instance of a decoder using
90  *   FLAC__stream_decoder_new().
91  * - The program overrides the default settings using
92  *   FLAC__stream_decoder_set_*() functions.
93  * - The program initializes the instance to validate the settings and
94  *   prepare for decoding using
95  *   - FLAC__stream_decoder_init_stream() or FLAC__stream_decoder_init_FILE()
96  *     or FLAC__stream_decoder_init_file() for native FLAC,
97  *   - FLAC__stream_decoder_init_ogg_stream() or FLAC__stream_decoder_init_ogg_FILE()
98  *     or FLAC__stream_decoder_init_ogg_file() for Ogg FLAC
99  * - The program calls the FLAC__stream_decoder_process_*() functions
100  *   to decode data, which subsequently calls the callbacks.
101  * - The program finishes the decoding with FLAC__stream_decoder_finish(),
102  *   which flushes the input and output and resets the decoder to the
103  *   uninitialized state.
104  * - The instance may be used again or deleted with
105  *   FLAC__stream_decoder_delete().
106  *
107  * In more detail, the program will create a new instance by calling
108  * FLAC__stream_decoder_new(), then call FLAC__stream_decoder_set_*()
109  * functions to override the default decoder options, and call
110  * one of the FLAC__stream_decoder_init_*() functions.
111  *
112  * There are three initialization functions for native FLAC, one for
113  * setting up the decoder to decode FLAC data from the client via
114  * callbacks, and two for decoding directly from a FLAC file.
115  *
116  * For decoding via callbacks, use FLAC__stream_decoder_init_stream().
117  * You must also supply several callbacks for handling I/O.  Some (like
118  * seeking) are optional, depending on the capabilities of the input.
119  *
120  * For decoding directly from a file, use FLAC__stream_decoder_init_FILE()
121  * or FLAC__stream_decoder_init_file().  Then you must only supply an open
122  * \c FILE* or filename and fewer callbacks; the decoder will handle
123  * the other callbacks internally.
124  *
125  * There are three similarly-named init functions for decoding from Ogg
126  * FLAC streams.  Check \c FLAC_API_SUPPORTS_OGG_FLAC to find out if the
127  * library has been built with Ogg support.
128  *
129  * Once the decoder is initialized, your program will call one of several
130  * functions to start the decoding process:
131  *
132  * - FLAC__stream_decoder_process_single() - Tells the decoder to process at
133  *   most one metadata block or audio frame and return, calling either the
134  *   metadata callback or write callback, respectively, once.  If the decoder
135  *   loses sync it will return with only the error callback being called.
136  * - FLAC__stream_decoder_process_until_end_of_metadata() - Tells the decoder
137  *   to process the stream from the current location and stop upon reaching
138  *   the first audio frame.  The client will get one metadata, write, or error
139  *   callback per metadata block, audio frame, or sync error, respectively.
140  * - FLAC__stream_decoder_process_until_end_of_stream() - Tells the decoder
141  *   to process the stream from the current location until the read callback
142  *   returns FLAC__STREAM_DECODER_READ_STATUS_END_OF_STREAM or
143  *   FLAC__STREAM_DECODER_READ_STATUS_ABORT.  The client will get one metadata,
144  *   write, or error callback per metadata block, audio frame, or sync error,
145  *   respectively.
146  *
147  * When the decoder has finished decoding (normally or through an abort),
148  * the instance is finished by calling FLAC__stream_decoder_finish(), which
149  * ensures the decoder is in the correct state and frees memory.  Then the
150  * instance may be deleted with FLAC__stream_decoder_delete() or initialized
151  * again to decode another stream.
152  *
153  * Seeking is exposed through the FLAC__stream_decoder_seek_absolute() method.
154  * At any point after the stream decoder has been initialized, the client can
155  * call this function to seek to an exact sample within the stream.
156  * Subsequently, the first time the write callback is called it will be
157  * passed a (possibly partial) block starting at that sample.
158  *
159  * If the client cannot seek via the callback interface provided, but still
160  * has another way of seeking, it can flush the decoder using
161  * FLAC__stream_decoder_flush() and start feeding data from the new position
162  * through the read callback.
163  *
164  * The stream decoder also provides MD5 signature checking.  If this is
165  * turned on before initialization, FLAC__stream_decoder_finish() will
166  * report when the decoded MD5 signature does not match the one stored
167  * in the STREAMINFO block.  MD5 checking is automatically turned off
168  * (until the next FLAC__stream_decoder_reset()) if there is no signature
169  * in the STREAMINFO block or when a seek is attempted.
170  *
171  * The FLAC__stream_decoder_set_metadata_*() functions deserve special
172  * attention.  By default, the decoder only calls the metadata_callback for
173  * the STREAMINFO block.  These functions allow you to tell the decoder
174  * explicitly which blocks to parse and return via the metadata_callback
175  * and/or which to skip.  Use a FLAC__stream_decoder_set_metadata_respond_all(),
176  * FLAC__stream_decoder_set_metadata_ignore() ... or FLAC__stream_decoder_set_metadata_ignore_all(),
177  * FLAC__stream_decoder_set_metadata_respond() ... sequence to exactly specify
178  * which blocks to return.  Remember that metadata blocks can potentially
179  * be big (for example, cover art) so filtering out the ones you don't
180  * use can reduce the memory requirements of the decoder.  Also note the
181  * special forms FLAC__stream_decoder_set_metadata_respond_application(id)
182  * and FLAC__stream_decoder_set_metadata_ignore_application(id) for
183  * filtering APPLICATION blocks based on the application ID.
184  *
185  * STREAMINFO and SEEKTABLE blocks are always parsed and used internally, but
186  * they still can legally be filtered from the metadata_callback.
187  *
188  * \note
189  * The "set" functions may only be called when the decoder is in the
190  * state FLAC__STREAM_DECODER_UNINITIALIZED, i.e. after
191  * FLAC__stream_decoder_new() or FLAC__stream_decoder_finish(), but
192  * before FLAC__stream_decoder_init_*().  If this is the case they will
193  * return \c true, otherwise \c false.
194  *
195  * \note
196  * FLAC__stream_decoder_finish() resets all settings to the constructor
197  * defaults, including the callbacks.
198  *
199  * \{
200  */
201 
202 
203 /** State values for a FLAC__StreamDecoder
204  *
205  * The decoder's state can be obtained by calling FLAC__stream_decoder_get_state().
206  */
207 enum FLAC__StreamDecoderState
208 {
209     FLAC__STREAM_DECODER_SEARCH_FOR_METADATA = 0,
210     /**< The decoder is ready to search for metadata. */
211 
212     FLAC__STREAM_DECODER_READ_METADATA,
213     /**< The decoder is ready to or is in the process of reading metadata. */
214 
215     FLAC__STREAM_DECODER_SEARCH_FOR_FRAME_SYNC,
216     /**< The decoder is ready to or is in the process of searching for the
217      * frame sync code.
218      */
219 
220     FLAC__STREAM_DECODER_READ_FRAME,
221     /**< The decoder is ready to or is in the process of reading a frame. */
222 
223     FLAC__STREAM_DECODER_END_OF_STREAM,
224     /**< The decoder has reached the end of the stream. */
225 
226     FLAC__STREAM_DECODER_OGG_ERROR,
227     /**< An error occurred in the underlying Ogg layer.  */
228 
229     FLAC__STREAM_DECODER_SEEK_ERROR,
230     /**< An error occurred while seeking.  The decoder must be flushed
231      * with FLAC__stream_decoder_flush() or reset with
232      * FLAC__stream_decoder_reset() before decoding can continue.
233      */
234 
235     FLAC__STREAM_DECODER_ABORTED,
236     /**< The decoder was aborted by the read callback. */
237 
238     FLAC__STREAM_DECODER_MEMORY_ALLOCATION_ERROR,
239     /**< An error occurred allocating memory.  The decoder is in an invalid
240      * state and can no longer be used.
241      */
242 
243     FLAC__STREAM_DECODER_UNINITIALIZED
244     /**< The decoder is in the uninitialized state; one of the
245      * FLAC__stream_decoder_init_*() functions must be called before samples
246      * can be processed.
247      */
248 }
249 
250 /** Maps a FLAC__StreamDecoderState to a C string.
251  *
252  *  Using a FLAC__StreamDecoderState as the index to this array
253  *  will give the string equivalent.  The contents should not be modified.
254  */
255 export extern __gshared const char** FLAC__StreamDecoderStateString;
256 
257 
258 /** Possible return values for the FLAC__stream_decoder_init_*() functions.
259  */
260 enum FLAC__StreamDecoderInitStatus
261 {
262     FLAC__STREAM_DECODER_INIT_STATUS_OK = 0,
263     /**< Initialization was successful. */
264 
265     FLAC__STREAM_DECODER_INIT_STATUS_UNSUPPORTED_CONTAINER,
266     /**< The library was not compiled with support for the given container
267      * format.
268      */
269 
270     FLAC__STREAM_DECODER_INIT_STATUS_INVALID_CALLBACKS,
271     /**< A required callback was not supplied. */
272 
273     FLAC__STREAM_DECODER_INIT_STATUS_MEMORY_ALLOCATION_ERROR,
274     /**< An error occurred allocating memory. */
275 
276     FLAC__STREAM_DECODER_INIT_STATUS_ERROR_OPENING_FILE,
277     /**< fopen() failed in FLAC__stream_decoder_init_file() or
278      * FLAC__stream_decoder_init_ogg_file(). */
279 
280     FLAC__STREAM_DECODER_INIT_STATUS_ALREADY_INITIALIZED
281     /**< FLAC__stream_decoder_init_*() was called when the decoder was
282      * already initialized, usually because
283      * FLAC__stream_decoder_finish() was not called.
284      */
285 }
286 
287 /** Maps a FLAC__StreamDecoderInitStatus to a C string.
288  *
289  *  Using a FLAC__StreamDecoderInitStatus as the index to this array
290  *  will give the string equivalent.  The contents should not be modified.
291  */
292 export extern __gshared const char** FLAC__StreamDecoderInitStatusString;
293 
294 
295 /** Return values for the FLAC__StreamDecoder read callback.
296  */
297 enum FLAC__StreamDecoderReadStatus
298 {
299     FLAC__STREAM_DECODER_READ_STATUS_CONTINUE,
300     /**< The read was OK and decoding can continue. */
301 
302     FLAC__STREAM_DECODER_READ_STATUS_END_OF_STREAM,
303     /**< The read was attempted while at the end of the stream.  Note that
304      * the client must only return this value when the read callback was
305      * called when already at the end of the stream.  Otherwise, if the read
306      * itself moves to the end of the stream, the client should still return
307      * the data and \c FLAC__STREAM_DECODER_READ_STATUS_CONTINUE, and then on
308      * the next read callback it should return
309      * \c FLAC__STREAM_DECODER_READ_STATUS_END_OF_STREAM with a byte count
310      * of \c 0.
311      */
312 
313     FLAC__STREAM_DECODER_READ_STATUS_ABORT
314     /**< An unrecoverable error occurred.  The decoder will return from the process call. */
315 }
316 
317 /** Maps a FLAC__StreamDecoderReadStatus to a C string.
318  *
319  *  Using a FLAC__StreamDecoderReadStatus as the index to this array
320  *  will give the string equivalent.  The contents should not be modified.
321  */
322 export extern __gshared const char** FLAC__StreamDecoderReadStatusString;
323 
324 
325 /** Return values for the FLAC__StreamDecoder seek callback.
326  */
327 enum FLAC__StreamDecoderSeekStatus
328 {
329     FLAC__STREAM_DECODER_SEEK_STATUS_OK,
330     /**< The seek was OK and decoding can continue. */
331 
332     FLAC__STREAM_DECODER_SEEK_STATUS_ERROR,
333     /**< An unrecoverable error occurred.  The decoder will return from the process call. */
334 
335     FLAC__STREAM_DECODER_SEEK_STATUS_UNSUPPORTED
336     /**< Client does not support seeking. */
337 }
338 
339 /** Maps a FLAC__StreamDecoderSeekStatus to a C string.
340  *
341  *  Using a FLAC__StreamDecoderSeekStatus as the index to this array
342  *  will give the string equivalent.  The contents should not be modified.
343  */
344 export extern __gshared const char** FLAC__StreamDecoderSeekStatusString;
345 
346 
347 /** Return values for the FLAC__StreamDecoder tell callback.
348  */
349 enum FLAC__StreamDecoderTellStatus
350 {
351     FLAC__STREAM_DECODER_TELL_STATUS_OK,
352     /**< The tell was OK and decoding can continue. */
353 
354     FLAC__STREAM_DECODER_TELL_STATUS_ERROR,
355     /**< An unrecoverable error occurred.  The decoder will return from the process call. */
356 
357     FLAC__STREAM_DECODER_TELL_STATUS_UNSUPPORTED
358     /**< Client does not support telling the position. */
359 
360 }
361 
362 /** Maps a FLAC__StreamDecoderTellStatus to a C string.
363  *
364  *  Using a FLAC__StreamDecoderTellStatus as the index to this array
365  *  will give the string equivalent.  The contents should not be modified.
366  */
367 export extern __gshared const char** FLAC__StreamDecoderTellStatusString;
368 
369 
370 /** Return values for the FLAC__StreamDecoder length callback.
371  */
372 enum FLAC__StreamDecoderLengthStatus
373 {
374     FLAC__STREAM_DECODER_LENGTH_STATUS_OK,
375     /**< The length call was OK and decoding can continue. */
376 
377     FLAC__STREAM_DECODER_LENGTH_STATUS_ERROR,
378     /**< An unrecoverable error occurred.  The decoder will return from the process call. */
379 
380     FLAC__STREAM_DECODER_LENGTH_STATUS_UNSUPPORTED
381     /**< Client does not support reporting the length. */
382 }
383 
384 /** Maps a FLAC__StreamDecoderLengthStatus to a C string.
385  *
386  *  Using a FLAC__StreamDecoderLengthStatus as the index to this array
387  *  will give the string equivalent.  The contents should not be modified.
388  */
389 export extern __gshared const char** FLAC__StreamDecoderLengthStatusString;
390 
391 
392 /** Return values for the FLAC__StreamDecoder write callback.
393  */
394 enum FLAC__StreamDecoderWriteStatus
395 {
396     FLAC__STREAM_DECODER_WRITE_STATUS_CONTINUE,
397     /**< The write was OK and decoding can continue. */
398 
399     FLAC__STREAM_DECODER_WRITE_STATUS_ABORT
400     /**< An unrecoverable error occurred.  The decoder will return from the process call. */
401 }
402 
403 /** Maps a FLAC__StreamDecoderWriteStatus to a C string.
404  *
405  *  Using a FLAC__StreamDecoderWriteStatus as the index to this array
406  *  will give the string equivalent.  The contents should not be modified.
407  */
408 export extern __gshared const char** FLAC__StreamDecoderWriteStatusString;
409 
410 
411 /** Possible values passed back to the FLAC__StreamDecoder error callback.
412  *  \c FLAC__STREAM_DECODER_ERROR_STATUS_LOST_SYNC is the generic catch-
413  *  all.  The rest could be caused by bad sync (false synchronization on
414  *  data that is not the start of a frame) or corrupted data.  The error
415  *  itself is the decoder's best guess at what happened assuming a correct
416  *  sync.  For example \c FLAC__STREAM_DECODER_ERROR_STATUS_BAD_HEADER
417  *  could be caused by a correct sync on the start of a frame, but some
418  *  data in the frame header was corrupted.  Or it could be the result of
419  *  syncing on a point the stream that looked like the starting of a frame
420  *  but was not.  \c FLAC__STREAM_DECODER_ERROR_STATUS_UNPARSEABLE_STREAM
421  *  could be because the decoder encountered a valid frame made by a future
422  *  version of the encoder which it cannot parse, or because of a false
423  *  sync making it appear as though an encountered frame was generated by
424  *  a future encoder.
425  */
426 enum FLAC__StreamDecoderErrorStatus
427 {
428     FLAC__STREAM_DECODER_ERROR_STATUS_LOST_SYNC,
429     /**< An error in the stream caused the decoder to lose synchronization. */
430 
431     FLAC__STREAM_DECODER_ERROR_STATUS_BAD_HEADER,
432     /**< The decoder encountered a corrupted frame header. */
433 
434     FLAC__STREAM_DECODER_ERROR_STATUS_FRAME_CRC_MISMATCH,
435     /**< The frame's data did not match the CRC in the footer. */
436 
437     FLAC__STREAM_DECODER_ERROR_STATUS_UNPARSEABLE_STREAM
438     /**< The decoder encountered reserved fields in use in the stream. */
439 }
440 
441 /** Maps a FLAC__StreamDecoderErrorStatus to a C string.
442  *
443  *  Using a FLAC__StreamDecoderErrorStatus as the index to this array
444  *  will give the string equivalent.  The contents should not be modified.
445  */
446 export extern __gshared const char** FLAC__StreamDecoderErrorStatusString;
447 
448 
449 /***********************************************************************
450  *
451  * class FLAC__StreamDecoder
452  *
453  ***********************************************************************/
454 
455 extern struct FLAC__StreamDecoderProtected;
456 extern struct FLAC__StreamDecoderPrivate;
457 /** The opaque structure definition for the stream decoder type.
458  *  See the \link flac_stream_decoder stream decoder module \endlink
459  *  for a detailed description.
460  */
461 struct FLAC__StreamDecoder
462 {
463     FLAC__StreamDecoderProtected* protected_; /* avoid the C++ keyword 'protected' */
464     FLAC__StreamDecoderPrivate* private_; /* avoid the C++ keyword 'private' */
465 }
466 
467 /** Signature for the read callback.
468  *
469  *  A function pointer matching this signature must be passed to
470  *  FLAC__stream_decoder_init*_stream(). The supplied function will be
471  *  called when the decoder needs more input data.  The address of the
472  *  buffer to be filled is supplied, along with the number of bytes the
473  *  buffer can hold.  The callback may choose to supply less data and
474  *  modify the byte count but must be careful not to overflow the buffer.
475  *  The callback then returns a status code chosen from
476  *  FLAC__StreamDecoderReadStatus.
477  *
478  * Here is an example of a read callback for stdio streams:
479  * \code
480  * FLAC__StreamDecoderReadStatus read_cb(const FLAC__StreamDecoder *decoder, FLAC__byte buffer[], size_t *bytes, void *client_data)
481  * {
482  *   FILE *file = ((MyClientData*)client_data)->file;
483  *   if(*bytes > 0) {
484  *     *bytes = fread(buffer, sizeof(FLAC__byte), *bytes, file);
485  *     if(ferror(file))
486  *       return FLAC__STREAM_DECODER_READ_STATUS_ABORT;
487  *     else if(*bytes == 0)
488  *       return FLAC__STREAM_DECODER_READ_STATUS_END_OF_STREAM;
489  *     else
490  *       return FLAC__STREAM_DECODER_READ_STATUS_CONTINUE;
491  *   }
492  *   else
493  *     return FLAC__STREAM_DECODER_READ_STATUS_ABORT;
494  * }
495  * \endcode
496  *
497  * \note In general, FLAC__StreamDecoder functions which change the
498  * state should not be called on the \a decoder while in the callback.
499  *
500  * \param  decoder  The decoder instance calling the callback.
501  * \param  buffer   A pointer to a location for the callee to store
502  *                  data to be decoded.
503  * \param  bytes    A pointer to the size of the buffer.  On entry
504  *                  to the callback, it contains the maximum number
505  *                  of bytes that may be stored in \a buffer.  The
506  *                  callee must set it to the actual number of bytes
507  *                  stored (0 in case of error or end-of-stream) before
508  *                  returning.
509  * \param  client_data  The callee's client data set through
510  *                      FLAC__stream_decoder_init_*().
511  * \retval FLAC__StreamDecoderReadStatus
512  *    The callee's return status.  Note that the callback should return
513  *    \c FLAC__STREAM_DECODER_READ_STATUS_END_OF_STREAM if and only if
514  *    zero bytes were read and there is no more data to be read.
515  */
516 alias FLAC__StreamDecoderReadStatus function(const FLAC__StreamDecoder* decoder, FLAC__byte* buffer, size_t* bytes, void* client_data) FLAC__StreamDecoderReadCallback;
517 
518 /** Signature for the seek callback.
519  *
520  *  A function pointer matching this signature may be passed to
521  *  FLAC__stream_decoder_init*_stream().  The supplied function will be
522  *  called when the decoder needs to seek the input stream.  The decoder
523  *  will pass the absolute byte offset to seek to, 0 meaning the
524  *  beginning of the stream.
525  *
526  * Here is an example of a seek callback for stdio streams:
527  * \code
528  * FLAC__StreamDecoderSeekStatus seek_cb(const FLAC__StreamDecoder *decoder, FLAC__uint64 absolute_byte_offset, void *client_data)
529  * {
530  *   FILE *file = ((MyClientData*)client_data)->file;
531  *   if(file == stdin)
532  *     return FLAC__STREAM_DECODER_SEEK_STATUS_UNSUPPORTED;
533  *   else if(fseeko(file, (off_t)absolute_byte_offset, SEEK_SET) < 0)
534  *     return FLAC__STREAM_DECODER_SEEK_STATUS_ERROR;
535  *   else
536  *     return FLAC__STREAM_DECODER_SEEK_STATUS_OK;
537  * }
538  * \endcode
539  *
540  * \note In general, FLAC__StreamDecoder functions which change the
541  * state should not be called on the \a decoder while in the callback.
542  *
543  * \param  decoder  The decoder instance calling the callback.
544  * \param  absolute_byte_offset  The offset from the beginning of the stream
545  *                               to seek to.
546  * \param  client_data  The callee's client data set through
547  *                      FLAC__stream_decoder_init_*().
548  * \retval FLAC__StreamDecoderSeekStatus
549  *    The callee's return status.
550  */
551 alias FLAC__StreamDecoderSeekStatus function(const FLAC__StreamDecoder* decoder, FLAC__uint64 absolute_byte_offset, void* client_data) FLAC__StreamDecoderSeekCallback;
552 
553 /** Signature for the tell callback.
554  *
555  *  A function pointer matching this signature may be passed to
556  *  FLAC__stream_decoder_init*_stream().  The supplied function will be
557  *  called when the decoder wants to know the current position of the
558  *  stream.  The callback should return the byte offset from the
559  *  beginning of the stream.
560  *
561  * Here is an example of a tell callback for stdio streams:
562  * \code
563  * FLAC__StreamDecoderTellStatus tell_cb(const FLAC__StreamDecoder *decoder, FLAC__uint64 *absolute_byte_offset, void *client_data)
564  * {
565  *   FILE *file = ((MyClientData*)client_data)->file;
566  *   off_t pos;
567  *   if(file == stdin)
568  *     return FLAC__STREAM_DECODER_TELL_STATUS_UNSUPPORTED;
569  *   else if((pos = ftello(file)) < 0)
570  *     return FLAC__STREAM_DECODER_TELL_STATUS_ERROR;
571  *   else {
572  *     *absolute_byte_offset = (FLAC__uint64)pos;
573  *     return FLAC__STREAM_DECODER_TELL_STATUS_OK;
574  *   }
575  * }
576  * \endcode
577  *
578  * \note In general, FLAC__StreamDecoder functions which change the
579  * state should not be called on the \a decoder while in the callback.
580  *
581  * \param  decoder  The decoder instance calling the callback.
582  * \param  absolute_byte_offset  A pointer to storage for the current offset
583  *                               from the beginning of the stream.
584  * \param  client_data  The callee's client data set through
585  *                      FLAC__stream_decoder_init_*().
586  * \retval FLAC__StreamDecoderTellStatus
587  *    The callee's return status.
588  */
589 alias FLAC__StreamDecoderTellStatus function(const FLAC__StreamDecoder* decoder, FLAC__uint64* absolute_byte_offset, void* client_data) FLAC__StreamDecoderTellCallback;
590 
591 /** Signature for the length callback.
592  *
593  *  A function pointer matching this signature may be passed to
594  *  FLAC__stream_decoder_init*_stream().  The supplied function will be
595  *  called when the decoder wants to know the total length of the stream
596  *  in bytes.
597  *
598  * Here is an example of a length callback for stdio streams:
599  * \code
600  * FLAC__StreamDecoderLengthStatus length_cb(const FLAC__StreamDecoder *decoder, FLAC__uint64 *stream_length, void *client_data)
601  * {
602  *   FILE *file = ((MyClientData*)client_data)->file;
603  *   struct stat filestats;
604  *
605  *   if(file == stdin)
606  *     return FLAC__STREAM_DECODER_LENGTH_STATUS_UNSUPPORTED;
607  *   else if(fstat(fileno(file), &filestats) != 0)
608  *     return FLAC__STREAM_DECODER_LENGTH_STATUS_ERROR;
609  *   else {
610  *     *stream_length = (FLAC__uint64)filestats.st_size;
611  *     return FLAC__STREAM_DECODER_LENGTH_STATUS_OK;
612  *   }
613  * }
614  * \endcode
615  *
616  * \note In general, FLAC__StreamDecoder functions which change the
617  * state should not be called on the \a decoder while in the callback.
618  *
619  * \param  decoder  The decoder instance calling the callback.
620  * \param  stream_length  A pointer to storage for the length of the stream
621  *                        in bytes.
622  * \param  client_data  The callee's client data set through
623  *                      FLAC__stream_decoder_init_*().
624  * \retval FLAC__StreamDecoderLengthStatus
625  *    The callee's return status.
626  */
627 alias FLAC__StreamDecoderLengthStatus function(const FLAC__StreamDecoder* decoder, FLAC__uint64* stream_length, void* client_data) FLAC__StreamDecoderLengthCallback;
628 
629 /** Signature for the EOF callback.
630  *
631  *  A function pointer matching this signature may be passed to
632  *  FLAC__stream_decoder_init*_stream().  The supplied function will be
633  *  called when the decoder needs to know if the end of the stream has
634  *  been reached.
635  *
636  * Here is an example of a EOF callback for stdio streams:
637  * FLAC__bool eof_cb(const FLAC__StreamDecoder *decoder, void *client_data)
638  * \code
639  * {
640  *   FILE *file = ((MyClientData*)client_data)->file;
641  *   return feof(file)? true : false;
642  * }
643  * \endcode
644  *
645  * \note In general, FLAC__StreamDecoder functions which change the
646  * state should not be called on the \a decoder while in the callback.
647  *
648  * \param  decoder  The decoder instance calling the callback.
649  * \param  client_data  The callee's client data set through
650  *                      FLAC__stream_decoder_init_*().
651  * \retval FLAC__bool
652  *    \c true if the currently at the end of the stream, else \c false.
653  */
654 alias FLAC__bool function(const FLAC__StreamDecoder* decoder, void* client_data) FLAC__StreamDecoderEofCallback;
655 
656 /** Signature for the write callback.
657  *
658  *  A function pointer matching this signature must be passed to one of
659  *  the FLAC__stream_decoder_init_*() functions.
660  *  The supplied function will be called when the decoder has decoded a
661  *  single audio frame.  The decoder will pass the frame metadata as well
662  *  as an array of pointers (one for each channel) pointing to the
663  *  decoded audio.
664  *
665  * \note In general, FLAC__StreamDecoder functions which change the
666  * state should not be called on the \a decoder while in the callback.
667  *
668  * \param  decoder  The decoder instance calling the callback.
669  * \param  frame    The description of the decoded frame.  See
670  *                  FLAC__Frame.
671  * \param  buffer   An array of pointers to decoded channels of data.
672  *                  Each pointer will point to an array of signed
673  *                  samples of length \a frame->header.blocksize.
674  *                  Channels will be ordered according to the FLAC
675  *                  specification; see the documentation for the
676  *                  <A HREF="../format.html#frame_header">frame header</A>.
677  * \param  client_data  The callee's client data set through
678  *                      FLAC__stream_decoder_init_*().
679  * \retval FLAC__StreamDecoderWriteStatus
680  *    The callee's return status.
681  */
682 alias FLAC__StreamDecoderWriteStatus function(const FLAC__StreamDecoder* decoder, const FLAC__Frame* frame, const FLAC__int32** buffer, void* client_data) FLAC__StreamDecoderWriteCallback;
683 
684 /** Signature for the metadata callback.
685  *
686  *  A function pointer matching this signature must be passed to one of
687  *  the FLAC__stream_decoder_init_*() functions.
688  *  The supplied function will be called when the decoder has decoded a
689  *  metadata block.  In a valid FLAC file there will always be one
690  *  \c STREAMINFO block, followed by zero or more other metadata blocks.
691  *  These will be supplied by the decoder in the same order as they
692  *  appear in the stream and always before the first audio frame (i.e.
693  *  write callback).  The metadata block that is passed in must not be
694  *  modified, and it doesn't live beyond the callback, so you should make
695  *  a copy of it with FLAC__metadata_object_clone() if you will need it
696  *  elsewhere.  Since metadata blocks can potentially be large, by
697  *  default the decoder only calls the metadata callback for the
698  *  \c STREAMINFO block; you can instruct the decoder to pass or filter
699  *  other blocks with FLAC__stream_decoder_set_metadata_*() calls.
700  *
701  * \note In general, FLAC__StreamDecoder functions which change the
702  * state should not be called on the \a decoder while in the callback.
703  *
704  * \param  decoder  The decoder instance calling the callback.
705  * \param  metadata The decoded metadata block.
706  * \param  client_data  The callee's client data set through
707  *                      FLAC__stream_decoder_init_*().
708  */
709 alias void function(const FLAC__StreamDecoder* decoder, const FLAC__StreamMetadata* metadata, void* client_data) FLAC__StreamDecoderMetadataCallback;
710 
711 /** Signature for the error callback.
712  *
713  *  A function pointer matching this signature must be passed to one of
714  *  the FLAC__stream_decoder_init_*() functions.
715  *  The supplied function will be called whenever an error occurs during
716  *  decoding.
717  *
718  * \note In general, FLAC__StreamDecoder functions which change the
719  * state should not be called on the \a decoder while in the callback.
720  *
721  * \param  decoder  The decoder instance calling the callback.
722  * \param  status   The error encountered by the decoder.
723  * \param  client_data  The callee's client data set through
724  *                      FLAC__stream_decoder_init_*().
725  */
726 alias void function(const FLAC__StreamDecoder* decoder, FLAC__StreamDecoderErrorStatus status, void* client_data) FLAC__StreamDecoderErrorCallback;
727 
728 
729 /***********************************************************************
730  *
731  * Class constructor/destructor
732  *
733  ***********************************************************************/
734 
735 /** Create a new stream decoder instance.  The instance is created with
736  *  default settings; see the individual FLAC__stream_decoder_set_*()
737  *  functions for each setting's default.
738  *
739  * \retval FLAC__StreamDecoder*
740  *    \c NULL if there was an error allocating memory, else the new instance.
741  */
742 FLAC__StreamDecoder* FLAC__stream_decoder_new();
743 
744 /** Free a decoder instance.  Deletes the object pointed to by \a decoder.
745  *
746  * \param decoder  A pointer to an existing decoder.
747  * \assert
748  *    \code decoder != NULL \endcode
749  */
750 void FLAC__stream_decoder_delete(FLAC__StreamDecoder* decoder);
751 
752 
753 /***********************************************************************
754  *
755  * Public class method prototypes
756  *
757  ***********************************************************************/
758 
759 /** Set the serial number for the FLAC stream within the Ogg container.
760  *  The default behavior is to use the serial number of the first Ogg
761  *  page.  Setting a serial number here will explicitly specify which
762  *  stream is to be decoded.
763  *
764  * \note
765  * This does not need to be set for native FLAC decoding.
766  *
767  * \default \c use serial number of first page
768  * \param  decoder        A decoder instance to set.
769  * \param  serial_number  See above.
770  * \assert
771  *    \code decoder != NULL \endcode
772  * \retval FLAC__bool
773  *    \c false if the decoder is already initialized, else \c true.
774  */
775 FLAC__bool FLAC__stream_decoder_set_ogg_serial_number(FLAC__StreamDecoder* decoder, c_long serial_number);
776 
777 /** Set the "MD5 signature checking" flag.  If \c true, the decoder will
778  *  compute the MD5 signature of the unencoded audio data while decoding
779  *  and compare it to the signature from the STREAMINFO block, if it
780  *  exists, during FLAC__stream_decoder_finish().
781  *
782  *  MD5 signature checking will be turned off (until the next
783  *  FLAC__stream_decoder_reset()) if there is no signature in the
784  *  STREAMINFO block or when a seek is attempted.
785  *
786  *  Clients that do not use the MD5 check should leave this off to speed
787  *  up decoding.
788  *
789  * \default \c false
790  * \param  decoder  A decoder instance to set.
791  * \param  value    Flag value (see above).
792  * \assert
793  *    \code decoder != NULL \endcode
794  * \retval FLAC__bool
795  *    \c false if the decoder is already initialized, else \c true.
796  */
797 FLAC__bool FLAC__stream_decoder_set_md5_checking(FLAC__StreamDecoder* decoder, FLAC__bool value);
798 
799 /** Direct the decoder to pass on all metadata blocks of type \a type.
800  *
801  * \default By default, only the \c STREAMINFO block is returned via the
802  *          metadata callback.
803  * \param  decoder  A decoder instance to set.
804  * \param  type     See above.
805  * \assert
806  *    \code decoder != NULL \endcode
807  *    \a type is valid
808  * \retval FLAC__bool
809  *    \c false if the decoder is already initialized, else \c true.
810  */
811 FLAC__bool FLAC__stream_decoder_set_metadata_respond(FLAC__StreamDecoder* decoder, FLAC__MetadataType type);
812 
813 /** Direct the decoder to pass on all APPLICATION metadata blocks of the
814  *  given \a id.
815  *
816  * \default By default, only the \c STREAMINFO block is returned via the
817  *          metadata callback.
818  * \param  decoder  A decoder instance to set.
819  * \param  id       See above.
820  * \assert
821  *    \code decoder != NULL \endcode
822  *    \code id != NULL \endcode
823  * \retval FLAC__bool
824  *    \c false if the decoder is already initialized, else \c true.
825  */
826 FLAC__bool FLAC__stream_decoder_set_metadata_respond_application(FLAC__StreamDecoder* decoder, const ref FLAC__byte id[4]);
827 
828 /** Direct the decoder to pass on all metadata blocks of any type.
829  *
830  * \default By default, only the \c STREAMINFO block is returned via the
831  *          metadata callback.
832  * \param  decoder  A decoder instance to set.
833  * \assert
834  *    \code decoder != NULL \endcode
835  * \retval FLAC__bool
836  *    \c false if the decoder is already initialized, else \c true.
837  */
838 FLAC__bool FLAC__stream_decoder_set_metadata_respond_all(FLAC__StreamDecoder* decoder);
839 
840 /** Direct the decoder to filter out all metadata blocks of type \a type.
841  *
842  * \default By default, only the \c STREAMINFO block is returned via the
843  *          metadata callback.
844  * \param  decoder  A decoder instance to set.
845  * \param  type     See above.
846  * \assert
847  *    \code decoder != NULL \endcode
848  *    \a type is valid
849  * \retval FLAC__bool
850  *    \c false if the decoder is already initialized, else \c true.
851  */
852 FLAC__bool FLAC__stream_decoder_set_metadata_ignore(FLAC__StreamDecoder* decoder, FLAC__MetadataType type);
853 
854 /** Direct the decoder to filter out all APPLICATION metadata blocks of
855  *  the given \a id.
856  *
857  * \default By default, only the \c STREAMINFO block is returned via the
858  *          metadata callback.
859  * \param  decoder  A decoder instance to set.
860  * \param  id       See above.
861  * \assert
862  *    \code decoder != NULL \endcode
863  *    \code id != NULL \endcode
864  * \retval FLAC__bool
865  *    \c false if the decoder is already initialized, else \c true.
866  */
867 FLAC__bool FLAC__stream_decoder_set_metadata_ignore_application(FLAC__StreamDecoder* decoder, const ref FLAC__byte id[4]);
868 
869 /** Direct the decoder to filter out all metadata blocks of any type.
870  *
871  * \default By default, only the \c STREAMINFO block is returned via the
872  *          metadata callback.
873  * \param  decoder  A decoder instance to set.
874  * \assert
875  *    \code decoder != NULL \endcode
876  * \retval FLAC__bool
877  *    \c false if the decoder is already initialized, else \c true.
878  */
879 FLAC__bool FLAC__stream_decoder_set_metadata_ignore_all(FLAC__StreamDecoder* decoder);
880 
881 /** Get the current decoder state.
882  *
883  * \param  decoder  A decoder instance to query.
884  * \assert
885  *    \code decoder != NULL \endcode
886  * \retval FLAC__StreamDecoderState
887  *    The current decoder state.
888  */
889 FLAC__StreamDecoderState FLAC__stream_decoder_get_state(const FLAC__StreamDecoder* decoder);
890 
891 /** Get the current decoder state as a C string.
892  *
893  * \param  decoder  A decoder instance to query.
894  * \assert
895  *    \code decoder != NULL \endcode
896  * \retval const char *
897  *    The decoder state as a C string.  Do not modify the contents.
898  */
899 const(char)* FLAC__stream_decoder_get_resolved_state_string(const FLAC__StreamDecoder* decoder);
900 
901 /** Get the "MD5 signature checking" flag.
902  *  This is the value of the setting, not whether or not the decoder is
903  *  currently checking the MD5 (remember, it can be turned off automatically
904  *  by a seek).  When the decoder is reset the flag will be restored to the
905  *  value returned by this function.
906  *
907  * \param  decoder  A decoder instance to query.
908  * \assert
909  *    \code decoder != NULL \endcode
910  * \retval FLAC__bool
911  *    See above.
912  */
913 FLAC__bool FLAC__stream_decoder_get_md5_checking(const FLAC__StreamDecoder* decoder);
914 
915 /** Get the total number of samples in the stream being decoded.
916  *  Will only be valid after decoding has started and will contain the
917  *  value from the \c STREAMINFO block.  A value of \c 0 means "unknown".
918  *
919  * \param  decoder  A decoder instance to query.
920  * \assert
921  *    \code decoder != NULL \endcode
922  * \retval uint
923  *    See above.
924  */
925 FLAC__uint64 FLAC__stream_decoder_get_total_samples(const FLAC__StreamDecoder* decoder);
926 
927 /** Get the current number of channels in the stream being decoded.
928  *  Will only be valid after decoding has started and will contain the
929  *  value from the most recently decoded frame header.
930  *
931  * \param  decoder  A decoder instance to query.
932  * \assert
933  *    \code decoder != NULL \endcode
934  * \retval uint
935  *    See above.
936  */
937 uint FLAC__stream_decoder_get_channels(const FLAC__StreamDecoder* decoder);
938 
939 /** Get the current channel assignment in the stream being decoded.
940  *  Will only be valid after decoding has started and will contain the
941  *  value from the most recently decoded frame header.
942  *
943  * \param  decoder  A decoder instance to query.
944  * \assert
945  *    \code decoder != NULL \endcode
946  * \retval FLAC__ChannelAssignment
947  *    See above.
948  */
949 FLAC__ChannelAssignment FLAC__stream_decoder_get_channel_assignment(const FLAC__StreamDecoder* decoder);
950 
951 /** Get the current sample resolution in the stream being decoded.
952  *  Will only be valid after decoding has started and will contain the
953  *  value from the most recently decoded frame header.
954  *
955  * \param  decoder  A decoder instance to query.
956  * \assert
957  *    \code decoder != NULL \endcode
958  * \retval uint
959  *    See above.
960  */
961 uint FLAC__stream_decoder_get_bits_per_sample(const FLAC__StreamDecoder* decoder);
962 
963 /** Get the current sample rate in Hz of the stream being decoded.
964  *  Will only be valid after decoding has started and will contain the
965  *  value from the most recently decoded frame header.
966  *
967  * \param  decoder  A decoder instance to query.
968  * \assert
969  *    \code decoder != NULL \endcode
970  * \retval uint
971  *    See above.
972  */
973 uint FLAC__stream_decoder_get_sample_rate(const FLAC__StreamDecoder* decoder);
974 
975 /** Get the current blocksize of the stream being decoded.
976  *  Will only be valid after decoding has started and will contain the
977  *  value from the most recently decoded frame header.
978  *
979  * \param  decoder  A decoder instance to query.
980  * \assert
981  *    \code decoder != NULL \endcode
982  * \retval uint
983  *    See above.
984  */
985 uint FLAC__stream_decoder_get_blocksize(const FLAC__StreamDecoder* decoder);
986 
987 /** Returns the decoder's current read position within the stream.
988  *  The position is the byte offset from the start of the stream.
989  *  Bytes before this position have been fully decoded.  Note that
990  *  there may still be undecoded bytes in the decoder's read FIFO.
991  *  The returned position is correct even after a seek.
992  *
993  *  \warning This function currently only works for native FLAC,
994  *           not Ogg FLAC streams.
995  *
996  * \param  decoder   A decoder instance to query.
997  * \param  position  Address at which to return the desired position.
998  * \assert
999  *    \code decoder != NULL \endcode
1000  *    \code position != NULL \endcode
1001  * \retval FLAC__bool
1002  *    \c true if successful, \c false if the stream is not native FLAC,
1003  *    or there was an error from the 'tell' callback or it returned
1004  *    \c FLAC__STREAM_DECODER_TELL_STATUS_UNSUPPORTED.
1005  */
1006 FLAC__bool FLAC__stream_decoder_get_decode_position(const FLAC__StreamDecoder* decoder, FLAC__uint64* position);
1007 
1008 /** Initialize the decoder instance to decode native FLAC streams.
1009  *
1010  *  This flavor of initialization sets up the decoder to decode from a
1011  *  native FLAC stream. I/O is performed via callbacks to the client.
1012  *  For decoding from a plain file via filename or open FILE*,
1013  *  FLAC__stream_decoder_init_file() and FLAC__stream_decoder_init_FILE()
1014  *  provide a simpler interface.
1015  *
1016  *  This function should be called after FLAC__stream_decoder_new() and
1017  *  FLAC__stream_decoder_set_*() but before any of the
1018  *  FLAC__stream_decoder_process_*() functions.  Will set and return the
1019  *  decoder state, which will be FLAC__STREAM_DECODER_SEARCH_FOR_METADATA
1020  *  if initialization succeeded.
1021  *
1022  * \param  decoder            An uninitialized decoder instance.
1023  * \param  read_callback      See FLAC__StreamDecoderReadCallback.  This
1024  *                            pointer must not be \c NULL.
1025  * \param  seek_callback      See FLAC__StreamDecoderSeekCallback.  This
1026  *                            pointer may be \c NULL if seeking is not
1027  *                            supported.  If \a seek_callback is not \c NULL then a
1028  *                            \a tell_callback, \a length_callback, and \a eof_callback must also be supplied.
1029  *                            Alternatively, a dummy seek callback that just
1030  *                            returns \c FLAC__STREAM_DECODER_SEEK_STATUS_UNSUPPORTED
1031  *                            may also be supplied, all though this is slightly
1032  *                            less efficient for the decoder.
1033  * \param  tell_callback      See FLAC__StreamDecoderTellCallback.  This
1034  *                            pointer may be \c NULL if not supported by the client.  If
1035  *                            \a seek_callback is not \c NULL then a
1036  *                            \a tell_callback must also be supplied.
1037  *                            Alternatively, a dummy tell callback that just
1038  *                            returns \c FLAC__STREAM_DECODER_TELL_STATUS_UNSUPPORTED
1039  *                            may also be supplied, all though this is slightly
1040  *                            less efficient for the decoder.
1041  * \param  length_callback    See FLAC__StreamDecoderLengthCallback.  This
1042  *                            pointer may be \c NULL if not supported by the client.  If
1043  *                            \a seek_callback is not \c NULL then a
1044  *                            \a length_callback must also be supplied.
1045  *                            Alternatively, a dummy length callback that just
1046  *                            returns \c FLAC__STREAM_DECODER_LENGTH_STATUS_UNSUPPORTED
1047  *                            may also be supplied, all though this is slightly
1048  *                            less efficient for the decoder.
1049  * \param  eof_callback       See FLAC__StreamDecoderEofCallback.  This
1050  *                            pointer may be \c NULL if not supported by the client.  If
1051  *                            \a seek_callback is not \c NULL then a
1052  *                            \a eof_callback must also be supplied.
1053  *                            Alternatively, a dummy length callback that just
1054  *                            returns \c false
1055  *                            may also be supplied, all though this is slightly
1056  *                            less efficient for the decoder.
1057  * \param  write_callback     See FLAC__StreamDecoderWriteCallback.  This
1058  *                            pointer must not be \c NULL.
1059  * \param  metadata_callback  See FLAC__StreamDecoderMetadataCallback.  This
1060  *                            pointer may be \c NULL if the callback is not
1061  *                            desired.
1062  * \param  error_callback     See FLAC__StreamDecoderErrorCallback.  This
1063  *                            pointer must not be \c NULL.
1064  * \param  client_data        This value will be supplied to callbacks in their
1065  *                            \a client_data argument.
1066  * \assert
1067  *    \code decoder != NULL \endcode
1068  * \retval FLAC__StreamDecoderInitStatus
1069  *    \c FLAC__STREAM_DECODER_INIT_STATUS_OK if initialization was successful;
1070  *    see FLAC__StreamDecoderInitStatus for the meanings of other return values.
1071  */
1072 FLAC__StreamDecoderInitStatus FLAC__stream_decoder_init_stream(
1073     FLAC__StreamDecoder* decoder,
1074     FLAC__StreamDecoderReadCallback read_callback,
1075     FLAC__StreamDecoderSeekCallback seek_callback,
1076     FLAC__StreamDecoderTellCallback tell_callback,
1077     FLAC__StreamDecoderLengthCallback length_callback,
1078     FLAC__StreamDecoderEofCallback eof_callback,
1079     FLAC__StreamDecoderWriteCallback write_callback,
1080     FLAC__StreamDecoderMetadataCallback metadata_callback,
1081     FLAC__StreamDecoderErrorCallback error_callback,
1082     void* client_data
1083 );
1084 
1085 /** Initialize the decoder instance to decode Ogg FLAC streams.
1086  *
1087  *  This flavor of initialization sets up the decoder to decode from a
1088  *  FLAC stream in an Ogg container. I/O is performed via callbacks to the
1089  *  client.  For decoding from a plain file via filename or open FILE*,
1090  *  FLAC__stream_decoder_init_ogg_file() and FLAC__stream_decoder_init_ogg_FILE()
1091  *  provide a simpler interface.
1092  *
1093  *  This function should be called after FLAC__stream_decoder_new() and
1094  *  FLAC__stream_decoder_set_*() but before any of the
1095  *  FLAC__stream_decoder_process_*() functions.  Will set and return the
1096  *  decoder state, which will be FLAC__STREAM_DECODER_SEARCH_FOR_METADATA
1097  *  if initialization succeeded.
1098  *
1099  *  \note Support for Ogg FLAC in the library is optional.  If this
1100  *  library has been built without support for Ogg FLAC, this function
1101  *  will return \c FLAC__STREAM_DECODER_INIT_STATUS_UNSUPPORTED_CONTAINER.
1102  *
1103  * \param  decoder            An uninitialized decoder instance.
1104  * \param  read_callback      See FLAC__StreamDecoderReadCallback.  This
1105  *                            pointer must not be \c NULL.
1106  * \param  seek_callback      See FLAC__StreamDecoderSeekCallback.  This
1107  *                            pointer may be \c NULL if seeking is not
1108  *                            supported.  If \a seek_callback is not \c NULL then a
1109  *                            \a tell_callback, \a length_callback, and \a eof_callback must also be supplied.
1110  *                            Alternatively, a dummy seek callback that just
1111  *                            returns \c FLAC__STREAM_DECODER_SEEK_STATUS_UNSUPPORTED
1112  *                            may also be supplied, all though this is slightly
1113  *                            less efficient for the decoder.
1114  * \param  tell_callback      See FLAC__StreamDecoderTellCallback.  This
1115  *                            pointer may be \c NULL if not supported by the client.  If
1116  *                            \a seek_callback is not \c NULL then a
1117  *                            \a tell_callback must also be supplied.
1118  *                            Alternatively, a dummy tell callback that just
1119  *                            returns \c FLAC__STREAM_DECODER_TELL_STATUS_UNSUPPORTED
1120  *                            may also be supplied, all though this is slightly
1121  *                            less efficient for the decoder.
1122  * \param  length_callback    See FLAC__StreamDecoderLengthCallback.  This
1123  *                            pointer may be \c NULL if not supported by the client.  If
1124  *                            \a seek_callback is not \c NULL then a
1125  *                            \a length_callback must also be supplied.
1126  *                            Alternatively, a dummy length callback that just
1127  *                            returns \c FLAC__STREAM_DECODER_LENGTH_STATUS_UNSUPPORTED
1128  *                            may also be supplied, all though this is slightly
1129  *                            less efficient for the decoder.
1130  * \param  eof_callback       See FLAC__StreamDecoderEofCallback.  This
1131  *                            pointer may be \c NULL if not supported by the client.  If
1132  *                            \a seek_callback is not \c NULL then a
1133  *                            \a eof_callback must also be supplied.
1134  *                            Alternatively, a dummy length callback that just
1135  *                            returns \c false
1136  *                            may also be supplied, all though this is slightly
1137  *                            less efficient for the decoder.
1138  * \param  write_callback     See FLAC__StreamDecoderWriteCallback.  This
1139  *                            pointer must not be \c NULL.
1140  * \param  metadata_callback  See FLAC__StreamDecoderMetadataCallback.  This
1141  *                            pointer may be \c NULL if the callback is not
1142  *                            desired.
1143  * \param  error_callback     See FLAC__StreamDecoderErrorCallback.  This
1144  *                            pointer must not be \c NULL.
1145  * \param  client_data        This value will be supplied to callbacks in their
1146  *                            \a client_data argument.
1147  * \assert
1148  *    \code decoder != NULL \endcode
1149  * \retval FLAC__StreamDecoderInitStatus
1150  *    \c FLAC__STREAM_DECODER_INIT_STATUS_OK if initialization was successful;
1151  *    see FLAC__StreamDecoderInitStatus for the meanings of other return values.
1152  */
1153 FLAC__StreamDecoderInitStatus FLAC__stream_decoder_init_ogg_stream(
1154     FLAC__StreamDecoder* decoder,
1155     FLAC__StreamDecoderReadCallback read_callback,
1156     FLAC__StreamDecoderSeekCallback seek_callback,
1157     FLAC__StreamDecoderTellCallback tell_callback,
1158     FLAC__StreamDecoderLengthCallback length_callback,
1159     FLAC__StreamDecoderEofCallback eof_callback,
1160     FLAC__StreamDecoderWriteCallback write_callback,
1161     FLAC__StreamDecoderMetadataCallback metadata_callback,
1162     FLAC__StreamDecoderErrorCallback error_callback,
1163     void* client_data
1164 );
1165 
1166 /** Initialize the decoder instance to decode native FLAC files.
1167  *
1168  *  This flavor of initialization sets up the decoder to decode from a
1169  *  plain native FLAC file.  For non-stdio streams, you must use
1170  *  FLAC__stream_decoder_init_stream() and provide callbacks for the I/O.
1171  *
1172  *  This function should be called after FLAC__stream_decoder_new() and
1173  *  FLAC__stream_decoder_set_*() but before any of the
1174  *  FLAC__stream_decoder_process_*() functions.  Will set and return the
1175  *  decoder state, which will be FLAC__STREAM_DECODER_SEARCH_FOR_METADATA
1176  *  if initialization succeeded.
1177  *
1178  * \param  decoder            An uninitialized decoder instance.
1179  * \param  file               An open FLAC file.  The file should have been
1180  *                            opened with mode \c "rb" and rewound.  The file
1181  *                            becomes owned by the decoder and should not be
1182  *                            manipulated by the client while decoding.
1183  *                            Unless \a file is \c stdin, it will be closed
1184  *                            when FLAC__stream_decoder_finish() is called.
1185  *                            Note however that seeking will not work when
1186  *                            decoding from \c stdout since it is not seekable.
1187  * \param  write_callback     See FLAC__StreamDecoderWriteCallback.  This
1188  *                            pointer must not be \c NULL.
1189  * \param  metadata_callback  See FLAC__StreamDecoderMetadataCallback.  This
1190  *                            pointer may be \c NULL if the callback is not
1191  *                            desired.
1192  * \param  error_callback     See FLAC__StreamDecoderErrorCallback.  This
1193  *                            pointer must not be \c NULL.
1194  * \param  client_data        This value will be supplied to callbacks in their
1195  *                            \a client_data argument.
1196  * \assert
1197  *    \code decoder != NULL \endcode
1198  *    \code file != NULL \endcode
1199  * \retval FLAC__StreamDecoderInitStatus
1200  *    \c FLAC__STREAM_DECODER_INIT_STATUS_OK if initialization was successful;
1201  *    see FLAC__StreamDecoderInitStatus for the meanings of other return values.
1202  */
1203 FLAC__StreamDecoderInitStatus FLAC__stream_decoder_init_FILE(
1204     FLAC__StreamDecoder *decoder,
1205     FILE* file,
1206     FLAC__StreamDecoderWriteCallback write_callback,
1207     FLAC__StreamDecoderMetadataCallback metadata_callback,
1208     FLAC__StreamDecoderErrorCallback error_callback,
1209     void* client_data
1210 );
1211 
1212 /** Initialize the decoder instance to decode Ogg FLAC files.
1213  *
1214  *  This flavor of initialization sets up the decoder to decode from a
1215  *  plain Ogg FLAC file.  For non-stdio streams, you must use
1216  *  FLAC__stream_decoder_init_ogg_stream() and provide callbacks for the I/O.
1217  *
1218  *  This function should be called after FLAC__stream_decoder_new() and
1219  *  FLAC__stream_decoder_set_*() but before any of the
1220  *  FLAC__stream_decoder_process_*() functions.  Will set and return the
1221  *  decoder state, which will be FLAC__STREAM_DECODER_SEARCH_FOR_METADATA
1222  *  if initialization succeeded.
1223  *
1224  *  \note Support for Ogg FLAC in the library is optional.  If this
1225  *  library has been built without support for Ogg FLAC, this function
1226  *  will return \c FLAC__STREAM_DECODER_INIT_STATUS_UNSUPPORTED_CONTAINER.
1227  *
1228  * \param  decoder            An uninitialized decoder instance.
1229  * \param  file               An open FLAC file.  The file should have been
1230  *                            opened with mode \c "rb" and rewound.  The file
1231  *                            becomes owned by the decoder and should not be
1232  *                            manipulated by the client while decoding.
1233  *                            Unless \a file is \c stdin, it will be closed
1234  *                            when FLAC__stream_decoder_finish() is called.
1235  *                            Note however that seeking will not work when
1236  *                            decoding from \c stdout since it is not seekable.
1237  * \param  write_callback     See FLAC__StreamDecoderWriteCallback.  This
1238  *                            pointer must not be \c NULL.
1239  * \param  metadata_callback  See FLAC__StreamDecoderMetadataCallback.  This
1240  *                            pointer may be \c NULL if the callback is not
1241  *                            desired.
1242  * \param  error_callback     See FLAC__StreamDecoderErrorCallback.  This
1243  *                            pointer must not be \c NULL.
1244  * \param  client_data        This value will be supplied to callbacks in their
1245  *                            \a client_data argument.
1246  * \assert
1247  *    \code decoder != NULL \endcode
1248  *    \code file != NULL \endcode
1249  * \retval FLAC__StreamDecoderInitStatus
1250  *    \c FLAC__STREAM_DECODER_INIT_STATUS_OK if initialization was successful;
1251  *    see FLAC__StreamDecoderInitStatus for the meanings of other return values.
1252  */
1253 FLAC__StreamDecoderInitStatus FLAC__stream_decoder_init_ogg_FILE(
1254     FLAC__StreamDecoder* decoder,
1255     FILE* file,
1256     FLAC__StreamDecoderWriteCallback write_callback,
1257     FLAC__StreamDecoderMetadataCallback metadata_callback,
1258     FLAC__StreamDecoderErrorCallback error_callback,
1259     void* client_data
1260 );
1261 
1262 /** Initialize the decoder instance to decode native FLAC files.
1263  *
1264  *  This flavor of initialization sets up the decoder to decode from a plain
1265  *  native FLAC file.  If POSIX fopen() semantics are not sufficient, (for
1266  *  example, with Unicode filenames on Windows), you must use
1267  *  FLAC__stream_decoder_init_FILE(), or FLAC__stream_decoder_init_stream()
1268  *  and provide callbacks for the I/O.
1269  *
1270  *  This function should be called after FLAC__stream_decoder_new() and
1271  *  FLAC__stream_decoder_set_*() but before any of the
1272  *  FLAC__stream_decoder_process_*() functions.  Will set and return the
1273  *  decoder state, which will be FLAC__STREAM_DECODER_SEARCH_FOR_METADATA
1274  *  if initialization succeeded.
1275  *
1276  * \param  decoder            An uninitialized decoder instance.
1277  * \param  filename           The name of the file to decode from.  The file will
1278  *                            be opened with fopen().  Use \c NULL to decode from
1279  *                            \c stdin.  Note that \c stdin is not seekable.
1280  * \param  write_callback     See FLAC__StreamDecoderWriteCallback.  This
1281  *                            pointer must not be \c NULL.
1282  * \param  metadata_callback  See FLAC__StreamDecoderMetadataCallback.  This
1283  *                            pointer may be \c NULL if the callback is not
1284  *                            desired.
1285  * \param  error_callback     See FLAC__StreamDecoderErrorCallback.  This
1286  *                            pointer must not be \c NULL.
1287  * \param  client_data        This value will be supplied to callbacks in their
1288  *                            \a client_data argument.
1289  * \assert
1290  *    \code decoder != NULL \endcode
1291  * \retval FLAC__StreamDecoderInitStatus
1292  *    \c FLAC__STREAM_DECODER_INIT_STATUS_OK if initialization was successful;
1293  *    see FLAC__StreamDecoderInitStatus for the meanings of other return values.
1294  */
1295 FLAC__StreamDecoderInitStatus FLAC__stream_decoder_init_file(
1296     FLAC__StreamDecoder* decoder,
1297     const char* filename,
1298     FLAC__StreamDecoderWriteCallback write_callback,
1299     FLAC__StreamDecoderMetadataCallback metadata_callback,
1300     FLAC__StreamDecoderErrorCallback error_callback,
1301     void* client_data
1302 );
1303 
1304 /** Initialize the decoder instance to decode Ogg FLAC files.
1305  *
1306  *  This flavor of initialization sets up the decoder to decode from a plain
1307  *  Ogg FLAC file.  If POSIX fopen() semantics are not sufficient, (for
1308  *  example, with Unicode filenames on Windows), you must use
1309  *  FLAC__stream_decoder_init_ogg_FILE(), or FLAC__stream_decoder_init_ogg_stream()
1310  *  and provide callbacks for the I/O.
1311  *
1312  *  This function should be called after FLAC__stream_decoder_new() and
1313  *  FLAC__stream_decoder_set_*() but before any of the
1314  *  FLAC__stream_decoder_process_*() functions.  Will set and return the
1315  *  decoder state, which will be FLAC__STREAM_DECODER_SEARCH_FOR_METADATA
1316  *  if initialization succeeded.
1317  *
1318  *  \note Support for Ogg FLAC in the library is optional.  If this
1319  *  library has been built without support for Ogg FLAC, this function
1320  *  will return \c FLAC__STREAM_DECODER_INIT_STATUS_UNSUPPORTED_CONTAINER.
1321  *
1322  * \param  decoder            An uninitialized decoder instance.
1323  * \param  filename           The name of the file to decode from.  The file will
1324  *                            be opened with fopen().  Use \c NULL to decode from
1325  *                            \c stdin.  Note that \c stdin is not seekable.
1326  * \param  write_callback     See FLAC__StreamDecoderWriteCallback.  This
1327  *                            pointer must not be \c NULL.
1328  * \param  metadata_callback  See FLAC__StreamDecoderMetadataCallback.  This
1329  *                            pointer may be \c NULL if the callback is not
1330  *                            desired.
1331  * \param  error_callback     See FLAC__StreamDecoderErrorCallback.  This
1332  *                            pointer must not be \c NULL.
1333  * \param  client_data        This value will be supplied to callbacks in their
1334  *                            \a client_data argument.
1335  * \assert
1336  *    \code decoder != NULL \endcode
1337  * \retval FLAC__StreamDecoderInitStatus
1338  *    \c FLAC__STREAM_DECODER_INIT_STATUS_OK if initialization was successful;
1339  *    see FLAC__StreamDecoderInitStatus for the meanings of other return values.
1340  */
1341 FLAC__StreamDecoderInitStatus FLAC__stream_decoder_init_ogg_file(
1342     FLAC__StreamDecoder *decoder,
1343     const char* filename,
1344     FLAC__StreamDecoderWriteCallback write_callback,
1345     FLAC__StreamDecoderMetadataCallback metadata_callback,
1346     FLAC__StreamDecoderErrorCallback error_callback,
1347     void* client_data
1348 );
1349 
1350 /** Finish the decoding process.
1351  *  Flushes the decoding buffer, releases resources, resets the decoder
1352  *  settings to their defaults, and returns the decoder state to
1353  *  FLAC__STREAM_DECODER_UNINITIALIZED.
1354  *
1355  *  In the event of a prematurely-terminated decode, it is not strictly
1356  *  necessary to call this immediately before FLAC__stream_decoder_delete()
1357  *  but it is good practice to match every FLAC__stream_decoder_init_*()
1358  *  with a FLAC__stream_decoder_finish().
1359  *
1360  * \param  decoder  An uninitialized decoder instance.
1361  * \assert
1362  *    \code decoder != NULL \endcode
1363  * \retval FLAC__bool
1364  *    \c false if MD5 checking is on AND a STREAMINFO block was available
1365  *    AND the MD5 signature in the STREAMINFO block was non-zero AND the
1366  *    signature does not match the one computed by the decoder; else
1367  *    \c true.
1368  */
1369 FLAC__bool FLAC__stream_decoder_finish(FLAC__StreamDecoder* decoder);
1370 
1371 /** Flush the stream input.
1372  *  The decoder's input buffer will be cleared and the state set to
1373  *  \c FLAC__STREAM_DECODER_SEARCH_FOR_FRAME_SYNC.  This will also turn
1374  *  off MD5 checking.
1375  *
1376  * \param  decoder  A decoder instance.
1377  * \assert
1378  *    \code decoder != NULL \endcode
1379  * \retval FLAC__bool
1380  *    \c true if successful, else \c false if a memory allocation
1381  *    error occurs (in which case the state will be set to
1382  *    \c FLAC__STREAM_DECODER_MEMORY_ALLOCATION_ERROR).
1383  */
1384 FLAC__bool FLAC__stream_decoder_flush(FLAC__StreamDecoder* decoder);
1385 
1386 /** Reset the decoding process.
1387  *  The decoder's input buffer will be cleared and the state set to
1388  *  \c FLAC__STREAM_DECODER_SEARCH_FOR_METADATA.  This is similar to
1389  *  FLAC__stream_decoder_finish() except that the settings are
1390  *  preserved; there is no need to call FLAC__stream_decoder_init_*()
1391  *  before decoding again.  MD5 checking will be restored to its original
1392  *  setting.
1393  *
1394  *  If the decoder is seekable, or was initialized with
1395  *  FLAC__stream_decoder_init*_FILE() or FLAC__stream_decoder_init*_file(),
1396  *  the decoder will also attempt to seek to the beginning of the file.
1397  *  If this rewind fails, this function will return \c false.  It follows
1398  *  that FLAC__stream_decoder_reset() cannot be used when decoding from
1399  *  \c stdin.
1400  *
1401  *  If the decoder was initialized with FLAC__stream_encoder_init*_stream()
1402  *  and is not seekable (i.e. no seek callback was provided or the seek
1403  *  callback returns \c FLAC__STREAM_DECODER_SEEK_STATUS_UNSUPPORTED), it
1404  *  is the duty of the client to start feeding data from the beginning of
1405  *  the stream on the next FLAC__stream_decoder_process() or
1406  *  FLAC__stream_decoder_process_interleaved() call.
1407  *
1408  * \param  decoder  A decoder instance.
1409  * \assert
1410  *    \code decoder != NULL \endcode
1411  * \retval FLAC__bool
1412  *    \c true if successful, else \c false if a memory allocation occurs
1413  *    (in which case the state will be set to
1414  *    \c FLAC__STREAM_DECODER_MEMORY_ALLOCATION_ERROR) or a seek error
1415  *    occurs (the state will be unchanged).
1416  */
1417 FLAC__bool FLAC__stream_decoder_reset(FLAC__StreamDecoder* decoder);
1418 
1419 /** Decode one metadata block or audio frame.
1420  *  This version instructs the decoder to decode a either a single metadata
1421  *  block or a single frame and stop, unless the callbacks return a fatal
1422  *  error or the read callback returns
1423  *  \c FLAC__STREAM_DECODER_READ_STATUS_END_OF_STREAM.
1424  *
1425  *  As the decoder needs more input it will call the read callback.
1426  *  Depending on what was decoded, the metadata or write callback will be
1427  *  called with the decoded metadata block or audio frame.
1428  *
1429  *  Unless there is a fatal read error or end of stream, this function
1430  *  will return once one whole frame is decoded.  In other words, if the
1431  *  stream is not synchronized or points to a corrupt frame header, the
1432  *  decoder will continue to try and resync until it gets to a valid
1433  *  frame, then decode one frame, then return.  If the decoder points to
1434  *  a frame whose frame CRC in the frame footer does not match the
1435  *  computed frame CRC, this function will issue a
1436  *  FLAC__STREAM_DECODER_ERROR_STATUS_FRAME_CRC_MISMATCH error to the
1437  *  error callback, and return, having decoded one complete, although
1438  *  corrupt, frame.  (Such corrupted frames are sent as silence of the
1439  *  correct length to the write callback.)
1440  *
1441  * \param  decoder  An initialized decoder instance.
1442  * \assert
1443  *    \code decoder != NULL \endcode
1444  * \retval FLAC__bool
1445  *    \c false if any fatal read, write, or memory allocation error
1446  *    occurred (meaning decoding must stop), else \c true; for more
1447  *    information about the decoder, check the decoder state with
1448  *    FLAC__stream_decoder_get_state().
1449  */
1450 FLAC__bool FLAC__stream_decoder_process_single(FLAC__StreamDecoder* decoder);
1451 
1452 /** Decode until the end of the metadata.
1453  *  This version instructs the decoder to decode from the current position
1454  *  and continue until all the metadata has been read, or until the
1455  *  callbacks return a fatal error or the read callback returns
1456  *  \c FLAC__STREAM_DECODER_READ_STATUS_END_OF_STREAM.
1457  *
1458  *  As the decoder needs more input it will call the read callback.
1459  *  As each metadata block is decoded, the metadata callback will be called
1460  *  with the decoded metadata.
1461  *
1462  * \param  decoder  An initialized decoder instance.
1463  * \assert
1464  *    \code decoder != NULL \endcode
1465  * \retval FLAC__bool
1466  *    \c false if any fatal read, write, or memory allocation error
1467  *    occurred (meaning decoding must stop), else \c true; for more
1468  *    information about the decoder, check the decoder state with
1469  *    FLAC__stream_decoder_get_state().
1470  */
1471 FLAC__bool FLAC__stream_decoder_process_until_end_of_metadata(FLAC__StreamDecoder* decoder);
1472 
1473 /** Decode until the end of the stream.
1474  *  This version instructs the decoder to decode from the current position
1475  *  and continue until the end of stream (the read callback returns
1476  *  \c FLAC__STREAM_DECODER_READ_STATUS_END_OF_STREAM), or until the
1477  *  callbacks return a fatal error.
1478  *
1479  *  As the decoder needs more input it will call the read callback.
1480  *  As each metadata block and frame is decoded, the metadata or write
1481  *  callback will be called with the decoded metadata or frame.
1482  *
1483  * \param  decoder  An initialized decoder instance.
1484  * \assert
1485  *    \code decoder != NULL \endcode
1486  * \retval FLAC__bool
1487  *    \c false if any fatal read, write, or memory allocation error
1488  *    occurred (meaning decoding must stop), else \c true; for more
1489  *    information about the decoder, check the decoder state with
1490  *    FLAC__stream_decoder_get_state().
1491  */
1492 FLAC__bool FLAC__stream_decoder_process_until_end_of_stream(FLAC__StreamDecoder* decoder);
1493 
1494 /** Skip one audio frame.
1495  *  This version instructs the decoder to 'skip' a single frame and stop,
1496  *  unless the callbacks return a fatal error or the read callback returns
1497  *  \c FLAC__STREAM_DECODER_READ_STATUS_END_OF_STREAM.
1498  *
1499  *  The decoding flow is the same as what occurs when
1500  *  FLAC__stream_decoder_process_single() is called to process an audio
1501  *  frame, except that this function does not decode the parsed data into
1502  *  PCM or call the write callback.  The integrity of the frame is still
1503  *  checked the same way as in the other process functions.
1504  *
1505  *  This function will return once one whole frame is skipped, in the
1506  *  same way that FLAC__stream_decoder_process_single() will return once
1507  *  one whole frame is decoded.
1508  *
1509  *  This function can be used in more quickly determining FLAC frame
1510  *  boundaries when decoding of the actual data is not needed, for
1511  *  example when an application is separating a FLAC stream into frames
1512  *  for editing or storing in a container.  To do this, the application
1513  *  can use FLAC__stream_decoder_skip_single_frame() to quickly advance
1514  *  to the next frame, then use
1515  *  FLAC__stream_decoder_get_decode_position() to find the new frame
1516  *  boundary.
1517  *
1518  *  This function should only be called when the stream has advanced
1519  *  past all the metadata, otherwise it will return \c false.
1520  *
1521  * \param  decoder  An initialized decoder instance not in a metadata
1522  *                  state.
1523  * \assert
1524  *    \code decoder != NULL \endcode
1525  * \retval FLAC__bool
1526  *    \c false if any fatal read, write, or memory allocation error
1527  *    occurred (meaning decoding must stop), or if the decoder
1528  *    is in the FLAC__STREAM_DECODER_SEARCH_FOR_METADATA or
1529  *    FLAC__STREAM_DECODER_READ_METADATA state, else \c true; for more
1530  *    information about the decoder, check the decoder state with
1531  *    FLAC__stream_decoder_get_state().
1532  */
1533 FLAC__bool FLAC__stream_decoder_skip_single_frame(FLAC__StreamDecoder* decoder);
1534 
1535 /** Flush the input and seek to an absolute sample.
1536  *  Decoding will resume at the given sample.  Note that because of
1537  *  this, the next write callback may contain a partial block.  The
1538  *  client must support seeking the input or this function will fail
1539  *  and return \c false.  Furthermore, if the decoder state is
1540  *  \c FLAC__STREAM_DECODER_SEEK_ERROR, then the decoder must be flushed
1541  *  with FLAC__stream_decoder_flush() or reset with
1542  *  FLAC__stream_decoder_reset() before decoding can continue.
1543  *
1544  * \param  decoder  A decoder instance.
1545  * \param  sample   The target sample number to seek to.
1546  * \assert
1547  *    \code decoder != NULL \endcode
1548  * \retval FLAC__bool
1549  *    \c true if successful, else \c false.
1550  */
1551 FLAC__bool FLAC__stream_decoder_seek_absolute(FLAC__StreamDecoder* decoder, FLAC__uint64 sample);