337
507
* stored (0 in case of error or end-of-stream) before
339
509
* \param client_data The callee's client data set through
340
* FLAC__stream_decoder_set_client_data().
510
* FLAC__stream_decoder_init_*().
341
511
* \retval FLAC__StreamDecoderReadStatus
342
* The callee's return status.
344
typedef FLAC__StreamDecoderReadStatus (*FLAC__StreamDecoderReadCallback)(const FLAC__StreamDecoder *decoder, FLAC__byte buffer[], unsigned *bytes, void *client_data);
512
* The callee's return status. Note that the callback should return
513
* \c FLAC__STREAM_DECODER_READ_STATUS_END_OF_STREAM if and only if
514
* zero bytes were read and there is no more data to be read.
516
typedef FLAC__StreamDecoderReadStatus (*FLAC__StreamDecoderReadCallback)(const FLAC__StreamDecoder *decoder, FLAC__byte buffer[], size_t *bytes, void *client_data);
518
/** Signature for the seek callback.
520
* A function pointer matching this signature may be passed to
521
* FLAC__stream_decoder_init*_stream(). The supplied function will be
522
* called when the decoder needs to seek the input stream. The decoder
523
* will pass the absolute byte offset to seek to, 0 meaning the
524
* beginning of the stream.
526
* Here is an example of a seek callback for stdio streams:
528
* FLAC__StreamDecoderSeekStatus seek_cb(const FLAC__StreamDecoder *decoder, FLAC__uint64 absolute_byte_offset, void *client_data)
530
* FILE *file = ((MyClientData*)client_data)->file;
532
* return FLAC__STREAM_DECODER_SEEK_STATUS_UNSUPPORTED;
533
* else if(fseeko(file, (off_t)absolute_byte_offset, SEEK_SET) < 0)
534
* return FLAC__STREAM_DECODER_SEEK_STATUS_ERROR;
536
* return FLAC__STREAM_DECODER_SEEK_STATUS_OK;
540
* \note In general, FLAC__StreamDecoder functions which change the
541
* state should not be called on the \a decoder while in the callback.
543
* \param decoder The decoder instance calling the callback.
544
* \param absolute_byte_offset The offset from the beginning of the stream
546
* \param client_data The callee's client data set through
547
* FLAC__stream_decoder_init_*().
548
* \retval FLAC__StreamDecoderSeekStatus
549
* The callee's return status.
551
typedef FLAC__StreamDecoderSeekStatus (*FLAC__StreamDecoderSeekCallback)(const FLAC__StreamDecoder *decoder, FLAC__uint64 absolute_byte_offset, void *client_data);
553
/** Signature for the tell callback.
555
* A function pointer matching this signature may be passed to
556
* FLAC__stream_decoder_init*_stream(). The supplied function will be
557
* called when the decoder wants to know the current position of the
558
* stream. The callback should return the byte offset from the
559
* beginning of the stream.
561
* Here is an example of a tell callback for stdio streams:
563
* FLAC__StreamDecoderTellStatus tell_cb(const FLAC__StreamDecoder *decoder, FLAC__uint64 *absolute_byte_offset, void *client_data)
565
* FILE *file = ((MyClientData*)client_data)->file;
568
* return FLAC__STREAM_DECODER_TELL_STATUS_UNSUPPORTED;
569
* else if((pos = ftello(file)) < 0)
570
* return FLAC__STREAM_DECODER_TELL_STATUS_ERROR;
572
* *absolute_byte_offset = (FLAC__uint64)pos;
573
* return FLAC__STREAM_DECODER_TELL_STATUS_OK;
578
* \note In general, FLAC__StreamDecoder functions which change the
579
* state should not be called on the \a decoder while in the callback.
581
* \param decoder The decoder instance calling the callback.
582
* \param absolute_byte_offset A pointer to storage for the current offset
583
* from the beginning of the stream.
584
* \param client_data The callee's client data set through
585
* FLAC__stream_decoder_init_*().
586
* \retval FLAC__StreamDecoderTellStatus
587
* The callee's return status.
589
typedef FLAC__StreamDecoderTellStatus (*FLAC__StreamDecoderTellCallback)(const FLAC__StreamDecoder *decoder, FLAC__uint64 *absolute_byte_offset, void *client_data);
591
/** Signature for the length callback.
593
* A function pointer matching this signature may be passed to
594
* FLAC__stream_decoder_init*_stream(). The supplied function will be
595
* called when the decoder wants to know the total length of the stream
598
* Here is an example of a length callback for stdio streams:
600
* FLAC__StreamDecoderLengthStatus length_cb(const FLAC__StreamDecoder *decoder, FLAC__uint64 *stream_length, void *client_data)
602
* FILE *file = ((MyClientData*)client_data)->file;
603
* struct stat filestats;
606
* return FLAC__STREAM_DECODER_LENGTH_STATUS_UNSUPPORTED;
607
* else if(fstat(fileno(file), &filestats) != 0)
608
* return FLAC__STREAM_DECODER_LENGTH_STATUS_ERROR;
610
* *stream_length = (FLAC__uint64)filestats.st_size;
611
* return FLAC__STREAM_DECODER_LENGTH_STATUS_OK;
616
* \note In general, FLAC__StreamDecoder functions which change the
617
* state should not be called on the \a decoder while in the callback.
619
* \param decoder The decoder instance calling the callback.
620
* \param stream_length A pointer to storage for the length of the stream
622
* \param client_data The callee's client data set through
623
* FLAC__stream_decoder_init_*().
624
* \retval FLAC__StreamDecoderLengthStatus
625
* The callee's return status.
627
typedef FLAC__StreamDecoderLengthStatus (*FLAC__StreamDecoderLengthCallback)(const FLAC__StreamDecoder *decoder, FLAC__uint64 *stream_length, void *client_data);
629
/** Signature for the EOF callback.
631
* A function pointer matching this signature may be passed to
632
* FLAC__stream_decoder_init*_stream(). The supplied function will be
633
* called when the decoder needs to know if the end of the stream has
636
* Here is an example of a EOF callback for stdio streams:
637
* FLAC__bool eof_cb(const FLAC__StreamDecoder *decoder, void *client_data)
640
* FILE *file = ((MyClientData*)client_data)->file;
641
* return feof(file)? true : false;
645
* \note In general, FLAC__StreamDecoder functions which change the
646
* state should not be called on the \a decoder while in the callback.
648
* \param decoder The decoder instance calling the callback.
649
* \param client_data The callee's client data set through
650
* FLAC__stream_decoder_init_*().
652
* \c true if the currently at the end of the stream, else \c false.
654
typedef FLAC__bool (*FLAC__StreamDecoderEofCallback)(const FLAC__StreamDecoder *decoder, void *client_data);
346
656
/** Signature for the write callback.
347
* See FLAC__stream_decoder_set_write_callback() for more info.
658
* A function pointer matching this signature must be passed to one of
659
* the FLAC__stream_decoder_init_*() functions.
660
* The supplied function will be called when the decoder has decoded a
661
* single audio frame. The decoder will pass the frame metadata as well
662
* as an array of pointers (one for each channel) pointing to the
665
* \note In general, FLAC__StreamDecoder functions which change the
666
* state should not be called on the \a decoder while in the callback.
349
668
* \param decoder The decoder instance calling the callback.
350
669
* \param frame The description of the decoded frame. See
414
757
***********************************************************************/
416
/** Set the read callback.
417
* The supplied function will be called when the decoder needs more input
418
* data. The address of the buffer to be filled is supplied, along with
419
* the number of bytes the buffer can hold. The callback may choose to
420
* supply less data and modify the byte count but must be careful not to
421
* overflow the buffer. The callback then returns a status code chosen
422
* from FLAC__StreamDecoderReadStatus.
425
* The callback is mandatory and must be set before initialization.
428
* \param decoder A decoder instance to set.
429
* \param value See above.
431
* \code decoder != NULL \endcode
432
* \code value != NULL \endcode
434
* \c false if the decoder is already initialized, else \c true.
436
FLAC_API FLAC__bool FLAC__stream_decoder_set_read_callback(FLAC__StreamDecoder *decoder, FLAC__StreamDecoderReadCallback value);
438
/** Set the write callback.
439
* The supplied function will be called when the decoder has decoded a
440
* single frame of data. The decoder will pass the frame metadata as
441
* well as an array of pointers (one for each channel) pointing to the
445
* The callback is mandatory and must be set before initialization.
448
* \param decoder A decoder instance to set.
449
* \param value See above.
451
* \code decoder != NULL \endcode
452
* \code value != NULL \endcode
454
* \c false if the decoder is already initialized, else \c true.
456
FLAC_API FLAC__bool FLAC__stream_decoder_set_write_callback(FLAC__StreamDecoder *decoder, FLAC__StreamDecoderWriteCallback value);
458
/** Set the metadata callback.
459
* The supplied function will be called when the decoder has decoded a metadata
460
* block. In a valid FLAC file there will always be one STREAMINFO block,
461
* followed by zero or more other metadata blocks. These will be supplied
462
* by the decoder in the same order as they appear in the stream and always
463
* before the first audio frame (i.e. write callback). The metadata block
464
* that is passed in must not be modified, and it doesn't live beyond the
465
* callback, so you should make a copy of it with
466
* FLAC__metadata_object_clone() if you will need it elsewhere. Since
467
* metadata blocks can potentially be large, by default the decoder only
468
* calls the metadata callback for the STREAMINFO block; you can instruct
469
* the decoder to pass or filter other blocks with
470
* FLAC__stream_decoder_set_metadata_*() calls.
473
* The callback is mandatory and must be set before initialization.
476
* \param decoder A decoder instance to set.
477
* \param value See above.
479
* \code decoder != NULL \endcode
480
* \code value != NULL \endcode
482
* \c false if the decoder is already initialized, else \c true.
484
FLAC_API FLAC__bool FLAC__stream_decoder_set_metadata_callback(FLAC__StreamDecoder *decoder, FLAC__StreamDecoderMetadataCallback value);
486
/** Set the error callback.
487
* The supplied function will be called whenever an error occurs during
491
* The callback is mandatory and must be set before initialization.
494
* \param decoder A decoder instance to set.
495
* \param value See above.
497
* \code decoder != NULL \endcode
498
* \code value != NULL \endcode
500
* \c false if the decoder is already initialized, else \c true.
502
FLAC_API FLAC__bool FLAC__stream_decoder_set_error_callback(FLAC__StreamDecoder *decoder, FLAC__StreamDecoderErrorCallback value);
504
/** Set the client data to be passed back to callbacks.
505
* This value will be supplied to callbacks in their \a client_data
509
* \param decoder A decoder instance to set.
510
* \param value See above.
512
* \code decoder != NULL \endcode
514
* \c false if the decoder is already initialized, else \c true.
516
FLAC_API FLAC__bool FLAC__stream_decoder_set_client_data(FLAC__StreamDecoder *decoder, void *value);
759
/** Set the serial number for the FLAC stream within the Ogg container.
760
* The default behavior is to use the serial number of the first Ogg
761
* page. Setting a serial number here will explicitly specify which
762
* stream is to be decoded.
765
* This does not need to be set for native FLAC decoding.
767
* \default \c use serial number of first page
768
* \param decoder A decoder instance to set.
769
* \param serial_number See above.
771
* \code decoder != NULL \endcode
773
* \c false if the decoder is already initialized, else \c true.
775
FLAC_API FLAC__bool FLAC__stream_decoder_set_ogg_serial_number(FLAC__StreamDecoder *decoder, long serial_number);
777
/** Set the "MD5 signature checking" flag. If \c true, the decoder will
778
* compute the MD5 signature of the unencoded audio data while decoding
779
* and compare it to the signature from the STREAMINFO block, if it
780
* exists, during FLAC__stream_decoder_finish().
782
* MD5 signature checking will be turned off (until the next
783
* FLAC__stream_decoder_reset()) if there is no signature in the
784
* STREAMINFO block or when a seek is attempted.
786
* Clients that do not use the MD5 check should leave this off to speed
790
* \param decoder A decoder instance to set.
791
* \param value Flag value (see above).
793
* \code decoder != NULL \endcode
795
* \c false if the decoder is already initialized, else \c true.
797
FLAC_API FLAC__bool FLAC__stream_decoder_set_md5_checking(FLAC__StreamDecoder *decoder, FLAC__bool value);
518
799
/** Direct the decoder to pass on all metadata blocks of type \a type.
678
985
FLAC_API unsigned FLAC__stream_decoder_get_blocksize(const FLAC__StreamDecoder *decoder);
680
/** Initialize the decoder instance.
681
* Should be called after FLAC__stream_decoder_new() and
682
* FLAC__stream_decoder_set_*() but before any of the
683
* FLAC__stream_decoder_process_*() functions. Will set and return the
684
* decoder state, which will be FLAC__STREAM_DECODER_SEARCH_FOR_METADATA
685
* if initialization succeeded.
687
* \param decoder An uninitialized decoder instance.
689
* \code decoder != NULL \endcode
690
* \retval FLAC__StreamDecoderState
691
* \c FLAC__STREAM_DECODER_SEARCH_FOR_METADATA if initialization was
692
* successful; see FLAC__StreamDecoderState for the meanings of other
695
FLAC_API FLAC__StreamDecoderState FLAC__stream_decoder_init(FLAC__StreamDecoder *decoder);
987
/** Returns the decoder's current read position within the stream.
988
* The position is the byte offset from the start of the stream.
989
* Bytes before this position have been fully decoded. Note that
990
* there may still be undecoded bytes in the decoder's read FIFO.
991
* The returned position is correct even after a seek.
993
* \warning This function currently only works for native FLAC,
994
* not Ogg FLAC streams.
996
* \param decoder A decoder instance to query.
997
* \param position Address at which to return the desired position.
999
* \code decoder != NULL \endcode
1000
* \code position != NULL \endcode
1001
* \retval FLAC__bool
1002
* \c true if successful, \c false if the stream is not native FLAC,
1003
* or there was an error from the 'tell' callback or it returned
1004
* \c FLAC__STREAM_DECODER_TELL_STATUS_UNSUPPORTED.
1006
FLAC_API FLAC__bool FLAC__stream_decoder_get_decode_position(const FLAC__StreamDecoder *decoder, FLAC__uint64 *position);
1008
/** Initialize the decoder instance to decode native FLAC streams.
1010
* This flavor of initialization sets up the decoder to decode from a
1011
* native FLAC stream. I/O is performed via callbacks to the client.
1012
* For decoding from a plain file via filename or open FILE*,
1013
* FLAC__stream_decoder_init_file() and FLAC__stream_decoder_init_FILE()
1014
* provide a simpler interface.
1016
* This function should be called after FLAC__stream_decoder_new() and
1017
* FLAC__stream_decoder_set_*() but before any of the
1018
* FLAC__stream_decoder_process_*() functions. Will set and return the
1019
* decoder state, which will be FLAC__STREAM_DECODER_SEARCH_FOR_METADATA
1020
* if initialization succeeded.
1022
* \param decoder An uninitialized decoder instance.
1023
* \param read_callback See FLAC__StreamDecoderReadCallback. This
1024
* pointer must not be \c NULL.
1025
* \param seek_callback See FLAC__StreamDecoderSeekCallback. This
1026
* pointer may be \c NULL if seeking is not
1027
* supported. If \a seek_callback is not \c NULL then a
1028
* \a tell_callback, \a length_callback, and \a eof_callback must also be supplied.
1029
* Alternatively, a dummy seek callback that just
1030
* returns \c FLAC__STREAM_DECODER_SEEK_STATUS_UNSUPPORTED
1031
* may also be supplied, all though this is slightly
1032
* less efficient for the decoder.
1033
* \param tell_callback See FLAC__StreamDecoderTellCallback. This
1034
* pointer may be \c NULL if not supported by the client. If
1035
* \a seek_callback is not \c NULL then a
1036
* \a tell_callback must also be supplied.
1037
* Alternatively, a dummy tell callback that just
1038
* returns \c FLAC__STREAM_DECODER_TELL_STATUS_UNSUPPORTED
1039
* may also be supplied, all though this is slightly
1040
* less efficient for the decoder.
1041
* \param length_callback See FLAC__StreamDecoderLengthCallback. This
1042
* pointer may be \c NULL if not supported by the client. If
1043
* \a seek_callback is not \c NULL then a
1044
* \a length_callback must also be supplied.
1045
* Alternatively, a dummy length callback that just
1046
* returns \c FLAC__STREAM_DECODER_LENGTH_STATUS_UNSUPPORTED
1047
* may also be supplied, all though this is slightly
1048
* less efficient for the decoder.
1049
* \param eof_callback See FLAC__StreamDecoderEofCallback. This
1050
* pointer may be \c NULL if not supported by the client. If
1051
* \a seek_callback is not \c NULL then a
1052
* \a eof_callback must also be supplied.
1053
* Alternatively, a dummy length callback that just
1055
* may also be supplied, all though this is slightly
1056
* less efficient for the decoder.
1057
* \param write_callback See FLAC__StreamDecoderWriteCallback. This
1058
* pointer must not be \c NULL.
1059
* \param metadata_callback See FLAC__StreamDecoderMetadataCallback. This
1060
* pointer may be \c NULL if the callback is not
1062
* \param error_callback See FLAC__StreamDecoderErrorCallback. This
1063
* pointer must not be \c NULL.
1064
* \param client_data This value will be supplied to callbacks in their
1065
* \a client_data argument.
1067
* \code decoder != NULL \endcode
1068
* \retval FLAC__StreamDecoderInitStatus
1069
* \c FLAC__STREAM_DECODER_INIT_STATUS_OK if initialization was successful;
1070
* see FLAC__StreamDecoderInitStatus for the meanings of other return values.
1072
FLAC_API FLAC__StreamDecoderInitStatus FLAC__stream_decoder_init_stream(
1073
FLAC__StreamDecoder *decoder,
1074
FLAC__StreamDecoderReadCallback read_callback,
1075
FLAC__StreamDecoderSeekCallback seek_callback,
1076
FLAC__StreamDecoderTellCallback tell_callback,
1077
FLAC__StreamDecoderLengthCallback length_callback,
1078
FLAC__StreamDecoderEofCallback eof_callback,
1079
FLAC__StreamDecoderWriteCallback write_callback,
1080
FLAC__StreamDecoderMetadataCallback metadata_callback,
1081
FLAC__StreamDecoderErrorCallback error_callback,
1085
/** Initialize the decoder instance to decode Ogg FLAC streams.
1087
* This flavor of initialization sets up the decoder to decode from a
1088
* FLAC stream in an Ogg container. I/O is performed via callbacks to the
1089
* client. For decoding from a plain file via filename or open FILE*,
1090
* FLAC__stream_decoder_init_ogg_file() and FLAC__stream_decoder_init_ogg_FILE()
1091
* provide a simpler interface.
1093
* This function should be called after FLAC__stream_decoder_new() and
1094
* FLAC__stream_decoder_set_*() but before any of the
1095
* FLAC__stream_decoder_process_*() functions. Will set and return the
1096
* decoder state, which will be FLAC__STREAM_DECODER_SEARCH_FOR_METADATA
1097
* if initialization succeeded.
1099
* \note Support for Ogg FLAC in the library is optional. If this
1100
* library has been built without support for Ogg FLAC, this function
1101
* will return \c FLAC__STREAM_DECODER_INIT_STATUS_UNSUPPORTED_CONTAINER.
1103
* \param decoder An uninitialized decoder instance.
1104
* \param read_callback See FLAC__StreamDecoderReadCallback. This
1105
* pointer must not be \c NULL.
1106
* \param seek_callback See FLAC__StreamDecoderSeekCallback. This
1107
* pointer may be \c NULL if seeking is not
1108
* supported. If \a seek_callback is not \c NULL then a
1109
* \a tell_callback, \a length_callback, and \a eof_callback must also be supplied.
1110
* Alternatively, a dummy seek callback that just
1111
* returns \c FLAC__STREAM_DECODER_SEEK_STATUS_UNSUPPORTED
1112
* may also be supplied, all though this is slightly
1113
* less efficient for the decoder.
1114
* \param tell_callback See FLAC__StreamDecoderTellCallback. This
1115
* pointer may be \c NULL if not supported by the client. If
1116
* \a seek_callback is not \c NULL then a
1117
* \a tell_callback must also be supplied.
1118
* Alternatively, a dummy tell callback that just
1119
* returns \c FLAC__STREAM_DECODER_TELL_STATUS_UNSUPPORTED
1120
* may also be supplied, all though this is slightly
1121
* less efficient for the decoder.
1122
* \param length_callback See FLAC__StreamDecoderLengthCallback. This
1123
* pointer may be \c NULL if not supported by the client. If
1124
* \a seek_callback is not \c NULL then a
1125
* \a length_callback must also be supplied.
1126
* Alternatively, a dummy length callback that just
1127
* returns \c FLAC__STREAM_DECODER_LENGTH_STATUS_UNSUPPORTED
1128
* may also be supplied, all though this is slightly
1129
* less efficient for the decoder.
1130
* \param eof_callback See FLAC__StreamDecoderEofCallback. This
1131
* pointer may be \c NULL if not supported by the client. If
1132
* \a seek_callback is not \c NULL then a
1133
* \a eof_callback must also be supplied.
1134
* Alternatively, a dummy length callback that just
1136
* may also be supplied, all though this is slightly
1137
* less efficient for the decoder.
1138
* \param write_callback See FLAC__StreamDecoderWriteCallback. This
1139
* pointer must not be \c NULL.
1140
* \param metadata_callback See FLAC__StreamDecoderMetadataCallback. This
1141
* pointer may be \c NULL if the callback is not
1143
* \param error_callback See FLAC__StreamDecoderErrorCallback. This
1144
* pointer must not be \c NULL.
1145
* \param client_data This value will be supplied to callbacks in their
1146
* \a client_data argument.
1148
* \code decoder != NULL \endcode
1149
* \retval FLAC__StreamDecoderInitStatus
1150
* \c FLAC__STREAM_DECODER_INIT_STATUS_OK if initialization was successful;
1151
* see FLAC__StreamDecoderInitStatus for the meanings of other return values.
1153
FLAC_API FLAC__StreamDecoderInitStatus FLAC__stream_decoder_init_ogg_stream(
1154
FLAC__StreamDecoder *decoder,
1155
FLAC__StreamDecoderReadCallback read_callback,
1156
FLAC__StreamDecoderSeekCallback seek_callback,
1157
FLAC__StreamDecoderTellCallback tell_callback,
1158
FLAC__StreamDecoderLengthCallback length_callback,
1159
FLAC__StreamDecoderEofCallback eof_callback,
1160
FLAC__StreamDecoderWriteCallback write_callback,
1161
FLAC__StreamDecoderMetadataCallback metadata_callback,
1162
FLAC__StreamDecoderErrorCallback error_callback,
1166
/** Initialize the decoder instance to decode native FLAC files.
1168
* This flavor of initialization sets up the decoder to decode from a
1169
* plain native FLAC file. For non-stdio streams, you must use
1170
* FLAC__stream_decoder_init_stream() and provide callbacks for the I/O.
1172
* This function should be called after FLAC__stream_decoder_new() and
1173
* FLAC__stream_decoder_set_*() but before any of the
1174
* FLAC__stream_decoder_process_*() functions. Will set and return the
1175
* decoder state, which will be FLAC__STREAM_DECODER_SEARCH_FOR_METADATA
1176
* if initialization succeeded.
1178
* \param decoder An uninitialized decoder instance.
1179
* \param file An open FLAC file. The file should have been
1180
* opened with mode \c "rb" and rewound. The file
1181
* becomes owned by the decoder and should not be
1182
* manipulated by the client while decoding.
1183
* Unless \a file is \c stdin, it will be closed
1184
* when FLAC__stream_decoder_finish() is called.
1185
* Note however that seeking will not work when
1186
* decoding from \c stdout since it is not seekable.
1187
* \param write_callback See FLAC__StreamDecoderWriteCallback. This
1188
* pointer must not be \c NULL.
1189
* \param metadata_callback See FLAC__StreamDecoderMetadataCallback. This
1190
* pointer may be \c NULL if the callback is not
1192
* \param error_callback See FLAC__StreamDecoderErrorCallback. This
1193
* pointer must not be \c NULL.
1194
* \param client_data This value will be supplied to callbacks in their
1195
* \a client_data argument.
1197
* \code decoder != NULL \endcode
1198
* \code file != NULL \endcode
1199
* \retval FLAC__StreamDecoderInitStatus
1200
* \c FLAC__STREAM_DECODER_INIT_STATUS_OK if initialization was successful;
1201
* see FLAC__StreamDecoderInitStatus for the meanings of other return values.
1203
FLAC_API FLAC__StreamDecoderInitStatus FLAC__stream_decoder_init_FILE(
1204
FLAC__StreamDecoder *decoder,
1206
FLAC__StreamDecoderWriteCallback write_callback,
1207
FLAC__StreamDecoderMetadataCallback metadata_callback,
1208
FLAC__StreamDecoderErrorCallback error_callback,
1212
/** Initialize the decoder instance to decode Ogg FLAC files.
1214
* This flavor of initialization sets up the decoder to decode from a
1215
* plain Ogg FLAC file. For non-stdio streams, you must use
1216
* FLAC__stream_decoder_init_ogg_stream() and provide callbacks for the I/O.
1218
* This function should be called after FLAC__stream_decoder_new() and
1219
* FLAC__stream_decoder_set_*() but before any of the
1220
* FLAC__stream_decoder_process_*() functions. Will set and return the
1221
* decoder state, which will be FLAC__STREAM_DECODER_SEARCH_FOR_METADATA
1222
* if initialization succeeded.
1224
* \note Support for Ogg FLAC in the library is optional. If this
1225
* library has been built without support for Ogg FLAC, this function
1226
* will return \c FLAC__STREAM_DECODER_INIT_STATUS_UNSUPPORTED_CONTAINER.
1228
* \param decoder An uninitialized decoder instance.
1229
* \param file An open FLAC file. The file should have been
1230
* opened with mode \c "rb" and rewound. The file
1231
* becomes owned by the decoder and should not be
1232
* manipulated by the client while decoding.
1233
* Unless \a file is \c stdin, it will be closed
1234
* when FLAC__stream_decoder_finish() is called.
1235
* Note however that seeking will not work when
1236
* decoding from \c stdout since it is not seekable.
1237
* \param write_callback See FLAC__StreamDecoderWriteCallback. This
1238
* pointer must not be \c NULL.
1239
* \param metadata_callback See FLAC__StreamDecoderMetadataCallback. This
1240
* pointer may be \c NULL if the callback is not
1242
* \param error_callback See FLAC__StreamDecoderErrorCallback. This
1243
* pointer must not be \c NULL.
1244
* \param client_data This value will be supplied to callbacks in their
1245
* \a client_data argument.
1247
* \code decoder != NULL \endcode
1248
* \code file != NULL \endcode
1249
* \retval FLAC__StreamDecoderInitStatus
1250
* \c FLAC__STREAM_DECODER_INIT_STATUS_OK if initialization was successful;
1251
* see FLAC__StreamDecoderInitStatus for the meanings of other return values.
1253
FLAC_API FLAC__StreamDecoderInitStatus FLAC__stream_decoder_init_ogg_FILE(
1254
FLAC__StreamDecoder *decoder,
1256
FLAC__StreamDecoderWriteCallback write_callback,
1257
FLAC__StreamDecoderMetadataCallback metadata_callback,
1258
FLAC__StreamDecoderErrorCallback error_callback,
1262
/** Initialize the decoder instance to decode native FLAC files.
1264
* This flavor of initialization sets up the decoder to decode from a plain
1265
* native FLAC file. If POSIX fopen() semantics are not sufficient, (for
1266
* example, with Unicode filenames on Windows), you must use
1267
* FLAC__stream_decoder_init_FILE(), or FLAC__stream_decoder_init_stream()
1268
* and provide callbacks for the I/O.
1270
* This function should be called after FLAC__stream_decoder_new() and
1271
* FLAC__stream_decoder_set_*() but before any of the
1272
* FLAC__stream_decoder_process_*() functions. Will set and return the
1273
* decoder state, which will be FLAC__STREAM_DECODER_SEARCH_FOR_METADATA
1274
* if initialization succeeded.
1276
* \param decoder An uninitialized decoder instance.
1277
* \param filename The name of the file to decode from. The file will
1278
* be opened with fopen(). Use \c NULL to decode from
1279
* \c stdin. Note that \c stdin is not seekable.
1280
* \param write_callback See FLAC__StreamDecoderWriteCallback. This
1281
* pointer must not be \c NULL.
1282
* \param metadata_callback See FLAC__StreamDecoderMetadataCallback. This
1283
* pointer may be \c NULL if the callback is not
1285
* \param error_callback See FLAC__StreamDecoderErrorCallback. This
1286
* pointer must not be \c NULL.
1287
* \param client_data This value will be supplied to callbacks in their
1288
* \a client_data argument.
1290
* \code decoder != NULL \endcode
1291
* \retval FLAC__StreamDecoderInitStatus
1292
* \c FLAC__STREAM_DECODER_INIT_STATUS_OK if initialization was successful;
1293
* see FLAC__StreamDecoderInitStatus for the meanings of other return values.
1295
FLAC_API FLAC__StreamDecoderInitStatus FLAC__stream_decoder_init_file(
1296
FLAC__StreamDecoder *decoder,
1297
const char *filename,
1298
FLAC__StreamDecoderWriteCallback write_callback,
1299
FLAC__StreamDecoderMetadataCallback metadata_callback,
1300
FLAC__StreamDecoderErrorCallback error_callback,
1304
/** Initialize the decoder instance to decode Ogg FLAC files.
1306
* This flavor of initialization sets up the decoder to decode from a plain
1307
* Ogg FLAC file. If POSIX fopen() semantics are not sufficient, (for
1308
* example, with Unicode filenames on Windows), you must use
1309
* FLAC__stream_decoder_init_ogg_FILE(), or FLAC__stream_decoder_init_ogg_stream()
1310
* and provide callbacks for the I/O.
1312
* This function should be called after FLAC__stream_decoder_new() and
1313
* FLAC__stream_decoder_set_*() but before any of the
1314
* FLAC__stream_decoder_process_*() functions. Will set and return the
1315
* decoder state, which will be FLAC__STREAM_DECODER_SEARCH_FOR_METADATA
1316
* if initialization succeeded.
1318
* \note Support for Ogg FLAC in the library is optional. If this
1319
* library has been built without support for Ogg FLAC, this function
1320
* will return \c FLAC__STREAM_DECODER_INIT_STATUS_UNSUPPORTED_CONTAINER.
1322
* \param decoder An uninitialized decoder instance.
1323
* \param filename The name of the file to decode from. The file will
1324
* be opened with fopen(). Use \c NULL to decode from
1325
* \c stdin. Note that \c stdin is not seekable.
1326
* \param write_callback See FLAC__StreamDecoderWriteCallback. This
1327
* pointer must not be \c NULL.
1328
* \param metadata_callback See FLAC__StreamDecoderMetadataCallback. This
1329
* pointer may be \c NULL if the callback is not
1331
* \param error_callback See FLAC__StreamDecoderErrorCallback. This
1332
* pointer must not be \c NULL.
1333
* \param client_data This value will be supplied to callbacks in their
1334
* \a client_data argument.
1336
* \code decoder != NULL \endcode
1337
* \retval FLAC__StreamDecoderInitStatus
1338
* \c FLAC__STREAM_DECODER_INIT_STATUS_OK if initialization was successful;
1339
* see FLAC__StreamDecoderInitStatus for the meanings of other return values.
1341
FLAC_API FLAC__StreamDecoderInitStatus FLAC__stream_decoder_init_ogg_file(
1342
FLAC__StreamDecoder *decoder,
1343
const char *filename,
1344
FLAC__StreamDecoderWriteCallback write_callback,
1345
FLAC__StreamDecoderMetadataCallback metadata_callback,
1346
FLAC__StreamDecoderErrorCallback error_callback,
697
1350
/** Finish the decoding process.
698
1351
* Flushes the decoding buffer, releases resources, resets the decoder