Mercurial > SDL_sound_CoreAudio
changeset 515:c5f184b4b2cd stable-1.0
Updated to libFLAC 1.1.3 API.
author | Ryan C. Gordon <icculus@icculus.org> |
---|---|
date | Sat, 28 Oct 2006 00:53:45 +0000 |
parents | ef0d98d55865 |
children | 0f5888f9aef7 |
files | CHANGELOG CREDITS configure.in decoders/flac.c |
diffstat | 4 files changed, 98 insertions(+), 28 deletions(-) [+] |
line wrap: on
line diff
--- a/CHANGELOG Fri May 12 14:43:27 2006 +0000 +++ b/CHANGELOG Sat Oct 28 00:53:45 2006 +0000 @@ -2,7 +2,9 @@ * CHANGELOG. */ -05122005 - Patched to get mpglib compiling again (thanks, Sam!). +10272006 - FLAC 1.1.3 breaks their API _again_, so we try to do the right + thing at build time. (Thanks, Josh!). +05122006 - Patched to get mpglib compiling again (thanks, Sam!). 12172005 - Fixed gcc4 whining in playsound_simple.c. 12062005 - Trimmed a bunch of junk out of the build system, and now it works on Mac OS X again.
--- a/CREDITS Fri May 12 14:43:27 2006 +0000 +++ b/CREDITS Sat Oct 28 00:53:45 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 ...
--- a/configure.in Fri May 12 14:43:27 2006 +0000 +++ b/configure.in Sat Oct 28 00:53:45 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]],
--- a/decoders/flac.c Fri May 12 14:43:27 2006 +0000 +++ b/decoders/flac.c Sat Oct 28 00:53:45 2006 +0000 @@ -44,6 +44,16 @@ #define __SDL_SOUND_INTERNAL__ #include "SDL_sound_internal.h" +#include <FLAC/export.h> + +/* 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 <FLAC/seekable_stream_decoder.h> #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 <FLAC/stream_decoder.h> + +#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; @@ -400,6 +444,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); @@ -410,6 +455,7 @@ d_set_eof_callback(decoder, eof_callback); d_set_client_data(decoder, f); +#endif f->rw = internal->rw; f->sample = sample; @@ -418,7 +464,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;