# HG changeset patch # User Ryan C. Gordon # Date 1161997030 0 # Node ID 46d5f399cb3534c764ca0518c2d2dfce47e9ee2c # Parent 6c4f29fc3d877a4150bf3350d114491a3399650c Patch from stable-1.0 branch r528:529. diff -r 6c4f29fc3d87 -r 46d5f399cb35 CHANGELOG --- a/CHANGELOG Fri Jul 28 06:29:19 2006 +0000 +++ b/CHANGELOG Sat Oct 28 00:57:10 2006 +0000 @@ -2,6 +2,8 @@ * CHANGELOG. */ +10272006 - FLAC 1.1.3 breaks their API _again_, so we try to do the right + thing at build time. (Thanks, Josh!). 07282006 - Ogg Vorbis decoding defaults to system byte order now. 05122006 - Patched to get mpglib compiling again (thanks, Sam!). 03312006 - Wedged in a temporary hack for Speex rewinding. diff -r 6c4f29fc3d87 -r 46d5f399cb35 CREDITS --- a/CREDITS Fri Jul 28 06:29:19 2006 +0000 +++ b/CREDITS Sat Oct 28 00:57:10 2006 +0000 @@ -53,6 +53,9 @@ Bugfixes and stuff: Eric Wing +FLAC 1.1.3 updates: + Josh Coalson + Other stuff: Your name here! Patches go to icculus@clutteredmind.org ... diff -r 6c4f29fc3d87 -r 46d5f399cb35 configure.in --- a/configure.in Fri Jul 28 06:29:19 2006 +0000 +++ b/configure.in Sat Oct 28 00:57:10 2006 +0000 @@ -151,28 +151,6 @@ AC_DEFINE(SOUND_SUPPORTS_MIDI, 1, [Define if MIDI support is desired.]) fi - -dnl Note that we intentionally look for a symbol in FLAC 1.0.4, since the -dnl FLAC developers tend to break their API with every release, so we're -dnl checking for the latest-and-greatest here so we don't have to support -dnl obsolete versions. - -dnl Hooray for shitty autoconf bugs! -x="C__seekable_stream_decoder_process_single" -flcsym="FLA$x" -dnl Check for libFLAC -AC_ARG_ENABLE(flac, -[ --enable-flac enable FLAC decoding via libFLAC [default=yes]], - , enable_flac=yes) -if test x$enable_flac = xyes; then - AC_CHECK_HEADER(FLAC/stream_decoder.h, have_flac_hdr=yes) - AC_CHECK_LIB(FLAC, $flcsym, have_flac_lib=yes) - if test x$have_flac_hdr = xyes -a x$have_flac_lib = xyes; then - LIBS="$LIBS -lFLAC" - AC_DEFINE(SOUND_SUPPORTS_FLAC, 1, [Define if FLAC support is desired.]) - fi -fi - dnl Check for SMPEG AC_ARG_ENABLE(smpeg, [ --enable-smpeg enable MP3 decoding via smpeg [default=yes]], @@ -230,20 +208,25 @@ fi fi -dnl Check for ogg +AC_CHECK_HEADER(ogg/ogg.h, have_ogg_hdr=yes) +AC_CHECK_LIB(ogg, ogg_sync_init, have_ogg_lib=yes) +have_ogg=no +if test x$have_ogg_hdr = xyes -a x$have_ogg_lib = xyes; then + have_ogg=yes +fi + +dnl !!! FIXME: should be --enable-vorbis. +dnl Check for Ogg Vorbis AC_ARG_ENABLE(ogg, [ --enable-ogg enable OGG decoding via libvorbis [default=yes]], , enable_ogg=yes) if test x$enable_ogg = xyes; then - AC_CHECK_HEADER(ogg/ogg.h, have_ogg_hdr=yes) - AC_CHECK_LIB(ogg, ogg_sync_init, have_ogg_lib=yes) AC_CHECK_HEADER(vorbis/codec.h, have_vorbis_hdr=yes) AC_CHECK_LIB(vorbis, vorbis_info_init, have_vorbis_lib=yes) AC_CHECK_HEADER(vorbis/vorbisfile.h, have_vorbisfile_hdr=yes) AC_CHECK_LIB(vorbisfile, ov_open_callbacks, have_vorbisfile_lib=yes) - have_vorbis=no - if test x$have_ogg_hdr = xyes -a x$have_ogg_lib = xyes; then + if test x$have_ogg = xyes; then if test x$have_vorbis_hdr = xyes -a x$have_vorbis_lib = xyes; then if test x$have_vorbisfile_hdr = xyes -a x$have_vorbisfile_lib = xyes; then have_vorbis=yes @@ -258,6 +241,34 @@ fi fi + +dnl Note that we intentionally look for a symbol in FLAC 1.0.4, since the +dnl FLAC developers tend to break their API with every release, so we're +dnl checking for the latest-and-greatest here so we don't have to support +dnl obsolete versions. +dnl Starting with FLAC 1.1.3: +dnl libFLAC supports Ogg FLAC (no more libOggFLAC) so we also need -logg +dnl the libFLAC .so version is also #defined in FLAC/export.h + +dnl Hooray for shitty autoconf bugs! +x="C__stream_decoder_process_single" +flcsym="FLA$x" +dnl Check for libFLAC +AC_ARG_ENABLE(flac, +[ --enable-flac enable FLAC decoding via libFLAC [default=yes]], + , enable_flac=yes) +if test x$enable_flac = xyes; then + AC_CHECK_HEADER(FLAC/stream_decoder.h, have_flac_hdr=yes) + AC_CHECK_LIB(FLAC, $flcsym, have_flac_lib=yes) + if test x$have_ogg = xyes; then + if test x$have_flac_hdr = xyes -a x$have_flac_lib = xyes; then + LIBS="$LIBS -lFLAC -logg" + AC_DEFINE(SOUND_SUPPORTS_FLAC, 1, [Define if FLAC support is desired.]) + fi + fi +fi + + dnl Check for speex AC_ARG_ENABLE(speex, [ --enable-speex enable SPX decoding via libspeex [default=yes]], diff -r 6c4f29fc3d87 -r 46d5f399cb35 decoders/flac.c --- a/decoders/flac.c Fri Jul 28 06:29:19 2006 +0000 +++ b/decoders/flac.c Sat Oct 28 00:57:10 2006 +0000 @@ -44,6 +44,16 @@ #define __SDL_SOUND_INTERNAL__ #include "SDL_sound_internal.h" +#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 +#else +#undef LEGACY_FLAC +#endif + +#ifdef LEGACY_FLAC #include #define D_END_OF_STREAM FLAC__SEEKABLE_STREAM_DECODER_END_OF_STREAM @@ -80,6 +90,34 @@ typedef FLAC__SeekableStreamDecoderSeekStatus d_seek_status_t; typedef FLAC__SeekableStreamDecoderTellStatus d_tell_status_t; typedef FLAC__SeekableStreamDecoderLengthStatus d_length_status_t; +#else +#include + +#define D_END_OF_STREAM FLAC__STREAM_DECODER_END_OF_STREAM + +#define d_new() FLAC__stream_decoder_new() +#define d_process_metadata(x) FLAC__stream_decoder_process_until_end_of_metadata(x) +#define d_process_one_frame(x) FLAC__stream_decoder_process_single(x) +#define d_get_state(x) FLAC__stream_decoder_get_state(x) +#define d_finish(x) FLAC__stream_decoder_finish(x) +#define d_delete(x) FLAC__stream_decoder_delete(x) + +typedef FLAC__StreamDecoder decoder_t; +typedef FLAC__StreamDecoderReadStatus d_read_status_t; + +#define D_SEEK_STATUS_OK FLAC__STREAM_DECODER_SEEK_STATUS_OK +#define D_SEEK_STATUS_ERROR FLAC__STREAM_DECODER_SEEK_STATUS_ERROR +#define D_TELL_STATUS_OK FLAC__STREAM_DECODER_TELL_STATUS_OK +#define D_TELL_STATUS_ERROR FLAC__STREAM_DECODER_TELL_STATUS_ERROR +#define D_LENGTH_STATUS_OK FLAC__STREAM_DECODER_LENGTH_STATUS_OK +#define D_LENGTH_STATUS_ERROR FLAC__STREAM_DECODER_LENGTH_STATUS_ERROR + +#define d_seek_absolute(x, y) FLAC__stream_decoder_seek_absolute(x, y) + +typedef FLAC__StreamDecoderSeekStatus d_seek_status_t; +typedef FLAC__StreamDecoderTellStatus d_tell_status_t; +typedef FLAC__StreamDecoderLengthStatus d_length_status_t; +#endif #define D_WRITE_CONTINUE FLAC__STREAM_DECODER_WRITE_STATUS_CONTINUE #define D_READ_END_OF_STREAM FLAC__STREAM_DECODER_READ_STATUS_END_OF_STREAM @@ -141,9 +179,15 @@ } /* free_flac */ +#ifdef LEGACY_FLAC static d_read_status_t read_callback( const decoder_t *decoder, FLAC__byte buffer[], unsigned int *bytes, void *client_data) +#else +static d_read_status_t read_callback( + const decoder_t *decoder, FLAC__byte buffer[], + size_t *bytes, void *client_data) +#endif { flac_t *f = (flac_t *) client_data; Uint32 retval; @@ -416,6 +460,7 @@ BAIL_MACRO(ERR_OUT_OF_MEMORY, 0); } /* if */ +#ifdef LEGACY_FLAC d_set_read_callback(decoder, read_callback); d_set_write_callback(decoder, write_callback); d_set_metadata_callback(decoder, metadata_callback); @@ -426,6 +471,7 @@ d_set_eof_callback(decoder, eof_callback); d_set_client_data(decoder, f); +#endif f->rw = internal->rw; f->sample = sample; @@ -434,7 +480,15 @@ f->is_flac = 0 /* !!! FIXME: should be "has_extension", not "0". */; internal->decoder_private = f; + /* really should check the init return value here: */ +#ifdef LEGACY_FLAC d_init(decoder); +#else + FLAC__stream_decoder_init_stream(decoder, read_callback, seek_callback, + tell_callback, length_callback, + eof_callback, write_callback, + metadata_callback, error_callback, f); +#endif sample->flags = SOUND_SAMPLEFLAG_NONE;