Fixed bug #297
authorSam Lantinga <slouken@libsdl.org>
Sun, 15 Jul 2007 03:38:33 +0000
changeset 35321fe62f9c4c6
parent 352 231d6e5a8325
child 354 e97cfc344dc3
Fixed bug #297

Philippe Simons - Sat Jul 14 20:33:17 PDT 2007
* Added support for Ogg Vorbis playback with Tremor (an integer decoder)
CHANGES
README
configure.in
dynamic_ogg.h
load_ogg.c
music_ogg.c
music_ogg.h
     1.1 --- a/CHANGES	Sun Jul 15 01:04:29 2007 +0000
     1.2 +++ b/CHANGES	Sun Jul 15 03:38:33 2007 +0000
     1.3 @@ -1,4 +1,6 @@
     1.4  1.2.8:
     1.5 +Philippe Simons - Sat Jul 14 20:33:17 PDT 2007
     1.6 + * Added support for Ogg Vorbis playback with Tremor (an integer decoder)
     1.7  Sam Lantinga - Sat Jul 14 07:02:09 PDT 2007
     1.8   * Fixed memory corruption in timidity resampling code
     1.9  Ryan Gordan - Tue Jul 3 10:44:29 2007 UTC
     2.1 --- a/README	Sun Jul 15 01:04:29 2007 +0000
     2.2 +++ b/README	Sun Jul 15 03:38:33 2007 +0000
     2.3 @@ -15,9 +15,13 @@
     2.4  The mixer can currently load Microsoft WAVE files and Creative Labs VOC
     2.5  files as audio samples, and can load MIDI files via Timidity and the
     2.6  following music formats via MikMod:  .MOD .S3M .IT .XM. It can load
     2.7 -Ogg Vorbis streams as music if built with the Ogg Vorbis libraries,
     2.8 +Ogg Vorbis streams as music if built with Ogg Vorbis or Tremor libraries,
     2.9  and finally it can load MP3 music using the SMPEG library.
    2.10  
    2.11 +Tremor decoding is disabled by default, you can enable it by passing
    2.12 +	--enable-music-ogg-tremor
    2.13 +to configure, or by defining OGG_MUSIC and OGG_USE_TREMOR.
    2.14 +
    2.15  The process of mixing MIDI files to wave output is very CPU intensive,
    2.16  so if playing regular WAVE files sound great, but playing MIDI files
    2.17  sound choppy, try using 8-bit audio, mono audio, or lower frequencies.
     3.1 --- a/configure.in	Sun Jul 15 01:04:29 2007 +0000
     3.2 +++ b/configure.in	Sun Jul 15 03:38:33 2007 +0000
     3.3 @@ -261,6 +261,26 @@
     3.4          fi
     3.5      fi
     3.6  fi
     3.7 +AC_ARG_ENABLE(music-ogg-tremor,
     3.8 +[  --enable-music-ogg-tremor   enable OGG music via libtremor [[default=no]]],
     3.9 +	      , enable_music_ogg_tremor=no)
    3.10 +if test x$enable_music_ogg_tremor = xyes; then
    3.11 +    AC_MSG_CHECKING(for libtremor headers)
    3.12 +    have_tremor=no
    3.13 +    AC_TRY_COMPILE([
    3.14 +     #include <tremor/ivorbiscodec.h>
    3.15 +     #include <tremor/ivorbisfile.h>
    3.16 +    ],[
    3.17 +    ],[
    3.18 +    have_tremor=yes
    3.19 +    ])
    3.20 +    AC_MSG_RESULT($have_tremor)
    3.21 +    if test x$have_tremor = xyes; then
    3.22 +        SOURCES="$SOURCES $srcdir/*_ogg.c"
    3.23 +        EXTRA_CFLAGS="$EXTRA_CFLAGS -DOGG_MUSIC -DOGG_USE_TREMOR"
    3.24 +	EXTRA_LDFLAGS="$EXTRA_LDFLAGS -lvorbisidec"
    3.25 +    fi
    3.26 +fi
    3.27  AC_ARG_ENABLE(music-mp3,
    3.28  [  --enable-music-mp3      enable MP3 music via smpeg [[default=yes]]],
    3.29                , enable_music_mp3=yes)
     4.1 --- a/dynamic_ogg.h	Sun Jul 15 01:04:29 2007 +0000
     4.2 +++ b/dynamic_ogg.h	Sun Jul 15 03:38:33 2007 +0000
     4.3 @@ -21,7 +21,11 @@
     4.4  */
     4.5  
     4.6  #ifdef OGG_MUSIC
     4.7 +#ifdef OGG_USE_TREMOR
     4.8 +#include <tremor/ivorbisfile.h>
     4.9 +#else
    4.10  #include <vorbis/vorbisfile.h>
    4.11 +#endif
    4.12  
    4.13  typedef struct {
    4.14  	int loaded;
    4.15 @@ -31,7 +35,11 @@
    4.16  	int (*ov_open)(FILE *f,OggVorbis_File *vf,char *initial,long ibytes);
    4.17  	int (*ov_open_callbacks)(void *datasource, OggVorbis_File *vf, char *initial, long ibytes, ov_callbacks callbacks);
    4.18  	ogg_int64_t (*ov_pcm_total)(OggVorbis_File *vf,int i);
    4.19 +#ifdef OGG_USE_TREMOR
    4.20 +	long (*ov_read)(OggVorbis_File *vf,char *buffer,int length, int *bitstream);
    4.21 +#else
    4.22  	long (*ov_read)(OggVorbis_File *vf,char *buffer,int length, int bigendianp,int word,int sgned,int *bitstream);
    4.23 +#endif
    4.24  	int (*ov_time_seek)(OggVorbis_File *vf,double pos);
    4.25  } vorbis_loader;
    4.26  
     5.1 --- a/load_ogg.c	Sun Jul 15 01:04:29 2007 +0000
     5.2 +++ b/load_ogg.c	Sun Jul 15 03:38:33 2007 +0000
     5.3 @@ -117,9 +117,15 @@
     5.4  
     5.5      buf = *audio_buf;
     5.6      to_read = *audio_len;
     5.7 +#ifdef OGG_USE_TREMOR
     5.8 +    for (read = vorbis.ov_read(&vf, (char *)buf, to_read, &bitstream);
     5.9 +	 read > 0;
    5.10 +	 read = vorbis.ov_read(&vf, (char *)buf, to_read, &bitstream))
    5.11 +#else
    5.12      for (read = vorbis.ov_read(&vf, (char *)buf, to_read, 0/*LE*/, 2/*16bit*/, 1/*signed*/, &bitstream);
    5.13           read > 0;
    5.14           read = vorbis.ov_read(&vf, (char *)buf, to_read, 0, 2, 1, &bitstream))
    5.15 +#endif	 
    5.16      {
    5.17          if (read == OV_HOLE || read == OV_EBADLINK)
    5.18              break; /* error */
     6.1 --- a/music_ogg.c	Sun Jul 15 01:04:29 2007 +0000
     6.2 +++ b/music_ogg.c	Sun Jul 15 03:38:33 2007 +0000
     6.3 @@ -165,7 +165,11 @@
     6.4  	char data[4096];
     6.5  	SDL_AudioCVT *cvt;
     6.6  
     6.7 +#ifdef OGG_USE_TREMOR
     6.8 +	len = vorbis.ov_read(&music->vf, data, sizeof(data), &section);
     6.9 +#else
    6.10  	len = vorbis.ov_read(&music->vf, data, sizeof(data), 0, 2, 1, &section);
    6.11 +#endif
    6.12  	if ( len <= 0 ) {
    6.13  		if ( len == 0 ) {
    6.14  			music->playing = 0;
     7.1 --- a/music_ogg.h	Sun Jul 15 01:04:29 2007 +0000
     7.2 +++ b/music_ogg.h	Sun Jul 15 03:38:33 2007 +0000
     7.3 @@ -26,7 +26,11 @@
     7.4  
     7.5  /* This file supports Ogg Vorbis music streams */
     7.6  
     7.7 +#ifdef OGG_USE_TREMOR
     7.8 +#include <tremor/ivorbisfile.h>
     7.9 +#else
    7.10  #include <vorbis/vorbisfile.h>
    7.11 +#endif
    7.12  
    7.13  typedef struct {
    7.14  	int playing;