diff -ru --exclude=Makefile.in --exclude=Makefile bossogg-0.13.6/boss3/bossao/bossao.c bossogg-0.13.6-b2/boss3/bossao/bossao.c --- bossogg-0.13.6/boss3/bossao/bossao.c 2004-04-01 17:44:26.000000000 -0800 +++ bossogg-0.13.6-b2/boss3/bossao/bossao.c 2006-10-30 23:25:47.000000000 -0800 @@ -46,7 +46,11 @@ #endif #ifdef HAVE_FLAC +#ifdef LEGACY_FLAC #include +#else +#include +#endif #include "flac.h" #endif diff -ru --exclude=Makefile.in --exclude=Makefile bossogg-0.13.6/boss3/bossao/bossao.h bossogg-0.13.6-b2/boss3/bossao/bossao.h --- bossogg-0.13.6/boss3/bossao/bossao.h 2004-04-01 17:44:26.000000000 -0800 +++ bossogg-0.13.6-b2/boss3/bossao/bossao.h 2006-10-30 23:17:54.000000000 -0800 @@ -38,6 +38,14 @@ #define RATE 44100 +#if defined(HAVE_FLAC) && !defined(LEGACY_FLAC) +#include +// FLAC 1.1.3 has FLAC_API_VERSION_CURRENT == 8 */ +#if !defined(FLAC_API_VERSION_CURRENT) || FLAC_API_VERSION_CURRENT < 8 +#define LEGACY_FLAC +#endif +#endif + #ifdef __cplusplus extern "C" { #endif @@ -50,7 +58,11 @@ struct mp3_t *mp3; #endif #ifdef HAVE_FLAC +#ifdef LEGACY_FLAC struct FLAC__FileDecoder *flac; +#else + struct FLAC__StreamDecoder *flac; +#endif #endif } songlib_s; diff -ru --exclude=Makefile.in --exclude=Makefile bossogg-0.13.6/boss3/bossao/flac.c bossogg-0.13.6-b2/boss3/bossao/flac.c --- bossogg-0.13.6/boss3/bossao/flac.c 2004-04-01 17:44:26.000000000 -0800 +++ bossogg-0.13.6-b2/boss3/bossao/flac.c 2006-10-30 23:26:07.000000000 -0800 @@ -22,7 +22,19 @@ #include #include +#if !defined(LEGACY_FLAC) +#include +// FLAC 1.1.3 has FLAC_API_VERSION_CURRENT == 8 */ +#if !defined(FLAC_API_VERSION_CURRENT) || FLAC_API_VERSION_CURRENT < 8 +#define LEGACY_FLAC +#endif +#endif + +#ifdef LEGACY_FLAC #include +#else +#include +#endif #include #include #include @@ -32,15 +44,17 @@ #include "bossao.h" #include "flac.h" -static FLAC__bool eof_callback (const FLAC__SeekableStreamDecoder *decoder, void *client_data) -{ - //printf ("FLAC got eof\n"); -} - +#ifdef LEGACY_FLAC static FLAC__StreamDecoderWriteStatus write_callback (const FLAC__FileDecoder *decoder, const FLAC__Frame *frame, const FLAC__int32 *const buffer[], void *client_data) +#else +static FLAC__StreamDecoderWriteStatus write_callback (const FLAC__StreamDecoder *decoder, + const FLAC__Frame *frame, + const FLAC__int32 *const buffer[], + void *client_data) +#endif { //printf ("in write\n"); size_t size = frame->header.blocksize * frame->header.channels; @@ -76,16 +90,28 @@ return FLAC__STREAM_DECODER_WRITE_STATUS_CONTINUE; } +#ifdef LEGACY_FLAC static void metadata_callback (const FLAC__FileDecoder *decoder, const FLAC__StreamMetadata *metadata, void *client_data) +#else +static void metadata_callback (const FLAC__StreamDecoder *decoder, + const FLAC__StreamMetadata *metadata, + void *client_data) +#endif { //printf ("Doing nothing in metadata callback\n"); } +#ifdef LEGACY_FLAC static void error_callback (const FLAC__FileDecoder *decoder, const FLAC__StreamDecoderErrorStatus status, void *client_data) +#else +static void error_callback (const FLAC__StreamDecoder *decoder, + const FLAC__StreamDecoderErrorStatus status, + void *client_data) +#endif { printf ("A FLAC error occured\n"); } @@ -93,9 +119,15 @@ void *prepare_flac (song_s *song, char *filename) { //song->songlib->flac = malloc (sizeof (FLAC__FileDecoder)); +#ifdef LEGACY_FLAC song->songlib->flac = FLAC__file_decoder_new (); FLAC__FileDecoder *decoder = (FLAC__FileDecoder *)song->songlib->flac; +#else + song->songlib->flac = FLAC__stream_decoder_new (); + FLAC__StreamDecoder *decoder = (FLAC__StreamDecoder *)song->songlib->flac; +#endif +#ifdef LEGACY_FLAC /* callbacks here? */ FLAC__file_decoder_set_write_callback (decoder, write_callback); FLAC__file_decoder_set_metadata_callback (decoder, metadata_callback); @@ -108,13 +140,21 @@ FLAC__SeekableStreamDecoderState state = FLAC__file_decoder_init (decoder); //printf ("inited\n"); if (state != FLAC__FILE_DECODER_OK) { - printf ("Problem initizlizing FLAC file decoder: %d", state); + printf ("Problem initializing FLAC file decoder: %d", state); if (state == FLAC__FILE_DECODER_ALREADY_INITIALIZED) printf ("already inited\n"); if (state == FLAC__FILE_DECODER_SEEKABLE_STREAM_DECODER_ERROR) printf ("seekable decoder error\n"); return NULL; } +#else + FLAC__StreamDecoderInitStatus init_status = FLAC__stream_decoder_init_file (decoder, filename, write_callback, metadata_callback, error_callback, song); + //printf ("inited\n"); + if (init_status != FLAC__STREAM_DECODER_INIT_STATUS_OK) { + printf ("Problem initializing FLAC decoder: %s\n", FLAC__StreamDecoderInitStatusString[init_status]); + return NULL; + } +#endif FLAC__Metadata_SimpleIterator *it = FLAC__metadata_simple_iterator_new (); if (!FLAC__metadata_simple_iterator_init (it, filename, 1, 0)) { @@ -142,12 +182,22 @@ int destroy_flac (song_s *song) { +#ifdef LEGACY_FLAC FLAC__FileDecoder *decoder = (FLAC__FileDecoder *)song->songlib->flac; +#else + FLAC__StreamDecoder *decoder = (FLAC__StreamDecoder *)song->songlib->flac; +#endif if (decoder != NULL) { +#ifdef LEGACY_FLAC FLAC__file_decoder_finish (decoder); /* seperate this somehow? */ FLAC__file_decoder_delete (decoder); +#else + FLAC__stream_decoder_finish (decoder); + /* seperate this somehow? */ + FLAC__stream_decoder_delete (decoder); +#endif //free (decoder); decoder = NULL; } @@ -157,15 +207,30 @@ long chunk_play_flac (song_s *song, char *buffer) { +#ifdef LEGACY_FLAC FLAC__FileDecoder *decoder = (FLAC__FileDecoder *)song->songlib->flac; +#else + FLAC__StreamDecoder *decoder = (FLAC__StreamDecoder *)song->songlib->flac; +#endif //printf ("trying to play a chunk %x\n", decoder); +#ifdef LEGACY_FLAC FLAC__file_decoder_process_single (decoder); +#else + FLAC__stream_decoder_process_single (decoder); +#endif //printf ("done chunking\n"); +#ifdef LEGACY_FLAC if (FLAC__file_decoder_get_state (decoder) == FLAC__FILE_DECODER_END_OF_FILE) { //printf ("flac reached end of file\n"); return 0; } +#else + if (FLAC__stream_decoder_get_state (decoder) == FLAC__STREAM_DECODER_END_OF_STREAM) { + //printf ("flac reached end of file\n"); + return 0; + } +#endif return 1; } diff -ru --exclude=Makefile.in --exclude=Makefile bossogg-0.13.6/boss3/bossao/flac.h bossogg-0.13.6-b2/boss3/bossao/flac.h --- bossogg-0.13.6/boss3/bossao/flac.h 2004-04-01 17:44:26.000000000 -0800 +++ bossogg-0.13.6-b2/boss3/bossao/flac.h 2006-10-30 16:59:06.000000000 -0800 @@ -17,8 +17,20 @@ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ +#if !defined(LEGACY_FLAC) +#include +// FLAC 1.1.3 has FLAC_API_VERSION_CURRENT == 8 */ +#if !defined(FLAC_API_VERSION_CURRENT) || FLAC_API_VERSION_CURRENT < 8 +#define LEGACY_FLAC +#endif +#endif + typedef struct flac_t { +#ifdef LEGACY_FLAC FLAC__FileDecoder *decoder; +#else + FLAC__StreamDecoder *decoder; +#endif } flac_s;