com_add(): Return negative on errors
[paraslash.git] / ogg_afh_common.h
1 /*
2  * Copyright (C) 2010 Andre Noll <maan@tuebingen.mpg.de>
3  *
4  * Licensed under the GPL v2. For licencing details see COPYING.
5  */
6
7 /**
8  * \file ogg_afh_common.h Structures and prototypes common to audio format
9  * handlers that use the ogg container format.
10  */
11
12 /**
13  * Callback structure provided by audio format handlers.
14  *
15  * All audio formats which utilize the ogg container format define a callback
16  * function whose purpose is to extract the meta information about the audio
17  * file from the first few ogg packets of the bitstream.
18  */
19 struct ogg_afh_callback_info {
20         /**
21          * ogg_get_file_info() calls this function for the first three ogg
22          * packets, or until the callback returns a non-positive value. If it
23          * returns negative, the audio file was not recognized by the audio
24          * format handler. If it returns zero, the audio file is considered
25          * valid, and no further processing by the callback is needed. In this
26          * case the header chunk, i.e. chunk number zero, is defined as the
27          * concatenation of all packets that have been processed by the
28          * callback.
29          */
30         int (*packet_callback)(ogg_packet *packet, int packet_num,
31                 int serial, struct afh_info *afhi, void *private_data);
32         /** Data specific to the audio format handler. */
33         void *private_data;
34 };
35
36 int ogg_get_file_info(char *map, size_t numbytes, struct afh_info *afhi,
37                 struct ogg_afh_callback_info *ci);