annotate win32-mingw/include/FLAC/callback.h @ 122:62723f530572

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