The purpose of the I/O callback functions is to create a common way for the metadata interfaces to handle I/O.
Originally the metadata interfaces required filenames as the way of specifying FLAC files to operate on. This is problematic in some environments so there is an additional option to specify a set of callbacks for doing I/O on the FLAC file, instead of the filename.
In addition to the callbacks, a FLAC__IOHandle type is defined as an opaque structure for a data source.
The callback function prototypes are similar (but not identical) to the stdio functions fread, fwrite, fseek, ftell, feof, and fclose. If you use stdio streams to implement the callbacks, you can pass fread, fwrite, and fclose anywhere a FLAC__IOCallback_Read, FLAC__IOCallback_Write, or FLAC__IOCallback_Close is required, and a FILE* anywhere a FLAC__IOHandle is required.
Classes | |
struct | FLAC__IOCallbacks |
Typedefs | |
typedef void * | FLAC__IOHandle |
typedef size_t(* | FLAC__IOCallback_Read )(void *ptr, size_t size, size_t nmemb, FLAC__IOHandle handle) |
typedef size_t(* | FLAC__IOCallback_Write )(const void *ptr, size_t size, size_t nmemb, FLAC__IOHandle handle) |
typedef int(* | FLAC__IOCallback_Seek )(FLAC__IOHandle handle, FLAC__int64 offset, int whence) |
typedef FLAC__int64(* | FLAC__IOCallback_Tell )(FLAC__IOHandle handle) |
typedef int(* | FLAC__IOCallback_Eof )(FLAC__IOHandle handle) |
typedef int(* | FLAC__IOCallback_Close )(FLAC__IOHandle handle) |
|
This is the opaque handle type used by the callbacks. Typically this is a |
|
Signature for the read callback. The signature and semantics match POSIX fread() implementations and can generally be used interchangeably.
|
|
Signature for the write callback. The signature and semantics match POSIX fwrite() implementations and can generally be used interchangeably.
|
|
Signature for the seek callback. The signature and semantics mostly match POSIX fseek() WITH ONE IMPORTANT EXCEPTION: the offset is a 64-bit type whereas fseek() is generally 'long' and 32-bits wide.
|
|
Signature for the tell callback. The signature and semantics mostly match POSIX ftell() WITH ONE IMPORTANT EXCEPTION: the offset is a 64-bit type whereas ftell() is generally 'long' and 32-bits wide.
|
|
Signature for the EOF callback. The signature and semantics mostly match POSIX feof() but WATCHOUT: on many systems, feof() is a macro, so in this case a wrapper function must be provided instead.
|
|
Signature for the close callback. The signature and semantics match POSIX fclose() implementations and can generally be used interchangeably.
|