View | Details | Raw Unified | Return to bug 10869
Collapse All | Expand All

(-)flac123-0.0.9/configure.ac (-2 / +2 lines)
Lines 40-48 Link Here
40
AC_PROG_CC
40
AC_PROG_CC
41
41
42
# Checks for libraries.
42
# Checks for libraries.
43
AC_CHECK_LIB(FLAC, FLAC__file_decoder_new, [haveflac=yes], [haveflac=no], -lm)
43
AC_CHECK_LIB(FLAC, FLAC__stream_decoder_new, [haveflac=yes], [haveflac=no], -lm)
44
if test "$haveflac" = "yes"; then
44
if test "$haveflac" = "yes"; then
45
	FLAC_LIBS="-lFLAC -lm"
45
	FLAC_LIBS="-lFLAC -logg -lm"
46
	AC_SUBST(FLAC_LIBS)
46
	AC_SUBST(FLAC_LIBS)
47
else
47
else
48
	AC_MSG_ERROR(FLAC required!)
48
	AC_MSG_ERROR(FLAC required!)
(-)flac123-0.0.9/flac123.c (-4 / +71 lines)
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;
(-)flac123-0.0.9/flac123.h (+11 lines)
Lines 22-34 Link Here
22
#include <limits.h>
22
#include <limits.h>
23
#include <FLAC/all.h>
23
#include <FLAC/all.h>
24
24
25
/* by LEGACY_FLAC we mean pre-1.1.3 before FLAC__FileDecoder was merged into FLAC__StreamDecoder */
26
#if !defined(FLAC_API_VERSION_CURRENT) || FLAC_API_VERSION_CURRENT < 8
27
#define LEGACY_FLAC
28
#else
29
#undef LEGACY_FLAC
30
#endif
31
25
/* string widths for printing ID3 (vorbis) data in remote mode */
32
/* string widths for printing ID3 (vorbis) data in remote mode */
26
#define VORBIS_TAG_LEN 30
33
#define VORBIS_TAG_LEN 30
27
#define VORBIS_YEAR_LEN 4
34
#define VORBIS_YEAR_LEN 4
28
35
29
/* the main data structure of the program */
36
/* the main data structure of the program */
30
typedef struct {
37
typedef struct {
38
#ifdef LEGACY_FLAC
31
    FLAC__FileDecoder *decoder;
39
    FLAC__FileDecoder *decoder;
40
#else
41
    FLAC__StreamDecoder *decoder;
42
#endif
32
43
33
    /* bits, rate, channels, byte_format */
44
    /* bits, rate, channels, byte_format */
34
    ao_sample_format sam_fmt; /* input sample's true format */
45
    ao_sample_format sam_fmt; /* input sample's true format */
(-)flac123-0.0.9/remote.c (+9 lines)
Lines 150-157 Link Here
150
		    file_info.current_sample += delta_frames;
150
		    file_info.current_sample += delta_frames;
151
		}
151
		}
152
152
153
#ifdef LEGACY_FLAC
153
		FLAC__file_decoder_seek_absolute(file_info.decoder,
154
		FLAC__file_decoder_seek_absolute(file_info.decoder,
154
						 file_info.current_sample);
155
						 file_info.current_sample);
156
#else
157
		FLAC__stream_decoder_seek_absolute(file_info.decoder,
158
						 file_info.current_sample);
159
#endif
155
            }
160
            }
156
	    /* absolute seek */
161
	    /* absolute seek */
157
            else
162
            else
Lines 161-167 Link Here
161
		file_info.elapsed_time = absolute_time;
166
		file_info.elapsed_time = absolute_time;
162
		file_info.current_sample = absolute_frame;
167
		file_info.current_sample = absolute_frame;
163
168
169
#ifdef LEGACY_FLAC
164
		FLAC__file_decoder_seek_absolute(file_info.decoder, absolute_frame);
170
		FLAC__file_decoder_seek_absolute(file_info.decoder, absolute_frame);
171
#else
172
		FLAC__stream_decoder_seek_absolute(file_info.decoder, absolute_frame);
173
#endif
165
            }
174
            }
166
175
167
        }
176
        }

Return to bug 10869