chiark / gitweb /
Consistency check for finished tracks.
[disorder] / server / decode-wav.c
CommitLineData
8d399b30
RK
1/*
2 * This file is part of DisOrder
3 * Copyright (C) 2007-2010 Richard Kettlewell
4 *
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.
9 *
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.
14 *
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/>.
17 */
18/** @file server/decode.c
19 * @brief General-purpose decoder for use by speaker process
20 */
21#include "decode.h"
22#include "wav.h"
23
24/** @brief Sample data callback used by decode_wav() */
25static int wav_write(struct wavfile attribute((unused)) *f,
26 const char *data,
27 size_t nbytes,
28 void attribute((unused)) *u) {
29 if(fwrite(data, 1, nbytes, outputfp) < nbytes)
30 disorder_fatal(errno, "decoding %s: writing sample data", path);
31 return 0;
32}
33
34/** @brief WAV file decoder */
35void decode_wav(void) {
36 struct wavfile f[1];
37 int err;
38
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);
44}
45
46/*
47Local Variables:
48c-basic-offset:2
49comment-column:40
50fill-column:79
51indent-tabs-mode:nil
52End:
53*/