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