Skip to content

Commit

Permalink
Fixed bug #297
Browse files Browse the repository at this point in the history
Philippe Simons - Sat Jul 14 20:33:17 PDT 2007
 * Added support for Ogg Vorbis playback with Tremor (an integer decoder)
  • Loading branch information
slouken committed Jul 15, 2007
1 parent 98ce09d commit 5cd8b9b
Show file tree
Hide file tree
Showing 7 changed files with 49 additions and 1 deletion.
2 changes: 2 additions & 0 deletions CHANGES
@@ -1,4 +1,6 @@
1.2.8:
Philippe Simons - Sat Jul 14 20:33:17 PDT 2007
* Added support for Ogg Vorbis playback with Tremor (an integer decoder)
Sam Lantinga - Sat Jul 14 07:02:09 PDT 2007
* Fixed memory corruption in timidity resampling code
Ryan Gordan - Tue Jul 3 10:44:29 2007 UTC
Expand Down
6 changes: 5 additions & 1 deletion README
Expand Up @@ -15,9 +15,13 @@ for documentation on this mixer library.
The mixer can currently load Microsoft WAVE files and Creative Labs VOC
files as audio samples, and can load MIDI files via Timidity and the
following music formats via MikMod: .MOD .S3M .IT .XM. It can load
Ogg Vorbis streams as music if built with the Ogg Vorbis libraries,
Ogg Vorbis streams as music if built with Ogg Vorbis or Tremor libraries,
and finally it can load MP3 music using the SMPEG library.

Tremor decoding is disabled by default, you can enable it by passing
--enable-music-ogg-tremor
to configure, or by defining OGG_MUSIC and OGG_USE_TREMOR.

The process of mixing MIDI files to wave output is very CPU intensive,
so if playing regular WAVE files sound great, but playing MIDI files
sound choppy, try using 8-bit audio, mono audio, or lower frequencies.
Expand Down
20 changes: 20 additions & 0 deletions configure.in
Expand Up @@ -261,6 +261,26 @@ AC_HELP_STRING([--enable-music-ogg-shared], [dynamically load Ogg Vorbis support
fi
fi
fi
AC_ARG_ENABLE(music-ogg-tremor,
[ --enable-music-ogg-tremor enable OGG music via libtremor [[default=no]]],
, enable_music_ogg_tremor=no)
if test x$enable_music_ogg_tremor = xyes; then
AC_MSG_CHECKING(for libtremor headers)
have_tremor=no
AC_TRY_COMPILE([
#include <tremor/ivorbiscodec.h>
#include <tremor/ivorbisfile.h>
],[
],[
have_tremor=yes
])
AC_MSG_RESULT($have_tremor)
if test x$have_tremor = xyes; then
SOURCES="$SOURCES $srcdir/*_ogg.c"
EXTRA_CFLAGS="$EXTRA_CFLAGS -DOGG_MUSIC -DOGG_USE_TREMOR"
EXTRA_LDFLAGS="$EXTRA_LDFLAGS -lvorbisidec"
fi
fi
AC_ARG_ENABLE(music-mp3,
[ --enable-music-mp3 enable MP3 music via smpeg [[default=yes]]],
, enable_music_mp3=yes)
Expand Down
8 changes: 8 additions & 0 deletions dynamic_ogg.h
Expand Up @@ -21,7 +21,11 @@
*/

#ifdef OGG_MUSIC
#ifdef OGG_USE_TREMOR
#include <tremor/ivorbisfile.h>
#else
#include <vorbis/vorbisfile.h>
#endif

typedef struct {
int loaded;
Expand All @@ -31,7 +35,11 @@ typedef struct {
int (*ov_open)(FILE *f,OggVorbis_File *vf,char *initial,long ibytes);
int (*ov_open_callbacks)(void *datasource, OggVorbis_File *vf, char *initial, long ibytes, ov_callbacks callbacks);
ogg_int64_t (*ov_pcm_total)(OggVorbis_File *vf,int i);
#ifdef OGG_USE_TREMOR
long (*ov_read)(OggVorbis_File *vf,char *buffer,int length, int *bitstream);
#else
long (*ov_read)(OggVorbis_File *vf,char *buffer,int length, int bigendianp,int word,int sgned,int *bitstream);
#endif
int (*ov_time_seek)(OggVorbis_File *vf,double pos);
} vorbis_loader;

Expand Down
6 changes: 6 additions & 0 deletions load_ogg.c
Expand Up @@ -117,9 +117,15 @@ SDL_AudioSpec *Mix_LoadOGG_RW (SDL_RWops *src, int freesrc,

buf = *audio_buf;
to_read = *audio_len;
#ifdef OGG_USE_TREMOR
for (read = vorbis.ov_read(&vf, (char *)buf, to_read, &bitstream);
read > 0;
read = vorbis.ov_read(&vf, (char *)buf, to_read, &bitstream))
#else
for (read = vorbis.ov_read(&vf, (char *)buf, to_read, 0/*LE*/, 2/*16bit*/, 1/*signed*/, &bitstream);
read > 0;
read = vorbis.ov_read(&vf, (char *)buf, to_read, 0, 2, 1, &bitstream))
#endif
{
if (read == OV_HOLE || read == OV_EBADLINK)
break; /* error */
Expand Down
4 changes: 4 additions & 0 deletions music_ogg.c
Expand Up @@ -165,7 +165,11 @@ static void OGG_getsome(OGG_music *music)
char data[4096];
SDL_AudioCVT *cvt;

#ifdef OGG_USE_TREMOR
len = vorbis.ov_read(&music->vf, data, sizeof(data), &section);
#else
len = vorbis.ov_read(&music->vf, data, sizeof(data), 0, 2, 1, &section);
#endif
if ( len <= 0 ) {
if ( len == 0 ) {
music->playing = 0;
Expand Down
4 changes: 4 additions & 0 deletions music_ogg.h
Expand Up @@ -26,7 +26,11 @@

/* This file supports Ogg Vorbis music streams */

#ifdef OGG_USE_TREMOR
#include <tremor/ivorbisfile.h>
#else
#include <vorbis/vorbisfile.h>
#endif

typedef struct {
int playing;
Expand Down

0 comments on commit 5cd8b9b

Please sign in to comment.