annotate osx/include/FLAC/callback.h @ 2:cc5d363db385

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