The "GR-PEACH_Audio_Playback_Sample" is a sample code that can provides high-resolution audio playback of FLAC format files. It also allows the user to audio-playback control functions such as play, pause, and stop by manipulating key switches.

Dependencies:   R_BSP TLV320_RBSP USBHost_custom

Note

For a sample program of with LCD Board,
please refer to GR-PEACH_Audio_Playback_7InchLCD_Sample.

Introduction

The "GR-PEACH_Audio_Playback_Sample" is a sample code that can provides high-resolution audio playback of FLAC format files. It also allows the user to audio-playback control functions such as play, pause, and stop by manipulating key switches.

1. Overview of the Sample Code

1.1 Software Block Diagram

Figure 1.1 shows the software block diagram.

/media/uploads/dkato/audioplayback_figure1_1x.png

1.2 Pin Definitions

Table 1.1 shows the pins that this sample code are to use.

/media/uploads/dkato/audioplayback_table1_1.png

2. Sample Code Operating Environment

This sample code runs in GR-PEACH + the Audio/Camera shield for the GR-PEACH environment. This section explains the functions of the ports that are used by this sample code.

2.1 Operating Environment

Figure 2.1 shows the configuration of the operating environment for running this sample code.

/media/uploads/dkato/audioplayback_figure2_1.png /media/uploads/1050186/figure2_2.png /media/uploads/dkato/audioplayback_figure2_3.png

2.2 List of User Operations

A list of user operations on the command line, TFT touch keys, and switch key that the user can perform for this sample code is shown in. Table 2.1.

/media/uploads/dkato/audioplayback_table2_1x.png

3. Function Outline

The functions of this sample code are summarized in Table 3.1 to Table 3.3.

/media/uploads/dkato/audioplayback_table3_1.png /media/uploads/dkato/audioplayback_table3_2.png /media/uploads/dkato/audioplayback_table3_3.png /media/uploads/dkato/audioplayback_figure3_1.png

3.1 Playback Control

The playback control that the sample code supports include play, pause, stop, skip to next, and skip to previous.

3.2 Trick Play Control

Manipulating "Repeat" alternates between "Repeat mode On" and "Repeat mode Off". The default mode is "Repeat mode On". When the repeat mode is on, the playback of the first song starts after the playback of the last song is finished. When the repeat mode is off, the sample code enters the stopped state after the playback of the last song is finished.

3.3 Acquisition of the Song Information

The information of the song being played is obtained by operating the "Play info" during the playback of the song. Table 3.4 lists the items of information that can be obtained by the "Play info" operation.

/media/uploads/dkato/audioplayback_table3_4.png

3.4 How the Folder Structure is Analyzed

The sample coded analyzes the folder structure in the breadth-first search order. The order in which files are numbered is illustrated in Table 3.5. The sample code does not sort the files by file or folder name.

/media/uploads/dkato/audioplayback_table3_5.png

4.Others

The default setting of serial communication (baud rate etc.) in mbed is shown the following link.
Please refer to the link and change the settings of your PC terminal software.
The default value of baud rate in mbed is 9600, and this application uses baud rate 9600.
https://developer.mbed.org/teams/Renesas/wiki/GR-PEACH-Getting-Started#install-the-usb-serial-communication

Committer:
dkato
Date:
Fri Oct 16 04:28:07 2015 +0000
Revision:
0:ee40da884cfc
first commit

Who changed what in which revision?

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