annotate win32-mingw/include/FLAC/callback.h @ 79:91c729825bca pa_catalina

Update build for AUDIO_COMPONENT_FIX
author Chris Cannam
date Wed, 30 Oct 2019 12:40:34 +0000
parents e582a1ccd5fe
children
rev   line source
Chris@5 1 /* libFLAC - Free Lossless Audio Codec library
Chris@5 2 * Copyright (C) 2004,2005,2006,2007 Josh Coalson
Chris@5 3 *
Chris@5 4 * Redistribution and use in source and binary forms, with or without
Chris@5 5 * modification, are permitted provided that the following conditions
Chris@5 6 * are met:
Chris@5 7 *
Chris@5 8 * - Redistributions of source code must retain the above copyright
Chris@5 9 * notice, this list of conditions and the following disclaimer.
Chris@5 10 *
Chris@5 11 * - Redistributions in binary form must reproduce the above copyright
Chris@5 12 * notice, this list of conditions and the following disclaimer in the
Chris@5 13 * documentation and/or other materials provided with the distribution.
Chris@5 14 *
Chris@5 15 * - Neither the name of the Xiph.org Foundation nor the names of its
Chris@5 16 * contributors may be used to endorse or promote products derived from
Chris@5 17 * this software without specific prior written permission.
Chris@5 18 *
Chris@5 19 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
Chris@5 20 * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
Chris@5 21 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
Chris@5 22 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR
Chris@5 23 * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
Chris@5 24 * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
Chris@5 25 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
Chris@5 26 * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
Chris@5 27 * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
Chris@5 28 * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
Chris@5 29 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
Chris@5 30 */
Chris@5 31
Chris@5 32 #ifndef FLAC__CALLBACK_H
Chris@5 33 #define FLAC__CALLBACK_H
Chris@5 34
Chris@5 35 #include "ordinals.h"
Chris@5 36 #include <stdlib.h> /* for size_t */
Chris@5 37
Chris@5 38 /** \file include/FLAC/callback.h
Chris@5 39 *
Chris@5 40 * \brief
Chris@5 41 * This module defines the structures for describing I/O callbacks
Chris@5 42 * to the other FLAC interfaces.
Chris@5 43 *
Chris@5 44 * See the detailed documentation for callbacks in the
Chris@5 45 * \link flac_callbacks callbacks \endlink module.
Chris@5 46 */
Chris@5 47
Chris@5 48 /** \defgroup flac_callbacks FLAC/callback.h: I/O callback structures
Chris@5 49 * \ingroup flac
Chris@5 50 *
Chris@5 51 * \brief
Chris@5 52 * This module defines the structures for describing I/O callbacks
Chris@5 53 * to the other FLAC interfaces.
Chris@5 54 *
Chris@5 55 * The purpose of the I/O callback functions is to create a common way
Chris@5 56 * for the metadata interfaces to handle I/O.
Chris@5 57 *
Chris@5 58 * Originally the metadata interfaces required filenames as the way of
Chris@5 59 * specifying FLAC files to operate on. This is problematic in some
Chris@5 60 * environments so there is an additional option to specify a set of
Chris@5 61 * callbacks for doing I/O on the FLAC file, instead of the filename.
Chris@5 62 *
Chris@5 63 * In addition to the callbacks, a FLAC__IOHandle type is defined as an
Chris@5 64 * opaque structure for a data source.
Chris@5 65 *
Chris@5 66 * The callback function prototypes are similar (but not identical) to the
Chris@5 67 * stdio functions fread, fwrite, fseek, ftell, feof, and fclose. If you use
Chris@5 68 * stdio streams to implement the callbacks, you can pass fread, fwrite, and
Chris@5 69 * fclose anywhere a FLAC__IOCallback_Read, FLAC__IOCallback_Write, or
Chris@5 70 * FLAC__IOCallback_Close is required, and a FILE* anywhere a FLAC__IOHandle
Chris@5 71 * is required. \warning You generally CANNOT directly use fseek or ftell
Chris@5 72 * for FLAC__IOCallback_Seek or FLAC__IOCallback_Tell since on most systems
Chris@5 73 * these use 32-bit offsets and FLAC requires 64-bit offsets to deal with
Chris@5 74 * large files. You will have to find an equivalent function (e.g. ftello),
Chris@5 75 * or write a wrapper. The same is true for feof() since this is usually
Chris@5 76 * implemented as a macro, not as a function whose address can be taken.
Chris@5 77 *
Chris@5 78 * \{
Chris@5 79 */
Chris@5 80
Chris@5 81 #ifdef __cplusplus
Chris@5 82 extern "C" {
Chris@5 83 #endif
Chris@5 84
Chris@5 85 /** This is the opaque handle type used by the callbacks. Typically
Chris@5 86 * this is a \c FILE* or address of a file descriptor.
Chris@5 87 */
Chris@5 88 typedef void* FLAC__IOHandle;
Chris@5 89
Chris@5 90 /** Signature for the read callback.
Chris@5 91 * The signature and semantics match POSIX fread() implementations
Chris@5 92 * and can generally be used interchangeably.
Chris@5 93 *
Chris@5 94 * \param ptr The address of the read buffer.
Chris@5 95 * \param size The size of the records to be read.
Chris@5 96 * \param nmemb The number of records to be read.
Chris@5 97 * \param handle The handle to the data source.
Chris@5 98 * \retval size_t
Chris@5 99 * The number of records read.
Chris@5 100 */
Chris@5 101 typedef size_t (*FLAC__IOCallback_Read) (void *ptr, size_t size, size_t nmemb, FLAC__IOHandle handle);
Chris@5 102
Chris@5 103 /** Signature for the write callback.
Chris@5 104 * The signature and semantics match POSIX fwrite() implementations
Chris@5 105 * and can generally be used interchangeably.
Chris@5 106 *
Chris@5 107 * \param ptr The address of the write buffer.
Chris@5 108 * \param size The size of the records to be written.
Chris@5 109 * \param nmemb The number of records to be written.
Chris@5 110 * \param handle The handle to the data source.
Chris@5 111 * \retval size_t
Chris@5 112 * The number of records written.
Chris@5 113 */
Chris@5 114 typedef size_t (*FLAC__IOCallback_Write) (const void *ptr, size_t size, size_t nmemb, FLAC__IOHandle handle);
Chris@5 115
Chris@5 116 /** Signature for the seek callback.
Chris@5 117 * The signature and semantics mostly match POSIX fseek() WITH ONE IMPORTANT
Chris@5 118 * EXCEPTION: the offset is a 64-bit type whereas fseek() is generally 'long'
Chris@5 119 * and 32-bits wide.
Chris@5 120 *
Chris@5 121 * \param handle The handle to the data source.
Chris@5 122 * \param offset The new position, relative to \a whence
Chris@5 123 * \param whence \c SEEK_SET, \c SEEK_CUR, or \c SEEK_END
Chris@5 124 * \retval int
Chris@5 125 * \c 0 on success, \c -1 on error.
Chris@5 126 */
Chris@5 127 typedef int (*FLAC__IOCallback_Seek) (FLAC__IOHandle handle, FLAC__int64 offset, int whence);
Chris@5 128
Chris@5 129 /** Signature for the tell callback.
Chris@5 130 * The signature and semantics mostly match POSIX ftell() WITH ONE IMPORTANT
Chris@5 131 * EXCEPTION: the offset is a 64-bit type whereas ftell() is generally 'long'
Chris@5 132 * and 32-bits wide.
Chris@5 133 *
Chris@5 134 * \param handle The handle to the data source.
Chris@5 135 * \retval FLAC__int64
Chris@5 136 * The current position on success, \c -1 on error.
Chris@5 137 */
Chris@5 138 typedef FLAC__int64 (*FLAC__IOCallback_Tell) (FLAC__IOHandle handle);
Chris@5 139
Chris@5 140 /** Signature for the EOF callback.
Chris@5 141 * The signature and semantics mostly match POSIX feof() but WATCHOUT:
Chris@5 142 * on many systems, feof() is a macro, so in this case a wrapper function
Chris@5 143 * must be provided instead.
Chris@5 144 *
Chris@5 145 * \param handle The handle to the data source.
Chris@5 146 * \retval int
Chris@5 147 * \c 0 if not at end of file, nonzero if at end of file.
Chris@5 148 */
Chris@5 149 typedef int (*FLAC__IOCallback_Eof) (FLAC__IOHandle handle);
Chris@5 150
Chris@5 151 /** Signature for the close callback.
Chris@5 152 * The signature and semantics match POSIX fclose() implementations
Chris@5 153 * and can generally be used interchangeably.
Chris@5 154 *
Chris@5 155 * \param handle The handle to the data source.
Chris@5 156 * \retval int
Chris@5 157 * \c 0 on success, \c EOF on error.
Chris@5 158 */
Chris@5 159 typedef int (*FLAC__IOCallback_Close) (FLAC__IOHandle handle);
Chris@5 160
Chris@5 161 /** A structure for holding a set of callbacks.
Chris@5 162 * Each FLAC interface that requires a FLAC__IOCallbacks structure will
Chris@5 163 * describe which of the callbacks are required. The ones that are not
Chris@5 164 * required may be set to NULL.
Chris@5 165 *
Chris@5 166 * If the seek requirement for an interface is optional, you can signify that
Chris@5 167 * a data sorce is not seekable by setting the \a seek field to \c NULL.
Chris@5 168 */
Chris@5 169 typedef struct {
Chris@5 170 FLAC__IOCallback_Read read;
Chris@5 171 FLAC__IOCallback_Write write;
Chris@5 172 FLAC__IOCallback_Seek seek;
Chris@5 173 FLAC__IOCallback_Tell tell;
Chris@5 174 FLAC__IOCallback_Eof eof;
Chris@5 175 FLAC__IOCallback_Close close;
Chris@5 176 } FLAC__IOCallbacks;
Chris@5 177
Chris@5 178 /* \} */
Chris@5 179
Chris@5 180 #ifdef __cplusplus
Chris@5 181 }
Chris@5 182 #endif
Chris@5 183
Chris@5 184 #endif