Lines 49-60
Link Here
|
49 |
|
49 |
|
50 |
static void play_file(const char *); |
50 |
static void play_file(const char *); |
51 |
static void play_remote_file(void); |
51 |
static void play_remote_file(void); |
52 |
void flac_error_hdl(const FLAC__FileDecoder *, FLAC__StreamDecoderErrorStatus, |
52 |
#ifdef LEGACY_FLAC |
53 |
void *); |
53 |
void flac_error_hdl(const FLAC__FileDecoder *, FLAC__StreamDecoderErrorStatus, void *); |
54 |
void flac_metadata_hdl(const FLAC__FileDecoder *, const FLAC__StreamMetadata *, |
54 |
void flac_metadata_hdl(const FLAC__FileDecoder *, const FLAC__StreamMetadata *, void *); |
55 |
void *); |
|
|
56 |
FLAC__StreamDecoderWriteStatus flac_write_hdl(const FLAC__FileDecoder *, |
55 |
FLAC__StreamDecoderWriteStatus flac_write_hdl(const FLAC__FileDecoder *, |
57 |
const FLAC__Frame *, const FLAC__int32 * const buf[], void *); |
56 |
const FLAC__Frame *, const FLAC__int32 * const buf[], void *); |
|
|
57 |
#else |
58 |
void flac_error_hdl(const FLAC__StreamDecoder *, FLAC__StreamDecoderErrorStatus, void *); |
59 |
void flac_metadata_hdl(const FLAC__StreamDecoder *, const FLAC__StreamMetadata *, void *); |
60 |
FLAC__StreamDecoderWriteStatus flac_write_hdl(const FLAC__StreamDecoder *, |
61 |
const FLAC__Frame *, const FLAC__int32 * const buf[], void *); |
62 |
#endif |
58 |
|
63 |
|
59 |
static void signal_handler(int); |
64 |
static void signal_handler(int); |
60 |
static int quit_now = 0; |
65 |
static int quit_now = 0; |
Lines 190-195
Link Here
|
190 |
file_info.year[VORBIS_YEAR_LEN] = '\0'; |
195 |
file_info.year[VORBIS_YEAR_LEN] = '\0'; |
191 |
|
196 |
|
192 |
/* create and initialize flac decoder object */ |
197 |
/* create and initialize flac decoder object */ |
|
|
198 |
#ifdef LEGACY_FLAC |
193 |
file_info.decoder = FLAC__file_decoder_new(); |
199 |
file_info.decoder = FLAC__file_decoder_new(); |
194 |
FLAC__file_decoder_set_md5_checking(file_info.decoder, true); |
200 |
FLAC__file_decoder_set_md5_checking(file_info.decoder, true); |
195 |
FLAC__file_decoder_set_filename(file_info.decoder, filename); |
201 |
FLAC__file_decoder_set_filename(file_info.decoder, filename); |
Lines 210-222
Link Here
|
210 |
FLAC__file_decoder_delete(file_info.decoder); |
216 |
FLAC__file_decoder_delete(file_info.decoder); |
211 |
return false; |
217 |
return false; |
212 |
} |
218 |
} |
|
|
219 |
#else |
220 |
file_info.decoder = FLAC__stream_decoder_new(); |
221 |
FLAC__stream_decoder_set_md5_checking(file_info.decoder, true); |
222 |
|
223 |
/* read metadata */ |
224 |
if ((FLAC__stream_decoder_init_file(file_info.decoder, filename, flac_write_hdl, flac_metadata_hdl, flac_error_hdl, (void *)&file_info) != FLAC__STREAM_DECODER_INIT_STATUS_OK) |
225 |
|| (!FLAC__stream_decoder_process_until_end_of_metadata(file_info.decoder))) |
226 |
{ |
227 |
FLAC__stream_decoder_delete(file_info.decoder); |
228 |
return false; |
229 |
} |
230 |
#endif |
213 |
|
231 |
|
214 |
/* open libao output device */ |
232 |
/* open libao output device */ |
215 |
if (cli_args.wavfile) { |
233 |
if (cli_args.wavfile) { |
216 |
if (!(file_info.ao_dev = ao_open_file(ao_driver_id("wav"), cli_args.wavfile, /*overwrite*/ 1, &(file_info.ao_fmt), NULL))) |
234 |
if (!(file_info.ao_dev = ao_open_file(ao_driver_id("wav"), cli_args.wavfile, /*overwrite*/ 1, &(file_info.ao_fmt), NULL))) |
217 |
{ |
235 |
{ |
218 |
fprintf(stderr, "Error opening wav file %s\n", cli_args.wavfile); |
236 |
fprintf(stderr, "Error opening wav file %s\n", cli_args.wavfile); |
|
|
237 |
#ifdef LEGACY_FLAC |
219 |
FLAC__file_decoder_delete(file_info.decoder); |
238 |
FLAC__file_decoder_delete(file_info.decoder); |
|
|
239 |
#else |
240 |
FLAC__stream_decoder_delete(file_info.decoder); |
241 |
#endif |
220 |
return false; |
242 |
return false; |
221 |
} |
243 |
} |
222 |
} |
244 |
} |
Lines 224-230
Link Here
|
224 |
if (!(file_info.ao_dev = ao_open_live(ao_output_id, &(file_info.ao_fmt), NULL))) |
246 |
if (!(file_info.ao_dev = ao_open_live(ao_output_id, &(file_info.ao_fmt), NULL))) |
225 |
{ |
247 |
{ |
226 |
fprintf(stderr, "Error opening ao device %d\n", ao_output_id); |
248 |
fprintf(stderr, "Error opening ao device %d\n", ao_output_id); |
|
|
249 |
#ifdef LEGACY_FLAC |
227 |
FLAC__file_decoder_delete(file_info.decoder); |
250 |
FLAC__file_decoder_delete(file_info.decoder); |
|
|
251 |
#else |
252 |
FLAC__stream_decoder_delete(file_info.decoder); |
253 |
#endif |
228 |
return false; |
254 |
return false; |
229 |
} |
255 |
} |
230 |
} |
256 |
} |
Lines 237-243
Link Here
|
237 |
if (!(file_info.ao_dev = ao_open_live(ao_output_id, &(file_info.ao_fmt), NULL))) |
263 |
if (!(file_info.ao_dev = ao_open_live(ao_output_id, &(file_info.ao_fmt), NULL))) |
238 |
{ |
264 |
{ |
239 |
fprintf(stderr, "Error opening ao device %d\n", ao_output_id); |
265 |
fprintf(stderr, "Error opening ao device %d\n", ao_output_id); |
|
|
266 |
#ifdef LEGACY_FLAC |
240 |
FLAC__file_decoder_delete(file_info.decoder); |
267 |
FLAC__file_decoder_delete(file_info.decoder); |
|
|
268 |
#else |
269 |
FLAC__stream_decoder_delete(file_info.decoder); |
270 |
#endif |
241 |
return false; |
271 |
return false; |
242 |
} |
272 |
} |
243 |
} |
273 |
} |
Lines 257-264
Link Here
|
257 |
|
287 |
|
258 |
void decoder_destructor(void) |
288 |
void decoder_destructor(void) |
259 |
{ |
289 |
{ |
|
|
290 |
#ifdef LEGACY_FLAC |
260 |
FLAC__file_decoder_finish(file_info.decoder); |
291 |
FLAC__file_decoder_finish(file_info.decoder); |
261 |
FLAC__file_decoder_delete(file_info.decoder); |
292 |
FLAC__file_decoder_delete(file_info.decoder); |
|
|
293 |
#else |
294 |
FLAC__stream_decoder_finish(file_info.decoder); |
295 |
FLAC__stream_decoder_delete(file_info.decoder); |
296 |
#endif |
262 |
file_info.is_loaded = false; |
297 |
file_info.is_loaded = false; |
263 |
file_info.is_playing = false; |
298 |
file_info.is_playing = false; |
264 |
file_info.filename[0] = '\0'; |
299 |
file_info.filename[0] = '\0'; |
Lines 272-280
Link Here
|
272 |
return; |
307 |
return; |
273 |
} |
308 |
} |
274 |
|
309 |
|
|
|
310 |
#ifdef LEGACY_FLAC |
275 |
while (FLAC__file_decoder_process_single(file_info.decoder) == true && |
311 |
while (FLAC__file_decoder_process_single(file_info.decoder) == true && |
276 |
FLAC__file_decoder_get_state(file_info.decoder) == |
312 |
FLAC__file_decoder_get_state(file_info.decoder) == |
277 |
FLAC__FILE_DECODER_OK && !interrupted) |
313 |
FLAC__FILE_DECODER_OK && !interrupted) |
|
|
314 |
#else |
315 |
while (FLAC__stream_decoder_process_single(file_info.decoder) == true && |
316 |
FLAC__stream_decoder_get_state(file_info.decoder) < |
317 |
FLAC__STREAM_DECODER_END_OF_STREAM && !interrupted) |
318 |
#endif |
278 |
{ |
319 |
{ |
279 |
} |
320 |
} |
280 |
interrupted = 0; /* more accurate feedback if placed after loop */ |
321 |
interrupted = 0; /* more accurate feedback if placed after loop */ |
Lines 292-304
Link Here
|
292 |
{ |
333 |
{ |
293 |
if (file_info.is_playing == true) |
334 |
if (file_info.is_playing == true) |
294 |
{ |
335 |
{ |
|
|
336 |
#ifdef LEGACY_FLAC |
295 |
if (FLAC__file_decoder_get_state(file_info.decoder) == |
337 |
if (FLAC__file_decoder_get_state(file_info.decoder) == |
296 |
FLAC__FILE_DECODER_END_OF_FILE) |
338 |
FLAC__FILE_DECODER_END_OF_FILE) |
|
|
339 |
#else |
340 |
if (FLAC__stream_decoder_get_state(file_info.decoder) == |
341 |
FLAC__STREAM_DECODER_END_OF_STREAM) |
342 |
#endif |
297 |
{ |
343 |
{ |
298 |
decoder_destructor(); |
344 |
decoder_destructor(); |
299 |
printf("@P 0\n"); |
345 |
printf("@P 0\n"); |
300 |
} |
346 |
} |
|
|
347 |
#ifdef LEGACY_FLAC |
301 |
else if (!FLAC__file_decoder_process_single(file_info.decoder)) |
348 |
else if (!FLAC__file_decoder_process_single(file_info.decoder)) |
|
|
349 |
#else |
350 |
else if (!FLAC__stream_decoder_process_single(file_info.decoder)) |
351 |
#endif |
302 |
{ |
352 |
{ |
303 |
fprintf(stderr, "error decoding single frame!\n"); |
353 |
fprintf(stderr, "error decoding single frame!\n"); |
304 |
} |
354 |
} |
Lines 314-327
Link Here
|
314 |
} |
364 |
} |
315 |
} |
365 |
} |
316 |
|
366 |
|
|
|
367 |
#ifdef LEGACY_FLAC |
317 |
void flac_error_hdl(const FLAC__FileDecoder *dec, |
368 |
void flac_error_hdl(const FLAC__FileDecoder *dec, |
318 |
FLAC__StreamDecoderErrorStatus status, void *data) |
369 |
FLAC__StreamDecoderErrorStatus status, void *data) |
|
|
370 |
#else |
371 |
void flac_error_hdl(const FLAC__StreamDecoder *dec, |
372 |
FLAC__StreamDecoderErrorStatus status, void *data) |
373 |
#endif |
319 |
{ |
374 |
{ |
320 |
fprintf(stderr, "error handler called!\n"); |
375 |
fprintf(stderr, "error handler called!\n"); |
321 |
} |
376 |
} |
322 |
|
377 |
|
|
|
378 |
#ifdef LEGACY_FLAC |
323 |
void flac_metadata_hdl(const FLAC__FileDecoder *dec, |
379 |
void flac_metadata_hdl(const FLAC__FileDecoder *dec, |
324 |
const FLAC__StreamMetadata *meta, void *data) |
380 |
const FLAC__StreamMetadata *meta, void *data) |
|
|
381 |
#else |
382 |
void flac_metadata_hdl(const FLAC__StreamDecoder *dec, |
383 |
const FLAC__StreamMetadata *meta, void *data) |
384 |
#endif |
325 |
{ |
385 |
{ |
326 |
file_info_struct *p = (file_info_struct *) data; |
386 |
file_info_struct *p = (file_info_struct *) data; |
327 |
|
387 |
|
Lines 344-353
Link Here
|
344 |
} |
404 |
} |
345 |
} |
405 |
} |
346 |
|
406 |
|
|
|
407 |
#ifdef LEGACY_FLAC |
347 |
FLAC__StreamDecoderWriteStatus flac_write_hdl(const FLAC__FileDecoder *dec, |
408 |
FLAC__StreamDecoderWriteStatus flac_write_hdl(const FLAC__FileDecoder *dec, |
348 |
const FLAC__Frame *frame, |
409 |
const FLAC__Frame *frame, |
349 |
const FLAC__int32 * const buf[], |
410 |
const FLAC__int32 * const buf[], |
350 |
void *data) |
411 |
void *data) |
|
|
412 |
#else |
413 |
FLAC__StreamDecoderWriteStatus flac_write_hdl(const FLAC__StreamDecoder *dec, |
414 |
const FLAC__Frame *frame, |
415 |
const FLAC__int32 * const buf[], |
416 |
void *data) |
417 |
#endif |
351 |
{ |
418 |
{ |
352 |
int sample, channel, i; |
419 |
int sample, channel, i; |
353 |
uint_32 samples = frame->header.blocksize; |
420 |
uint_32 samples = frame->header.blocksize; |