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.h
19 * @brief General-purpose decoder for use by speaker process
24 #include "disorder-server.h"
26 #include "speaker-protocol.h"
28 #define INPUT_BUFFER_SIZE 1048576
30 /** @brief Output file */
31 extern FILE *outputfp;
33 /** @brief Input filename */
34 extern const char *path;
36 /** @brief Input buffer */
37 extern char input_buffer[INPUT_BUFFER_SIZE];
39 /** @brief Number of bytes read into buffer */
40 extern int input_count;
42 /** @brief Write an 8-bit word */
43 static inline void output_8(int n) {
44 if(putc(n, outputfp) < 0)
45 disorder_fatal(errno, "decoding %s: output error", path);
48 /** @brief Write a 16-bit word in bigendian format */
49 static inline void output_16(uint16_t n) {
50 if(putc(n >> 8, outputfp) < 0
51 || putc(n, outputfp) < 0)
52 disorder_fatal(errno, "decoding %s: output error", path);
55 /** @brief Write a 24-bit word in bigendian format */
56 static inline void output_24(uint32_t n) {
57 if(putc(n >> 16, outputfp) < 0
58 || putc(n >> 8, outputfp) < 0
59 || putc(n, outputfp) < 0)
60 disorder_fatal(errno, "decoding %s: output error", path);
63 /** @brief Write a 32-bit word in bigendian format */
64 static inline void output_32(uint32_t n) {
65 if(putc(n >> 24, outputfp) < 0
66 || putc(n >> 16, outputfp) < 0
67 || putc(n >> 8, outputfp) < 0
68 || putc(n, outputfp) < 0)
69 disorder_fatal(errno, "decoding %s: output error", path);
72 void output_header(int rate,
78 void decode_mp3(void);
79 void decode_ogg(void);
80 void decode_wav(void);
81 void decode_flac(void);