annotate win64-mingw/include/FLAC/callback.h @ 34:05254799ed10

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