rate: add some sanity checking
[sox.git] / src / raw.h
blob6a5c4a5dbee2b49b9d64740c40c585fa93c99cdb
1 /* libSoX file formats: raw (c) 2007-8 SoX contributors
3 * This library is free software; you can redistribute it and/or modify it
4 * under the terms of the GNU Lesser General Public License as published by
5 * the Free Software Foundation; either version 2.1 of the License, or (at
6 * your option) any later version.
8 * This library is distributed in the hope that it will be useful, but
9 * WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser
11 * General Public License for more details.
13 * You should have received a copy of the GNU Lesser General Public License
14 * along with this library; if not, write to the Free Software Foundation,
15 * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
18 #define RAW_FORMAT0(id, size, flags, encoding) \
19 static int id ## _start(sox_format_t * ft) { \
20 return lsx_rawstart(ft, sox_true, sox_true, sox_true, SOX_ENCODING_ ## encoding, size); \
21 } \
22 const sox_format_handler_t *lsx_ ## id ## _format_fn(void); \
23 const sox_format_handler_t *lsx_ ## id ## _format_fn(void) { \
24 static unsigned const write_encodings[] = { \
25 SOX_ENCODING_ ## encoding, size, 0, 0}; \
26 static sox_format_handler_t handler = { \
27 SOX_LIB_VERSION_CODE, "Raw audio", \
28 names, flags, \
29 id ## _start, lsx_rawread , NULL, \
30 id ## _start, lsx_rawwrite, NULL, \
31 NULL, write_encodings, NULL, 0 \
32 }; \
33 return &handler; \
36 #define RAW_FORMAT(id, size, flags, encoding) \
37 static char const *names[] = {#id, NULL}; \
38 RAW_FORMAT0(id, size, flags, encoding)
40 #define RAW_FORMAT1(id, alt, size, flags, encoding) \
41 static char const *names[] = {#id, alt, NULL}; \
42 RAW_FORMAT0(id, size, flags, encoding)
44 #define RAW_FORMAT2(id, alt1, alt2, size, flags, encoding) \
45 static char const *names[] = {#id, alt1, alt2, NULL}; \
46 RAW_FORMAT0(id, size, flags, encoding)
48 #define RAW_FORMAT3(id, alt1, alt2, alt3, size, flags, encoding) \
49 static char const *names[] = {#id, alt1, alt2, alt3, NULL}; \
50 RAW_FORMAT0(id, size, flags, encoding)
52 #define RAW_FORMAT4(id, alt1, alt2, alt3, alt4, size, flags, encoding) \
53 static char const *names[] = {#id, alt1, alt2, alt3, alt4, NULL}; \
54 RAW_FORMAT0(id, size, flags, encoding)