2 * This file is part of DisOrder
3 * Copyright (C) 2007-2010 Richard Kettlewell
5 * This program is free software: you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License as published by
7 * the Free Software Foundation, either version 3 of the License, or
8 * (at your option) any later version.
10 * This program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
15 * You should have received a copy of the GNU General Public License
16 * along with this program. If not, see <http://www.gnu.org/licenses/>.
18 /** @file server/decode.c
19 * @brief General-purpose decoder for use by speaker process
24 /** @brief Sample data callback used by decode_wav() */
25 static int wav_write(struct wavfile
attribute((unused
)) *f
,
28 void attribute((unused
)) *u
) {
29 if(fwrite(data
, 1, nbytes
, outputfp
) < nbytes
)
30 disorder_fatal(errno
, "decoding %s: writing sample data", path
);
34 /** @brief WAV file decoder */
35 void decode_wav(void) {
39 if((err
= wav_init(f
, path
)))
40 disorder_fatal(err
, "opening %s", path
);
41 output_header(f
->rate
, f
->channels
, f
->bits
, f
->datasize
, ENDIAN_LITTLE
);
42 if((err
= wav_data(f
, wav_write
, 0)))
43 disorder_fatal(err
, "error decoding %s", path
);