comparison decoders/flac.c @ 393:b12c4483815e

Handles all versions of libFLAC up to version 1.0.3, now.
author Ryan C. Gordon <icculus@icculus.org>
date Thu, 11 Jul 2002 04:33:08 +0000
parents fb519e6028e3
children 9d0b5ec9cc26
comparison
equal deleted inserted replaced
392:442070fb3856 393:b12c4483815e
52 * An added benefit is that we get identifiers of manageable length. 52 * An added benefit is that we get identifiers of manageable length.
53 */ 53 */
54 54
55 #if SOUND_SUPPORTS_SEEKABLE_FLAC 55 #if SOUND_SUPPORTS_SEEKABLE_FLAC
56 56
57 #define FLAC_IS_SEEKABLE 1
58
57 #include "FLAC/seekable_stream_decoder.h" 59 #include "FLAC/seekable_stream_decoder.h"
58 60
59 #define D_END_OF_STREAM FLAC__SEEKABLE_STREAM_DECODER_END_OF_STREAM 61 #define D_END_OF_STREAM FLAC__SEEKABLE_STREAM_DECODER_END_OF_STREAM
60 62
61 #define d_new() FLAC__seekable_stream_decoder_new() 63 #define d_new() FLAC__seekable_stream_decoder_new()
95 97
96 #else 98 #else
97 99
98 #include "FLAC/stream_decoder.h" 100 #include "FLAC/stream_decoder.h"
99 101
102 #define FLAC_IS_SEEKABLE 0
103
100 #define D_END_OF_STREAM FLAC__STREAM_DECODER_END_OF_STREAM 104 #define D_END_OF_STREAM FLAC__STREAM_DECODER_END_OF_STREAM
101 105
102 #define d_new() FLAC__stream_decoder_new() 106 #define d_new() FLAC__stream_decoder_new()
103 #define d_init(x) FLAC__stream_decoder_init(x) 107 #define d_init(x) FLAC__stream_decoder_init(x)
104 #define d_process_metadata(x) FLAC__stream_decoder_process_metadata(x) 108 #define d_process_metadata(x) FLAC__stream_decoder_process_metadata(x)
119 123
120 #define d_reset(x) FLAC__stream_decoder_reset(x) 124 #define d_reset(x) FLAC__stream_decoder_reset(x)
121 125
122 #endif 126 #endif
123 127
128 /*
129 * FLAC 1.0.3 changed some symbol names, so we need to change what we
130 * reference depending on what version of their headers we compile against.
131 * We check for a #define that was included in FLAC 1.0.3 but doesn't exist
132 * in 1.0.2 and earlier. Fun. --ryan.
133 */
134 #if (defined FLAC__STREAM_SYNC_LENGTH)
135 #define FLAC_VERSION_102_OR_LESS 0
136 #else
137 #define FLAC_VERSION_102_OR_LESS 1
138 #endif
139
140
124 /* These are the same for both decoders, so they're just cosmetics. */ 141 /* These are the same for both decoders, so they're just cosmetics. */
125 142
143 #if FLAC_VERSION_102_OR_LESS
126 #define D_WRITE_CONTINUE FLAC__STREAM_DECODER_WRITE_CONTINUE 144 #define D_WRITE_CONTINUE FLAC__STREAM_DECODER_WRITE_CONTINUE
127 #define D_READ_END_OF_STREAM FLAC__STREAM_DECODER_READ_END_OF_STREAM 145 #define D_READ_END_OF_STREAM FLAC__STREAM_DECODER_READ_END_OF_STREAM
128 #define D_READ_ABORT FLAC__STREAM_DECODER_READ_ABORT 146 #define D_READ_ABORT FLAC__STREAM_DECODER_READ_ABORT
129 #define D_READ_CONTINUE FLAC__STREAM_DECODER_READ_CONTINUE 147 #define D_READ_CONTINUE FLAC__STREAM_DECODER_READ_CONTINUE
148 #else
149 #define D_WRITE_CONTINUE FLAC__STREAM_DECODER_WRITE_STATUS_CONTINUE
150 #define D_READ_END_OF_STREAM FLAC__STREAM_DECODER_READ_STATUS_END_OF_STREAM
151 #define D_READ_ABORT FLAC__STREAM_DECODER_READ_STATUS_ABORT
152 #define D_READ_CONTINUE FLAC__STREAM_DECODER_READ_STATUS_CONTINUE
153 #endif
130 154
131 #define d_error_status_string FLAC__StreamDecoderErrorStatusString 155 #define d_error_status_string FLAC__StreamDecoderErrorStatusString
132 156
157 typedef FLAC__StreamDecoderErrorStatus d_error_status_t;
158 #if FLAC_VERSION_102_OR_LESS
159 typedef FLAC__StreamMetaData d_metadata_t;
160 #else
161 typedef FLAC__StreamMetadata d_metadata_t;
162 #endif
133 typedef FLAC__StreamDecoderWriteStatus d_write_status_t; 163 typedef FLAC__StreamDecoderWriteStatus d_write_status_t;
134 typedef FLAC__StreamDecoderErrorStatus d_error_status_t;
135 typedef FLAC__StreamMetaData d_metadata_t;
136 164
137 165
138 static int FLAC_init(void); 166 static int FLAC_init(void);
139 static void FLAC_quit(void); 167 static void FLAC_quit(void);
140 static int FLAC_open(Sound_Sample *sample, const char *ext); 168 static int FLAC_open(Sound_Sample *sample, const char *ext);
221 } /* read_callback */ 249 } /* read_callback */
222 250
223 251
224 static d_write_status_t write_callback( 252 static d_write_status_t write_callback(
225 const decoder_t *decoder, const FLAC__Frame *frame, 253 const decoder_t *decoder, const FLAC__Frame *frame,
226 const FLAC__int32 *buffer[], void *client_data) 254 #if FLAC_VERSION_102_OR_LESS
255 const FLAC__int32 * buffer[],
256 #else
257 const FLAC__int32 * const buffer[],
258 #endif
259 void *client_data)
227 { 260 {
228 flac_t *f = (flac_t *) client_data; 261 flac_t *f = (flac_t *) client_data;
229 Uint32 i, j; 262 Uint32 i, j;
230 Uint32 sample; 263 Uint32 sample;
231 Uint8 *dst; 264 Uint8 *dst;
388 421
389 #endif 422 #endif
390 423
391 static int FLAC_init(void) 424 static int FLAC_init(void)
392 { 425 {
426 SNDDBG(("FLAC: we are using libFLAC version %s 1.0.2.\n",
427 FLAC_VERSION_102_OR_LESS ? "<=" : ">"));
428 SNDDBG(("FLAC: We %shave seeking support.\n",
429 FLAC_IS_SEEKABLE ? "" : "do NOT "));
430
393 return(1); /* always succeeds. */ 431 return(1); /* always succeeds. */
394 } /* FLAC_init */ 432 } /* FLAC_init */
395 433
396 434
397 static void FLAC_quit(void) 435 static void FLAC_quit(void)