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