1c74663799493f2b1e6123c18def94295d0afab7Kenny Root/* libFLAC - Free Lossless Audio Codec library
2c74663799493f2b1e6123c18def94295d0afab7Kenny Root * Copyright (C) 2000,2001,2002,2003,2004,2005,2006,2007  Josh Coalson
3c74663799493f2b1e6123c18def94295d0afab7Kenny Root *
4c74663799493f2b1e6123c18def94295d0afab7Kenny Root * Redistribution and use in source and binary forms, with or without
5c74663799493f2b1e6123c18def94295d0afab7Kenny Root * modification, are permitted provided that the following conditions
6c74663799493f2b1e6123c18def94295d0afab7Kenny Root * are met:
7c74663799493f2b1e6123c18def94295d0afab7Kenny Root *
8c74663799493f2b1e6123c18def94295d0afab7Kenny Root * - Redistributions of source code must retain the above copyright
9c74663799493f2b1e6123c18def94295d0afab7Kenny Root * notice, this list of conditions and the following disclaimer.
10c74663799493f2b1e6123c18def94295d0afab7Kenny Root *
11c74663799493f2b1e6123c18def94295d0afab7Kenny Root * - Redistributions in binary form must reproduce the above copyright
12c74663799493f2b1e6123c18def94295d0afab7Kenny Root * notice, this list of conditions and the following disclaimer in the
13c74663799493f2b1e6123c18def94295d0afab7Kenny Root * documentation and/or other materials provided with the distribution.
14c74663799493f2b1e6123c18def94295d0afab7Kenny Root *
15c74663799493f2b1e6123c18def94295d0afab7Kenny Root * - Neither the name of the Xiph.org Foundation nor the names of its
16c74663799493f2b1e6123c18def94295d0afab7Kenny Root * contributors may be used to endorse or promote products derived from
17c74663799493f2b1e6123c18def94295d0afab7Kenny Root * this software without specific prior written permission.
18c74663799493f2b1e6123c18def94295d0afab7Kenny Root *
19c74663799493f2b1e6123c18def94295d0afab7Kenny Root * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
20c74663799493f2b1e6123c18def94295d0afab7Kenny Root * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
21c74663799493f2b1e6123c18def94295d0afab7Kenny Root * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
22c74663799493f2b1e6123c18def94295d0afab7Kenny Root * A PARTICULAR PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE FOUNDATION OR
23c74663799493f2b1e6123c18def94295d0afab7Kenny Root * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
24c74663799493f2b1e6123c18def94295d0afab7Kenny Root * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
25c74663799493f2b1e6123c18def94295d0afab7Kenny Root * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
26c74663799493f2b1e6123c18def94295d0afab7Kenny Root * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
27c74663799493f2b1e6123c18def94295d0afab7Kenny Root * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
28c74663799493f2b1e6123c18def94295d0afab7Kenny Root * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
29c74663799493f2b1e6123c18def94295d0afab7Kenny Root * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
30c74663799493f2b1e6123c18def94295d0afab7Kenny Root */
31c74663799493f2b1e6123c18def94295d0afab7Kenny Root
32c74663799493f2b1e6123c18def94295d0afab7Kenny Root#ifndef FLAC__ALL_H
33c74663799493f2b1e6123c18def94295d0afab7Kenny Root#define FLAC__ALL_H
34c74663799493f2b1e6123c18def94295d0afab7Kenny Root
35c74663799493f2b1e6123c18def94295d0afab7Kenny Root#include "export.h"
36c74663799493f2b1e6123c18def94295d0afab7Kenny Root
37c74663799493f2b1e6123c18def94295d0afab7Kenny Root#include "assert.h"
38c74663799493f2b1e6123c18def94295d0afab7Kenny Root#include "callback.h"
39c74663799493f2b1e6123c18def94295d0afab7Kenny Root#include "format.h"
40c74663799493f2b1e6123c18def94295d0afab7Kenny Root#include "metadata.h"
41c74663799493f2b1e6123c18def94295d0afab7Kenny Root#include "ordinals.h"
42c74663799493f2b1e6123c18def94295d0afab7Kenny Root#include "stream_decoder.h"
43c74663799493f2b1e6123c18def94295d0afab7Kenny Root#include "stream_encoder.h"
44c74663799493f2b1e6123c18def94295d0afab7Kenny Root
45c74663799493f2b1e6123c18def94295d0afab7Kenny Root/** \mainpage
46c74663799493f2b1e6123c18def94295d0afab7Kenny Root *
47c74663799493f2b1e6123c18def94295d0afab7Kenny Root * \section intro Introduction
48c74663799493f2b1e6123c18def94295d0afab7Kenny Root *
49c74663799493f2b1e6123c18def94295d0afab7Kenny Root * This is the documentation for the FLAC C and C++ APIs.  It is
50c74663799493f2b1e6123c18def94295d0afab7Kenny Root * highly interconnected; this introduction should give you a top
51c74663799493f2b1e6123c18def94295d0afab7Kenny Root * level idea of the structure and how to find the information you
52c74663799493f2b1e6123c18def94295d0afab7Kenny Root * need.  As a prerequisite you should have at least a basic
53c74663799493f2b1e6123c18def94295d0afab7Kenny Root * knowledge of the FLAC format, documented
54c74663799493f2b1e6123c18def94295d0afab7Kenny Root * <A HREF="../format.html">here</A>.
55c74663799493f2b1e6123c18def94295d0afab7Kenny Root *
56c74663799493f2b1e6123c18def94295d0afab7Kenny Root * \section c_api FLAC C API
57c74663799493f2b1e6123c18def94295d0afab7Kenny Root *
58c74663799493f2b1e6123c18def94295d0afab7Kenny Root * The FLAC C API is the interface to libFLAC, a set of structures
59c74663799493f2b1e6123c18def94295d0afab7Kenny Root * describing the components of FLAC streams, and functions for
60c74663799493f2b1e6123c18def94295d0afab7Kenny Root * encoding and decoding streams, as well as manipulating FLAC
61c74663799493f2b1e6123c18def94295d0afab7Kenny Root * metadata in files.  The public include files will be installed
62c74663799493f2b1e6123c18def94295d0afab7Kenny Root * in your include area (for example /usr/include/FLAC/...).
63c74663799493f2b1e6123c18def94295d0afab7Kenny Root *
64c74663799493f2b1e6123c18def94295d0afab7Kenny Root * By writing a little code and linking against libFLAC, it is
65c74663799493f2b1e6123c18def94295d0afab7Kenny Root * relatively easy to add FLAC support to another program.  The
66c74663799493f2b1e6123c18def94295d0afab7Kenny Root * library is licensed under <A HREF="../license.html">Xiph's BSD license</A>.
67c74663799493f2b1e6123c18def94295d0afab7Kenny Root * Complete source code of libFLAC as well as the command-line
68c74663799493f2b1e6123c18def94295d0afab7Kenny Root * encoder and plugins is available and is a useful source of
69c74663799493f2b1e6123c18def94295d0afab7Kenny Root * examples.
70c74663799493f2b1e6123c18def94295d0afab7Kenny Root *
71c74663799493f2b1e6123c18def94295d0afab7Kenny Root * Aside from encoders and decoders, libFLAC provides a powerful
72c74663799493f2b1e6123c18def94295d0afab7Kenny Root * metadata interface for manipulating metadata in FLAC files.  It
73c74663799493f2b1e6123c18def94295d0afab7Kenny Root * allows the user to add, delete, and modify FLAC metadata blocks
74c74663799493f2b1e6123c18def94295d0afab7Kenny Root * and it can automatically take advantage of PADDING blocks to avoid
75c74663799493f2b1e6123c18def94295d0afab7Kenny Root * rewriting the entire FLAC file when changing the size of the
76c74663799493f2b1e6123c18def94295d0afab7Kenny Root * metadata.
77c74663799493f2b1e6123c18def94295d0afab7Kenny Root *
78c74663799493f2b1e6123c18def94295d0afab7Kenny Root * libFLAC usually only requires the standard C library and C math
79c74663799493f2b1e6123c18def94295d0afab7Kenny Root * library. In particular, threading is not used so there is no
80c74663799493f2b1e6123c18def94295d0afab7Kenny Root * dependency on a thread library. However, libFLAC does not use
81c74663799493f2b1e6123c18def94295d0afab7Kenny Root * global variables and should be thread-safe.
82c74663799493f2b1e6123c18def94295d0afab7Kenny Root *
83c74663799493f2b1e6123c18def94295d0afab7Kenny Root * libFLAC also supports encoding to and decoding from Ogg FLAC.
84c74663799493f2b1e6123c18def94295d0afab7Kenny Root * However the metadata editing interfaces currently have limited
85c74663799493f2b1e6123c18def94295d0afab7Kenny Root * read-only support for Ogg FLAC files.
86c74663799493f2b1e6123c18def94295d0afab7Kenny Root *
87c74663799493f2b1e6123c18def94295d0afab7Kenny Root * \section cpp_api FLAC C++ API
88c74663799493f2b1e6123c18def94295d0afab7Kenny Root *
89c74663799493f2b1e6123c18def94295d0afab7Kenny Root * The FLAC C++ API is a set of classes that encapsulate the
90c74663799493f2b1e6123c18def94295d0afab7Kenny Root * structures and functions in libFLAC.  They provide slightly more
91c74663799493f2b1e6123c18def94295d0afab7Kenny Root * functionality with respect to metadata but are otherwise
92c74663799493f2b1e6123c18def94295d0afab7Kenny Root * equivalent.  For the most part, they share the same usage as
93c74663799493f2b1e6123c18def94295d0afab7Kenny Root * their counterparts in libFLAC, and the FLAC C API documentation
94c74663799493f2b1e6123c18def94295d0afab7Kenny Root * can be used as a supplement.  The public include files
95c74663799493f2b1e6123c18def94295d0afab7Kenny Root * for the C++ API will be installed in your include area (for
96c74663799493f2b1e6123c18def94295d0afab7Kenny Root * example /usr/include/FLAC++/...).
97c74663799493f2b1e6123c18def94295d0afab7Kenny Root *
98c74663799493f2b1e6123c18def94295d0afab7Kenny Root * libFLAC++ is also licensed under
99c74663799493f2b1e6123c18def94295d0afab7Kenny Root * <A HREF="../license.html">Xiph's BSD license</A>.
100c74663799493f2b1e6123c18def94295d0afab7Kenny Root *
101c74663799493f2b1e6123c18def94295d0afab7Kenny Root * \section getting_started Getting Started
102c74663799493f2b1e6123c18def94295d0afab7Kenny Root *
103c74663799493f2b1e6123c18def94295d0afab7Kenny Root * A good starting point for learning the API is to browse through
104c74663799493f2b1e6123c18def94295d0afab7Kenny Root * the <A HREF="modules.html">modules</A>.  Modules are logical
105c74663799493f2b1e6123c18def94295d0afab7Kenny Root * groupings of related functions or classes, which correspond roughly
106c74663799493f2b1e6123c18def94295d0afab7Kenny Root * to header files or sections of header files.  Each module includes a
107c74663799493f2b1e6123c18def94295d0afab7Kenny Root * detailed description of the general usage of its functions or
108c74663799493f2b1e6123c18def94295d0afab7Kenny Root * classes.
109c74663799493f2b1e6123c18def94295d0afab7Kenny Root *
110c74663799493f2b1e6123c18def94295d0afab7Kenny Root * From there you can go on to look at the documentation of
111c74663799493f2b1e6123c18def94295d0afab7Kenny Root * individual functions.  You can see different views of the individual
112c74663799493f2b1e6123c18def94295d0afab7Kenny Root * functions through the links in top bar across this page.
113c74663799493f2b1e6123c18def94295d0afab7Kenny Root *
114c74663799493f2b1e6123c18def94295d0afab7Kenny Root * If you prefer a more hands-on approach, you can jump right to some
115c74663799493f2b1e6123c18def94295d0afab7Kenny Root * <A HREF="../documentation_example_code.html">example code</A>.
116c74663799493f2b1e6123c18def94295d0afab7Kenny Root *
117c74663799493f2b1e6123c18def94295d0afab7Kenny Root * \section porting_guide Porting Guide
118c74663799493f2b1e6123c18def94295d0afab7Kenny Root *
119c74663799493f2b1e6123c18def94295d0afab7Kenny Root * Starting with FLAC 1.1.3 a \link porting Porting Guide \endlink
120c74663799493f2b1e6123c18def94295d0afab7Kenny Root * has been introduced which gives detailed instructions on how to
121c74663799493f2b1e6123c18def94295d0afab7Kenny Root * port your code to newer versions of FLAC.
122c74663799493f2b1e6123c18def94295d0afab7Kenny Root *
123c74663799493f2b1e6123c18def94295d0afab7Kenny Root * \section embedded_developers Embedded Developers
124c74663799493f2b1e6123c18def94295d0afab7Kenny Root *
125c74663799493f2b1e6123c18def94295d0afab7Kenny Root * libFLAC has grown larger over time as more functionality has been
126c74663799493f2b1e6123c18def94295d0afab7Kenny Root * included, but much of it may be unnecessary for a particular embedded
127c74663799493f2b1e6123c18def94295d0afab7Kenny Root * implementation.  Unused parts may be pruned by some simple editing of
128c74663799493f2b1e6123c18def94295d0afab7Kenny Root * src/libFLAC/Makefile.am.  In general, the decoders, encoders, and
129c74663799493f2b1e6123c18def94295d0afab7Kenny Root * metadata interface are all independent from each other.
130c74663799493f2b1e6123c18def94295d0afab7Kenny Root *
131c74663799493f2b1e6123c18def94295d0afab7Kenny Root * It is easiest to just describe the dependencies:
132c74663799493f2b1e6123c18def94295d0afab7Kenny Root *
133c74663799493f2b1e6123c18def94295d0afab7Kenny Root * - All modules depend on the \link flac_format Format \endlink module.
134c74663799493f2b1e6123c18def94295d0afab7Kenny Root * - The decoders and encoders depend on the bitbuffer.
135c74663799493f2b1e6123c18def94295d0afab7Kenny Root * - The decoder is independent of the encoder.  The encoder uses the
136c74663799493f2b1e6123c18def94295d0afab7Kenny Root *   decoder because of the verify feature, but this can be removed if
137c74663799493f2b1e6123c18def94295d0afab7Kenny Root *   not needed.
138c74663799493f2b1e6123c18def94295d0afab7Kenny Root * - Parts of the metadata interface require the stream decoder (but not
139c74663799493f2b1e6123c18def94295d0afab7Kenny Root *   the encoder).
140c74663799493f2b1e6123c18def94295d0afab7Kenny Root * - Ogg support is selectable through the compile time macro
141c74663799493f2b1e6123c18def94295d0afab7Kenny Root *   \c FLAC__HAS_OGG.
142c74663799493f2b1e6123c18def94295d0afab7Kenny Root *
143c74663799493f2b1e6123c18def94295d0afab7Kenny Root * For example, if your application only requires the stream decoder, no
144c74663799493f2b1e6123c18def94295d0afab7Kenny Root * encoder, and no metadata interface, you can remove the stream encoder
145c74663799493f2b1e6123c18def94295d0afab7Kenny Root * and the metadata interface, which will greatly reduce the size of the
146c74663799493f2b1e6123c18def94295d0afab7Kenny Root * library.
147c74663799493f2b1e6123c18def94295d0afab7Kenny Root *
148c74663799493f2b1e6123c18def94295d0afab7Kenny Root * Also, there are several places in the libFLAC code with comments marked
149c74663799493f2b1e6123c18def94295d0afab7Kenny Root * with "OPT:" where a #define can be changed to enable code that might be
150c74663799493f2b1e6123c18def94295d0afab7Kenny Root * faster on a specific platform.  Experimenting with these can yield faster
151c74663799493f2b1e6123c18def94295d0afab7Kenny Root * binaries.
152c74663799493f2b1e6123c18def94295d0afab7Kenny Root */
153c74663799493f2b1e6123c18def94295d0afab7Kenny Root
154c74663799493f2b1e6123c18def94295d0afab7Kenny Root/** \defgroup porting Porting Guide for New Versions
155c74663799493f2b1e6123c18def94295d0afab7Kenny Root *
156c74663799493f2b1e6123c18def94295d0afab7Kenny Root * This module describes differences in the library interfaces from
157c74663799493f2b1e6123c18def94295d0afab7Kenny Root * version to version.  It assists in the porting of code that uses
158c74663799493f2b1e6123c18def94295d0afab7Kenny Root * the libraries to newer versions of FLAC.
159c74663799493f2b1e6123c18def94295d0afab7Kenny Root *
160c74663799493f2b1e6123c18def94295d0afab7Kenny Root * One simple facility for making porting easier that has been added
161c74663799493f2b1e6123c18def94295d0afab7Kenny Root * in FLAC 1.1.3 is a set of \c #defines in \c export.h of each
162c74663799493f2b1e6123c18def94295d0afab7Kenny Root * library's includes (e.g. \c include/FLAC/export.h).  The
163c74663799493f2b1e6123c18def94295d0afab7Kenny Root * \c #defines mirror the libraries'
164c74663799493f2b1e6123c18def94295d0afab7Kenny Root * <A HREF="http://www.gnu.org/software/libtool/manual.html#Libtool-versioning">libtool version numbers</A>,
165c74663799493f2b1e6123c18def94295d0afab7Kenny Root * e.g. in libFLAC there are \c FLAC_API_VERSION_CURRENT,
166c74663799493f2b1e6123c18def94295d0afab7Kenny Root * \c FLAC_API_VERSION_REVISION, and \c FLAC_API_VERSION_AGE.
167c74663799493f2b1e6123c18def94295d0afab7Kenny Root * These can be used to support multiple versions of an API during the
168c74663799493f2b1e6123c18def94295d0afab7Kenny Root * transition phase, e.g.
169c74663799493f2b1e6123c18def94295d0afab7Kenny Root *
170c74663799493f2b1e6123c18def94295d0afab7Kenny Root * \code
171c74663799493f2b1e6123c18def94295d0afab7Kenny Root * #if !defined(FLAC_API_VERSION_CURRENT) || FLAC_API_VERSION_CURRENT <= 7
172c74663799493f2b1e6123c18def94295d0afab7Kenny Root *   legacy code
173c74663799493f2b1e6123c18def94295d0afab7Kenny Root * #else
174c74663799493f2b1e6123c18def94295d0afab7Kenny Root *   new code
175c74663799493f2b1e6123c18def94295d0afab7Kenny Root * #endif
176c74663799493f2b1e6123c18def94295d0afab7Kenny Root * \endcode
177c74663799493f2b1e6123c18def94295d0afab7Kenny Root *
178c74663799493f2b1e6123c18def94295d0afab7Kenny Root * The the source will work for multiple versions and the legacy code can
179c74663799493f2b1e6123c18def94295d0afab7Kenny Root * easily be removed when the transition is complete.
180c74663799493f2b1e6123c18def94295d0afab7Kenny Root *
181c74663799493f2b1e6123c18def94295d0afab7Kenny Root * Another available symbol is FLAC_API_SUPPORTS_OGG_FLAC (defined in
182c74663799493f2b1e6123c18def94295d0afab7Kenny Root * include/FLAC/export.h), which can be used to determine whether or not
183c74663799493f2b1e6123c18def94295d0afab7Kenny Root * the library has been compiled with support for Ogg FLAC.  This is
184c74663799493f2b1e6123c18def94295d0afab7Kenny Root * simpler than trying to call an Ogg init function and catching the
185c74663799493f2b1e6123c18def94295d0afab7Kenny Root * error.
186c74663799493f2b1e6123c18def94295d0afab7Kenny Root */
187c74663799493f2b1e6123c18def94295d0afab7Kenny Root
188c74663799493f2b1e6123c18def94295d0afab7Kenny Root/** \defgroup porting_1_1_2_to_1_1_3 Porting from FLAC 1.1.2 to 1.1.3
189c74663799493f2b1e6123c18def94295d0afab7Kenny Root *  \ingroup porting
190c74663799493f2b1e6123c18def94295d0afab7Kenny Root *
191c74663799493f2b1e6123c18def94295d0afab7Kenny Root *  \brief
192c74663799493f2b1e6123c18def94295d0afab7Kenny Root *  This module describes porting from FLAC 1.1.2 to FLAC 1.1.3.
193c74663799493f2b1e6123c18def94295d0afab7Kenny Root *
194c74663799493f2b1e6123c18def94295d0afab7Kenny Root * The main change between the APIs in 1.1.2 and 1.1.3 is that they have
195c74663799493f2b1e6123c18def94295d0afab7Kenny Root * been simplified.  First, libOggFLAC has been merged into libFLAC and
196c74663799493f2b1e6123c18def94295d0afab7Kenny Root * libOggFLAC++ has been merged into libFLAC++.  Second, both the three
197c74663799493f2b1e6123c18def94295d0afab7Kenny Root * decoding layers and three encoding layers have been merged into a
198c74663799493f2b1e6123c18def94295d0afab7Kenny Root * single stream decoder and stream encoder.  That is, the functionality
199c74663799493f2b1e6123c18def94295d0afab7Kenny Root * of FLAC__SeekableStreamDecoder and FLAC__FileDecoder has been merged
200c74663799493f2b1e6123c18def94295d0afab7Kenny Root * into FLAC__StreamDecoder, and FLAC__SeekableStreamEncoder and
201c74663799493f2b1e6123c18def94295d0afab7Kenny Root * FLAC__FileEncoder into FLAC__StreamEncoder.  Only the
202c74663799493f2b1e6123c18def94295d0afab7Kenny Root * FLAC__StreamDecoder and FLAC__StreamEncoder remain.  What this means
203c74663799493f2b1e6123c18def94295d0afab7Kenny Root * is there is now a single API that can be used to encode or decode
204c74663799493f2b1e6123c18def94295d0afab7Kenny Root * streams to/from native FLAC or Ogg FLAC and the single API can work
205c74663799493f2b1e6123c18def94295d0afab7Kenny Root * on both seekable and non-seekable streams.
206c74663799493f2b1e6123c18def94295d0afab7Kenny Root *
207c74663799493f2b1e6123c18def94295d0afab7Kenny Root * Instead of creating an encoder or decoder of a certain layer, now the
208c74663799493f2b1e6123c18def94295d0afab7Kenny Root * client will always create a FLAC__StreamEncoder or
209c74663799493f2b1e6123c18def94295d0afab7Kenny Root * FLAC__StreamDecoder.  The old layers are now differentiated by the
210c74663799493f2b1e6123c18def94295d0afab7Kenny Root * initialization function.  For example, for the decoder,
211c74663799493f2b1e6123c18def94295d0afab7Kenny Root * FLAC__stream_decoder_init() has been replaced by
212c74663799493f2b1e6123c18def94295d0afab7Kenny Root * FLAC__stream_decoder_init_stream().  This init function takes
213c74663799493f2b1e6123c18def94295d0afab7Kenny Root * callbacks for the I/O, and the seeking callbacks are optional.  This
214c74663799493f2b1e6123c18def94295d0afab7Kenny Root * allows the client to use the same object for seekable and
215c74663799493f2b1e6123c18def94295d0afab7Kenny Root * non-seekable streams.  For decoding a FLAC file directly, the client
216c74663799493f2b1e6123c18def94295d0afab7Kenny Root * can use FLAC__stream_decoder_init_file() and pass just a filename
217c74663799493f2b1e6123c18def94295d0afab7Kenny Root * and fewer callbacks; most of the other callbacks are supplied
218c74663799493f2b1e6123c18def94295d0afab7Kenny Root * internally.  For situations where fopen()ing by filename is not
219c74663799493f2b1e6123c18def94295d0afab7Kenny Root * possible (e.g. Unicode filenames on Windows) the client can instead
220c74663799493f2b1e6123c18def94295d0afab7Kenny Root * open the file itself and supply the FILE* to
221c74663799493f2b1e6123c18def94295d0afab7Kenny Root * FLAC__stream_decoder_init_FILE().  The init functions now returns a
222c74663799493f2b1e6123c18def94295d0afab7Kenny Root * FLAC__StreamDecoderInitStatus instead of FLAC__StreamDecoderState.
223c74663799493f2b1e6123c18def94295d0afab7Kenny Root * Since the callbacks and client data are now passed to the init
224c74663799493f2b1e6123c18def94295d0afab7Kenny Root * function, the FLAC__stream_decoder_set_*_callback() functions and
225c74663799493f2b1e6123c18def94295d0afab7Kenny Root * FLAC__stream_decoder_set_client_data() are no longer needed.  The
226c74663799493f2b1e6123c18def94295d0afab7Kenny Root * rest of the calls to the decoder are the same as before.
227c74663799493f2b1e6123c18def94295d0afab7Kenny Root *
228c74663799493f2b1e6123c18def94295d0afab7Kenny Root * There are counterpart init functions for Ogg FLAC, e.g.
229c74663799493f2b1e6123c18def94295d0afab7Kenny Root * FLAC__stream_decoder_init_ogg_stream().  All the rest of the calls
230c74663799493f2b1e6123c18def94295d0afab7Kenny Root * and callbacks are the same as for native FLAC.
231c74663799493f2b1e6123c18def94295d0afab7Kenny Root *
232c74663799493f2b1e6123c18def94295d0afab7Kenny Root * As an example, in FLAC 1.1.2 a seekable stream decoder would have
233c74663799493f2b1e6123c18def94295d0afab7Kenny Root * been set up like so:
234c74663799493f2b1e6123c18def94295d0afab7Kenny Root *
235c74663799493f2b1e6123c18def94295d0afab7Kenny Root * \code
236c74663799493f2b1e6123c18def94295d0afab7Kenny Root * FLAC__SeekableStreamDecoder *decoder = FLAC__seekable_stream_decoder_new();
237c74663799493f2b1e6123c18def94295d0afab7Kenny Root * if(decoder == NULL) do_something;
238c74663799493f2b1e6123c18def94295d0afab7Kenny Root * FLAC__seekable_stream_decoder_set_md5_checking(decoder, true);
239c74663799493f2b1e6123c18def94295d0afab7Kenny Root * [... other settings ...]
240c74663799493f2b1e6123c18def94295d0afab7Kenny Root * FLAC__seekable_stream_decoder_set_read_callback(decoder, my_read_callback);
241c74663799493f2b1e6123c18def94295d0afab7Kenny Root * FLAC__seekable_stream_decoder_set_seek_callback(decoder, my_seek_callback);
242c74663799493f2b1e6123c18def94295d0afab7Kenny Root * FLAC__seekable_stream_decoder_set_tell_callback(decoder, my_tell_callback);
243c74663799493f2b1e6123c18def94295d0afab7Kenny Root * FLAC__seekable_stream_decoder_set_length_callback(decoder, my_length_callback);
244c74663799493f2b1e6123c18def94295d0afab7Kenny Root * FLAC__seekable_stream_decoder_set_eof_callback(decoder, my_eof_callback);
245c74663799493f2b1e6123c18def94295d0afab7Kenny Root * FLAC__seekable_stream_decoder_set_write_callback(decoder, my_write_callback);
246c74663799493f2b1e6123c18def94295d0afab7Kenny Root * FLAC__seekable_stream_decoder_set_metadata_callback(decoder, my_metadata_callback);
247c74663799493f2b1e6123c18def94295d0afab7Kenny Root * FLAC__seekable_stream_decoder_set_error_callback(decoder, my_error_callback);
248c74663799493f2b1e6123c18def94295d0afab7Kenny Root * FLAC__seekable_stream_decoder_set_client_data(decoder, my_client_data);
249c74663799493f2b1e6123c18def94295d0afab7Kenny Root * if(FLAC__seekable_stream_decoder_init(decoder) != FLAC__SEEKABLE_STREAM_DECODER_OK) do_something;
250c74663799493f2b1e6123c18def94295d0afab7Kenny Root * \endcode
251c74663799493f2b1e6123c18def94295d0afab7Kenny Root *
252c74663799493f2b1e6123c18def94295d0afab7Kenny Root * In FLAC 1.1.3 it is like this:
253c74663799493f2b1e6123c18def94295d0afab7Kenny Root *
254c74663799493f2b1e6123c18def94295d0afab7Kenny Root * \code
255c74663799493f2b1e6123c18def94295d0afab7Kenny Root * FLAC__StreamDecoder *decoder = FLAC__stream_decoder_new();
256c74663799493f2b1e6123c18def94295d0afab7Kenny Root * if(decoder == NULL) do_something;
257c74663799493f2b1e6123c18def94295d0afab7Kenny Root * FLAC__stream_decoder_set_md5_checking(decoder, true);
258c74663799493f2b1e6123c18def94295d0afab7Kenny Root * [... other settings ...]
259c74663799493f2b1e6123c18def94295d0afab7Kenny Root * if(FLAC__stream_decoder_init_stream(
260c74663799493f2b1e6123c18def94295d0afab7Kenny Root *   decoder,
261c74663799493f2b1e6123c18def94295d0afab7Kenny Root *   my_read_callback,
262c74663799493f2b1e6123c18def94295d0afab7Kenny Root *   my_seek_callback,      // or NULL
263c74663799493f2b1e6123c18def94295d0afab7Kenny Root *   my_tell_callback,      // or NULL
264c74663799493f2b1e6123c18def94295d0afab7Kenny Root *   my_length_callback,    // or NULL
265c74663799493f2b1e6123c18def94295d0afab7Kenny Root *   my_eof_callback,       // or NULL
266c74663799493f2b1e6123c18def94295d0afab7Kenny Root *   my_write_callback,
267c74663799493f2b1e6123c18def94295d0afab7Kenny Root *   my_metadata_callback,  // or NULL
268c74663799493f2b1e6123c18def94295d0afab7Kenny Root *   my_error_callback,
269c74663799493f2b1e6123c18def94295d0afab7Kenny Root *   my_client_data
270c74663799493f2b1e6123c18def94295d0afab7Kenny Root * ) != FLAC__STREAM_DECODER_INIT_STATUS_OK) do_something;
271c74663799493f2b1e6123c18def94295d0afab7Kenny Root * \endcode
272c74663799493f2b1e6123c18def94295d0afab7Kenny Root *
273c74663799493f2b1e6123c18def94295d0afab7Kenny Root * or you could do;
274c74663799493f2b1e6123c18def94295d0afab7Kenny Root *
275c74663799493f2b1e6123c18def94295d0afab7Kenny Root * \code
276c74663799493f2b1e6123c18def94295d0afab7Kenny Root * [...]
277c74663799493f2b1e6123c18def94295d0afab7Kenny Root * FILE *file = fopen("somefile.flac","rb");
278c74663799493f2b1e6123c18def94295d0afab7Kenny Root * if(file == NULL) do_somthing;
279c74663799493f2b1e6123c18def94295d0afab7Kenny Root * if(FLAC__stream_decoder_init_FILE(
280c74663799493f2b1e6123c18def94295d0afab7Kenny Root *   decoder,
281c74663799493f2b1e6123c18def94295d0afab7Kenny Root *   file,
282c74663799493f2b1e6123c18def94295d0afab7Kenny Root *   my_write_callback,
283c74663799493f2b1e6123c18def94295d0afab7Kenny Root *   my_metadata_callback,  // or NULL
284c74663799493f2b1e6123c18def94295d0afab7Kenny Root *   my_error_callback,
285c74663799493f2b1e6123c18def94295d0afab7Kenny Root *   my_client_data
286c74663799493f2b1e6123c18def94295d0afab7Kenny Root * ) != FLAC__STREAM_DECODER_INIT_STATUS_OK) do_something;
287c74663799493f2b1e6123c18def94295d0afab7Kenny Root * \endcode
288c74663799493f2b1e6123c18def94295d0afab7Kenny Root *
289c74663799493f2b1e6123c18def94295d0afab7Kenny Root * or just:
290c74663799493f2b1e6123c18def94295d0afab7Kenny Root *
291c74663799493f2b1e6123c18def94295d0afab7Kenny Root * \code
292c74663799493f2b1e6123c18def94295d0afab7Kenny Root * [...]
293c74663799493f2b1e6123c18def94295d0afab7Kenny Root * if(FLAC__stream_decoder_init_file(
294c74663799493f2b1e6123c18def94295d0afab7Kenny Root *   decoder,
295c74663799493f2b1e6123c18def94295d0afab7Kenny Root *   "somefile.flac",
296c74663799493f2b1e6123c18def94295d0afab7Kenny Root *   my_write_callback,
297c74663799493f2b1e6123c18def94295d0afab7Kenny Root *   my_metadata_callback,  // or NULL
298c74663799493f2b1e6123c18def94295d0afab7Kenny Root *   my_error_callback,
299c74663799493f2b1e6123c18def94295d0afab7Kenny Root *   my_client_data
300c74663799493f2b1e6123c18def94295d0afab7Kenny Root * ) != FLAC__STREAM_DECODER_INIT_STATUS_OK) do_something;
301c74663799493f2b1e6123c18def94295d0afab7Kenny Root * \endcode
302c74663799493f2b1e6123c18def94295d0afab7Kenny Root *
303c74663799493f2b1e6123c18def94295d0afab7Kenny Root * Another small change to the decoder is in how it handles unparseable
304c74663799493f2b1e6123c18def94295d0afab7Kenny Root * streams.  Before, when the decoder found an unparseable stream
305c74663799493f2b1e6123c18def94295d0afab7Kenny Root * (reserved for when the decoder encounters a stream from a future
306c74663799493f2b1e6123c18def94295d0afab7Kenny Root * encoder that it can't parse), it changed the state to
307c74663799493f2b1e6123c18def94295d0afab7Kenny Root * \c FLAC__STREAM_DECODER_UNPARSEABLE_STREAM.  Now the decoder instead
308c74663799493f2b1e6123c18def94295d0afab7Kenny Root * drops sync and calls the error callback with a new error code
309c74663799493f2b1e6123c18def94295d0afab7Kenny Root * \c FLAC__STREAM_DECODER_ERROR_STATUS_UNPARSEABLE_STREAM.  This is
310c74663799493f2b1e6123c18def94295d0afab7Kenny Root * more robust.  If your error callback does not discriminate on the the
311c74663799493f2b1e6123c18def94295d0afab7Kenny Root * error state, your code does not need to be changed.
312c74663799493f2b1e6123c18def94295d0afab7Kenny Root *
313c74663799493f2b1e6123c18def94295d0afab7Kenny Root * The encoder now has a new setting:
314c74663799493f2b1e6123c18def94295d0afab7Kenny Root * FLAC__stream_encoder_set_apodization().  This is for setting the
315c74663799493f2b1e6123c18def94295d0afab7Kenny Root * method used to window the data before LPC analysis.  You only need to
316c74663799493f2b1e6123c18def94295d0afab7Kenny Root * add a call to this function if the default is not suitable.   There
317c74663799493f2b1e6123c18def94295d0afab7Kenny Root * are also two new convenience functions that may be useful:
318c74663799493f2b1e6123c18def94295d0afab7Kenny Root * FLAC__metadata_object_cuesheet_calculate_cddb_id() and
319c74663799493f2b1e6123c18def94295d0afab7Kenny Root * FLAC__metadata_get_cuesheet().
320c74663799493f2b1e6123c18def94295d0afab7Kenny Root *
321c74663799493f2b1e6123c18def94295d0afab7Kenny Root * The \a bytes parameter to FLAC__StreamDecoderReadCallback,
322c74663799493f2b1e6123c18def94295d0afab7Kenny Root * FLAC__StreamEncoderReadCallback, and FLAC__StreamEncoderWriteCallback
323c74663799493f2b1e6123c18def94295d0afab7Kenny Root * is now \c size_t instead of \c unsigned.
324c74663799493f2b1e6123c18def94295d0afab7Kenny Root */
325c74663799493f2b1e6123c18def94295d0afab7Kenny Root
326c74663799493f2b1e6123c18def94295d0afab7Kenny Root/** \defgroup porting_1_1_3_to_1_1_4 Porting from FLAC 1.1.3 to 1.1.4
327c74663799493f2b1e6123c18def94295d0afab7Kenny Root *  \ingroup porting
328c74663799493f2b1e6123c18def94295d0afab7Kenny Root *
329c74663799493f2b1e6123c18def94295d0afab7Kenny Root *  \brief
330c74663799493f2b1e6123c18def94295d0afab7Kenny Root *  This module describes porting from FLAC 1.1.3 to FLAC 1.1.4.
331c74663799493f2b1e6123c18def94295d0afab7Kenny Root *
332c74663799493f2b1e6123c18def94295d0afab7Kenny Root * There were no changes to any of the interfaces from 1.1.3 to 1.1.4.
333c74663799493f2b1e6123c18def94295d0afab7Kenny Root * There was a slight change in the implementation of
334c74663799493f2b1e6123c18def94295d0afab7Kenny Root * FLAC__stream_encoder_set_metadata(); the function now makes a copy
335c74663799493f2b1e6123c18def94295d0afab7Kenny Root * of the \a metadata array of pointers so the client no longer needs
336c74663799493f2b1e6123c18def94295d0afab7Kenny Root * to maintain it after the call.  The objects themselves that are
337c74663799493f2b1e6123c18def94295d0afab7Kenny Root * pointed to by the array are still not copied though and must be
338c74663799493f2b1e6123c18def94295d0afab7Kenny Root * maintained until the call to FLAC__stream_encoder_finish().
339c74663799493f2b1e6123c18def94295d0afab7Kenny Root */
340c74663799493f2b1e6123c18def94295d0afab7Kenny Root
341c74663799493f2b1e6123c18def94295d0afab7Kenny Root/** \defgroup porting_1_1_4_to_1_2_0 Porting from FLAC 1.1.4 to 1.2.0
342c74663799493f2b1e6123c18def94295d0afab7Kenny Root *  \ingroup porting
343c74663799493f2b1e6123c18def94295d0afab7Kenny Root *
344c74663799493f2b1e6123c18def94295d0afab7Kenny Root *  \brief
345c74663799493f2b1e6123c18def94295d0afab7Kenny Root *  This module describes porting from FLAC 1.1.4 to FLAC 1.2.0.
346c74663799493f2b1e6123c18def94295d0afab7Kenny Root *
347c74663799493f2b1e6123c18def94295d0afab7Kenny Root * There were only very minor changes to the interfaces from 1.1.4 to 1.2.0.
348c74663799493f2b1e6123c18def94295d0afab7Kenny Root * In libFLAC, \c FLAC__format_sample_rate_is_subset() was added.
349c74663799493f2b1e6123c18def94295d0afab7Kenny Root * In libFLAC++, \c FLAC::Decoder::Stream::get_decode_position() was added.
350c74663799493f2b1e6123c18def94295d0afab7Kenny Root *
351c74663799493f2b1e6123c18def94295d0afab7Kenny Root * Finally, value of the constant \c FLAC__FRAME_HEADER_RESERVED_LEN
352c74663799493f2b1e6123c18def94295d0afab7Kenny Root * has changed to reflect the conversion of one of the reserved bits
353c74663799493f2b1e6123c18def94295d0afab7Kenny Root * into active use.  It used to be \c 2 and now is \c 1.  However the
354c74663799493f2b1e6123c18def94295d0afab7Kenny Root * FLAC frame header length has not changed, so to skip the proper
355c74663799493f2b1e6123c18def94295d0afab7Kenny Root * number of bits, use \c FLAC__FRAME_HEADER_RESERVED_LEN +
356c74663799493f2b1e6123c18def94295d0afab7Kenny Root * \c FLAC__FRAME_HEADER_BLOCKING_STRATEGY_LEN
357c74663799493f2b1e6123c18def94295d0afab7Kenny Root */
358c74663799493f2b1e6123c18def94295d0afab7Kenny Root
359c74663799493f2b1e6123c18def94295d0afab7Kenny Root/** \defgroup flac FLAC C API
360c74663799493f2b1e6123c18def94295d0afab7Kenny Root *
361c74663799493f2b1e6123c18def94295d0afab7Kenny Root * The FLAC C API is the interface to libFLAC, a set of structures
362c74663799493f2b1e6123c18def94295d0afab7Kenny Root * describing the components of FLAC streams, and functions for
363c74663799493f2b1e6123c18def94295d0afab7Kenny Root * encoding and decoding streams, as well as manipulating FLAC
364c74663799493f2b1e6123c18def94295d0afab7Kenny Root * metadata in files.
365c74663799493f2b1e6123c18def94295d0afab7Kenny Root *
366c74663799493f2b1e6123c18def94295d0afab7Kenny Root * You should start with the format components as all other modules
367c74663799493f2b1e6123c18def94295d0afab7Kenny Root * are dependent on it.
368c74663799493f2b1e6123c18def94295d0afab7Kenny Root */
369c74663799493f2b1e6123c18def94295d0afab7Kenny Root
370c74663799493f2b1e6123c18def94295d0afab7Kenny Root#endif
371