--- SDL_sound-1.0.1/decoders/flac.c.flac	2003-03-10 23:44:14.000000000 +0100
+++ SDL_sound-1.0.1/decoders/flac.c	2006-12-11 18:37:35.000000000 +0100
@@ -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;
 
--- SDL_sound-1.0.1/configure.in.flac	2006-12-11 18:38:34.000000000 +0100
+++ SDL_sound-1.0.1/configure.in	2006-12-11 18:40:19.000000000 +0100
@@ -71,10 +71,10 @@
     CFLAGS="-O0"
   fi
   CFLAGS="$CFLAGS -Werror"
-  AC_DEFINE(DEBUG)
-  AC_DEFINE(DEBUG_CHATTER)
+  AC_DEFINE(DEBUG, 1, [Define for debug builds.])
+  AC_DEFINE(DEBUG_CHATTER, 1, [Define for debug build chattering.])
 else
-  AC_DEFINE(NDEBUG)
+  AC_DEFINE(NDEBUG, 1, [Define to disable debugging.])
 fi
 
 
@@ -91,12 +91,13 @@
 CFLAGS="$CFLAGS $SDL_CFLAGS"
 LIBS="$LIBS $SDL_LIBS"
 
+
 dnl Check for voc decoder inclusion...
 AC_ARG_ENABLE(voc,
 [  --enable-voc               enable VOC decoding [default=yes]],
               , enable_voc=yes)
 if test x$enable_voc = xyes; then
-    AC_DEFINE(SOUND_SUPPORTS_VOC)
+    AC_DEFINE(SOUND_SUPPORTS_VOC, 1, [Define if VOC support is desired.])
 fi
 
 
@@ -105,7 +106,7 @@
 [  --enable-wav               enable WAV decoding [default=yes]],
               , enable_wav=yes)
 if test x$enable_wav = xyes; then
-    AC_DEFINE(SOUND_SUPPORTS_WAV)
+    AC_DEFINE(SOUND_SUPPORTS_WAV, 1, [Define if WAV support is desired.])
 fi
 
 
@@ -114,7 +115,7 @@
 [  --enable-raw               enable raw audio "decoding" [default=yes]],
               , enable_raw=yes)
 if test x$enable_raw = xyes; then
-    AC_DEFINE(SOUND_SUPPORTS_RAW)
+    AC_DEFINE(SOUND_SUPPORTS_RAW, 1, [Define if RAW support is desired.])
 fi
 
 
@@ -123,7 +124,7 @@
 [  --enable-aiff              enable AIFF decoding [default=yes]],
               , enable_aiff=yes)
 if test x$enable_aiff = xyes; then
-    AC_DEFINE(SOUND_SUPPORTS_AIFF)
+    AC_DEFINE(SOUND_SUPPORTS_AIFF, 1, [Define if AIFF support is desired.])
 fi
 
 dnl Check for au decoder inclusion
@@ -131,7 +132,7 @@
 [  --enable-au                enable AU decoding [default=yes]],
               , enable_au=yes)
 if test x$enable_au = xyes; then
-    AC_DEFINE(SOUND_SUPPORTS_AU)
+    AC_DEFINE(SOUND_SUPPORTS_AU, 1, [Define if AU support is desired.])
 fi
 
 dnl Check for shn decoder inclusion...
@@ -139,7 +140,7 @@
 [  --enable-shn               enable SHN decoding [default=yes]],
               , enable_shn=yes)
 if test x$enable_shn = xyes; then
-    AC_DEFINE(SOUND_SUPPORTS_SHN)
+    AC_DEFINE(SOUND_SUPPORTS_SHN, 1, [Define if SHN support is desired.])
 fi
 
 dnl Check for the MIDI decoder...
@@ -147,29 +148,7 @@
 [  --enable-midi              enable software MIDI music [default=yes]],
               , enable_midi=yes)
 if test x$enable_midi = xyes; then
-  AC_DEFINE(SOUND_SUPPORTS_MIDI)
-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)
-  fi
+  AC_DEFINE(SOUND_SUPPORTS_MIDI, 1, [Define if MIDI support is desired.])
 fi
 
 dnl Check for SMPEG
@@ -177,12 +156,11 @@
 [  --enable-smpeg             enable MP3 decoding via smpeg [default=yes]],
               , enable_smpeg=yes)
 if test x$enable_smpeg = xyes; then
-  SMPEG_VERSION=0.4.3
-  AM_PATH_SMPEG($SMPEG_VERSION, , no_smpeg=yes)
-  if test "x$no_smpeg" = "x" ; then
-    CFLAGS="$CFLAGS $SMPEG_CFLAGS"
-    LIBS="$LIBS $SMPEG_LIBS"
-    AC_DEFINE(SOUND_SUPPORTS_SMPEG)
+  AC_CHECK_HEADER(smpeg.h, have_smpeg_hdr=yes)
+  AC_CHECK_LIB(smpeg, SMPEG_new, have_smpeg_lib=yes)
+  if test x$have_smpeg_hdr = xyes -a x$have_smpeg_lib = xyes; then
+    LIBS="$LIBS -lsmpeg"
+    AC_DEFINE(SOUND_SUPPORTS_SMPEG, 1, [Define if SMPEG support is desired.])
   fi
 fi
 
@@ -191,7 +169,7 @@
 [  --enable-mpglib            enable MP3 decoding internally [default=yes]],
               , enable_mpglib=yes)
 if test x$enable_mpglib = xyes; then
-  AC_DEFINE(SOUND_SUPPORTS_MPGLIB)
+  AC_DEFINE(SOUND_SUPPORTS_MPGLIB, 1, [Define if MPGLIB support is desired.])
 fi
 
 
@@ -200,12 +178,11 @@
 [  --enable-mikmod            enable MOD decoding via mikmod [default=yes]],
               , enable_mikmod=yes)
 if test x$enable_mikmod = xyes; then
-  AM_PATH_LIBMIKMOD
-  if test "x$no_libmikmod" = "x" ; then
-    CFLAGS="$CFLAGS $LIBMIKMOD_CFLAGS"
-    LIBS="$LIBS $LIBMIKMOD_LIBS"
-    LDADD="$LDADD $LIBMIKMOD_LDADD"
-    AC_DEFINE(SOUND_SUPPORTS_MIKMOD)
+  AC_CHECK_HEADER(mikmod.h, have_mikmod_hdr=yes)
+  AC_CHECK_LIB(mikmod, MikMod_RegisterDriver, have_mikmod_lib=yes)
+  if test x$have_mikmod_hdr = xyes -a x$have_mikmod_lib = xyes; then
+    LIBS="$LIBS -lmikmod"
+    AC_DEFINE(SOUND_SUPPORTS_MIKMOD, 1, [Define if MIKMOD support is desired.])
   fi
 fi
 
@@ -214,27 +191,84 @@
 [  --enable-modplug           enable MOD decoding via modplug [default=yes]],
               , enable_modplug=yes)
 if test x$enable_modplug = xyes; then
+  have_modplug_hdr=no
   AC_CHECK_HEADER(modplug.h, have_modplug_hdr=yes)
+  if test x$have_modplug_hdr = xno; then
+    AC_CHECK_HEADER(libmodplug/modplug.h, have_modplug_hdr=yes)
+    if test x$have_modplug_hdr = xyes; then
+      have_modplug_hdr=yes
+      AC_DEFINE(SOUND_MODPLUG_IN_OWN_PATH, 1, [Define if modplug header is in own directory.])
+    fi
+  fi
+
   AC_CHECK_LIB(modplug, ModPlug_Load, have_modplug_lib=yes)
   if test x$have_modplug_hdr = xyes -a x$have_modplug_lib = xyes; then
     LIBS="$LIBS -lmodplug"
-    AC_DEFINE(SOUND_SUPPORTS_MODPLUG)
+    AC_DEFINE(SOUND_SUPPORTS_MODPLUG, 1, [Define if MODPLUG support is desired.])
   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
-  AM_PATH_VORBIS
-  if test "x$no_vorbis" = "x" ; then
-    CFLAGS="$CFLAGS $VORBIS_CFLAGS"
-    LIBS="$LIBS $VORBIS_LIBS $VORBISFILE_LIBS $VORBISENC_LIBS"
-    AC_DEFINE(SOUND_SUPPORTS_OGG)
+  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 = 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
+      fi
+    fi
+  fi
+
+  if test x$have_vorbis = xyes; then
+    CFLAGS="$CFLAGS"
+    LIBS="$LIBS -logg -lvorbis -lvorbisfile"
+    AC_DEFINE(SOUND_SUPPORTS_OGG, 1, [Define if OGG support is desired.])
+  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]],
@@ -246,7 +280,7 @@
   AC_CHECK_LIB(speex, speex_bits_init, have_speex_lib=yes)
   if test "x$have_ogg_hdr" = "xyes" -a "x$have_ogg_lib" = "xyes" -a "x$have_speex_hdr" = "xyes" -a "x$have_speex_lib" = "xyes"; then
     LIBS="$LIBS -logg -lspeex"
-    AC_DEFINE(SOUND_SUPPORTS_SPEEX)
+    AC_DEFINE(SOUND_SUPPORTS_SPEEX, 1, [Define if SPEEX support is desired.])
   fi
 fi
 
@@ -270,7 +304,7 @@
 [  --enable-altcvt            enable EXPERIMENTAL audio converter [default=no]],
               , enable_altcvt=no)
 if test x$enable_altcvt = xyes; then
-  AC_DEFINE(SOUND_USE_ALTCVT)
+  AC_DEFINE(SOUND_USE_ALTCVT, 1, [Define to use alternate audio converter.])
 fi
 
 
