diff --git a/sc2/configure.ac b/sc2/configure.ac index e1f2f2c5e..0c72ef6fe 100644 --- a/sc2/configure.ac +++ b/sc2/configure.ac @@ -27,8 +27,8 @@ AM_MAINTAINER_MODE # Configurables -CFLAGS="$CFLAGS -g -W -Wall -DHAVE_OPENGL -DSDL_PTHREADS -DGFXMODULE_SDL -DSOUNDMODULE_OPENAL" -CPPFLAGS="$CPPFLAGS -g -W -Wall -DHAVE_OPENGL -DSDL_PTHREADS -DGFXMODULE_SDL -DSOUNDMODULE_OPENAL" +CFLAGS="$CFLAGS -g -W -Wall -DHAVE_OPENGL -DSDL_PTHREADS -DGFXMODULE_SDL -DSOUNDMODULE_SDL" +CPPFLAGS="$CPPFLAGS -g -W -Wall -DHAVE_OPENGL -DSDL_PTHREADS -DGFXMODULE_SDL -DSOUNDMODULE_SDL" # -------------------------------------------------------------------------- @@ -69,9 +69,9 @@ AC_CHECK_FUNCS([strupr]) SDL_VERSION=1.2.2 AM_PATH_SDL($SDL_VERSION, , AC_MSG_ERROR([*** SDL version $SDL_VERSION not found!])) AC_CHECK_LIB(SDL_image, main, , AC_MSG_ERROR([Your system is missing libSDL_image!]),`sdl-config --libs`) -AC_CHECK_LIB(SDL_sound, main, , AC_MSG_ERROR([Your system is missing libSDL_sound!]),`sdl-config --libs`) -AC_CHECK_LIB(openal, main, , AC_MSG_ERROR([Your system is missing libopenal!]),"-lm") -#AC_CHECK_LIB(SDL_mixer, main, , AC_MSG_ERROR([Your system is missing libSDL_mixer!]),`sdl-config --libs`) +AC_CHECK_LIB(SDL_mixer, main, , AC_MSG_ERROR([Your system is missing libSDL_mixer!]),`sdl-config --libs`) +#AC_CHECK_LIB(SDL_sound, main, , AC_MSG_ERROR([Your system is missing libSDL_sound!]),`sdl-config --libs`) +#AC_CHECK_LIB(openal, main, , AC_MSG_ERROR([Your system is missing libopenal!]),"-lm") #AC_CHECK_HEADERS(SDL/SDL_image.h, , AC_MSG_ERROR([Your system is missing SDL_image.h!])) # Select platform dependent OpenGL libs.. (tweak your platform here) @@ -211,7 +211,7 @@ AC_CONFIG_FILES([ src/sc2code/libs/input/Makefile src/sc2code/libs/input/sdl/Makefile src/sc2code/libs/sound/Makefile - src/sc2code/libs/sound/openal/Makefile + src/sc2code/libs/sound/sdl/Makefile src/sc2code/libs/graphics/Makefile src/sc2code/libs/graphics/sdl/Makefile src/sc2code/libs/task/Makefile diff --git a/sc2/src/options.c b/sc2/src/options.c index ef870d336..64717d665 100644 --- a/sc2/src/options.c +++ b/sc2/src/options.c @@ -24,7 +24,7 @@ #include "compiler.h" #include "options.h" -int optWhichMusic = MUSIC_PC; +int optWhichMusic = MUSIC_3DO; BOOLEAN FileExists (char *filename) diff --git a/sc2/src/sc2code/libs/sound/Makefile.am b/sc2/src/sc2code/libs/sound/Makefile.am index 7d4869962..8e6b22bcf 100644 --- a/sc2/src/sc2code/libs/sound/Makefile.am +++ b/sc2/src/sc2code/libs/sound/Makefile.am @@ -3,7 +3,7 @@ # Written by Mudry , protected by GNU GPL. # CVS $ Id: $ -SUBDIRS = openal +SUBDIRS = sdl INCLUDES = @SDL_CFLAGS@ \ -I$(top_srcdir)/src \ @@ -12,6 +12,6 @@ INCLUDES = @SDL_CFLAGS@ \ noinst_LTLIBRARIES = libsound.la libsound_la_SOURCES = fileinst.c resinst.c sound_common.c -libsound_la_LIBADD = openal/libopenalsound.la +libsound_la_LIBADD = sdl/libsdlsound.la noinst_HEADERS = play.h redbook.h sndintrn.h trackplayer.h sound_common.h diff --git a/sc2/src/sc2code/libs/sound/sdl/modfuncs.c b/sc2/src/sc2code/libs/sound/sdl/modfuncs.c index 1e1fe557c..fed08ee59 100644 --- a/sc2/src/sc2code/libs/sound/sdl/modfuncs.c +++ b/sc2/src/sc2code/libs/sound/sdl/modfuncs.c @@ -18,16 +18,17 @@ #ifdef SOUNDMODULE_SDL -#include "libs/strings/strintrn.h" -#include "libs/sound/sndintrn.h" #ifdef WIN32 #include #endif #include +#include "libs/strings/strintrn.h" +#include "libs/sound/sndintrn.h" #include "libs/graphics/sdl/sdl_common.h" #include "libs/sound/sound_common.h" -#include "SDL_mixer.h" +#include "options.h" +#include MEM_HANDLE @@ -156,31 +157,52 @@ _ReleaseSoundBankData (MEM_HANDLE Snd) MEM_HANDLE _GetMusicData (FILE *fp, DWORD length) { - MEM_HANDLE h; - extern char *_cur_resfile_name; + MEM_HANDLE h; + extern char *_cur_resfile_name; - h = 0; - if (_cur_resfile_name && (h = AllocMusicData (sizeof (void *)))) + h = 0; + if (_cur_resfile_name && (h = AllocMusicData (sizeof (void *)))) + { + char filename[1000]; + Mix_Music **pmus; + + LockMusicData (h, &pmus); + + strcpy (filename, _cur_resfile_name); + switch (optWhichMusic) + { + default: + case MUSIC_3DO: + { + char threedoname[1000]; + + strcpy (threedoname, filename); + strcpy (&threedoname[strlen (threedoname)-3], "ogg"); + if (FileExists (threedoname)) + { + strcpy (filename, threedoname); + } + break; + } + case MUSIC_PC: + { + break; + } + } + + fprintf (stderr, "_GetMusicData(): loading %s\n", filename); + if (pmus == 0 || (*pmus = Mix_LoadMUS (filename)) == 0) { - Mix_Music **pmus; + UnlockMusicData (h); + mem_release (h); + h = 0; + } + UnlockMusicData (h); + } - LockMusicData (h, &pmus); - if (pmus == 0 || (*pmus = Mix_LoadMUS (_cur_resfile_name)) == 0) - { - UnlockMusicData (h); - mem_release (h); - h = 0; - } - else - { - // - } - UnlockMusicData (h); - } - - (void) fp; /* satisfy compiler (unused parameter) */ - (void) length; /* satisfy compiler (unused parameter) */ - return (h); + (void) fp; /* satisfy compiler (unused parameter) */ + (void) length; /* satisfy compiler (unused parameter) */ + return (h); } BOOLEAN diff --git a/sc2/src/sc2code/libs/sound/sdl/play.c b/sc2/src/sc2code/libs/sound/sdl/play.c index 84b217139..cfa71c0f3 100644 --- a/sc2/src/sc2code/libs/sound/sdl/play.c +++ b/sc2/src/sc2code/libs/sound/sdl/play.c @@ -22,7 +22,7 @@ #include "libs/graphics/sdl/sdl_common.h" #include "libs/sound/sound_common.h" -#include "SDL_mixer.h" +#include static MUSIC_REF curMusicRef; diff --git a/sc2/src/sc2code/libs/sound/sdl/sound.c b/sc2/src/sc2code/libs/sound/sdl/sound.c index 679b0a10b..57644e369 100644 --- a/sc2/src/sc2code/libs/sound/sdl/sound.c +++ b/sc2/src/sc2code/libs/sound/sdl/sound.c @@ -20,8 +20,7 @@ #include "libs/graphics/sdl/sdl_common.h" #include "libs/sound/sound_common.h" -#include "SDL_mixer.h" -#include "SDL_sound.h" +#include int TFB_InitSound (int driver, int flags, int frequency) @@ -66,16 +65,6 @@ TFB_InitSound (int driver, int flags, int frequency) Mix_Linked_Version()->major, Mix_Linked_Version()->minor, Mix_Linked_Version()->patch); - - fprintf (stderr, "Initializing SDL_sound.\n"); - fprintf (stderr, "(NOTE: if this locks up, compile SDL_sound without libmikmod support)\n"); - fflush (stderr); - if (!Sound_Init()) - { - fprintf(stderr, "Sound_Init() failed: %s\n", Sound_GetError()); - exit (-1); - } - fprintf (stderr, "SDL_sound initialized.\n"); return 0; } diff --git a/sc2/src/sc2code/libs/sound/sdl/trackplayer.c b/sc2/src/sc2code/libs/sound/sdl/trackplayer.c index cb5d65725..a8dc1ecb1 100644 --- a/sc2/src/sc2code/libs/sound/sdl/trackplayer.c +++ b/sc2/src/sc2code/libs/sound/sdl/trackplayer.c @@ -21,8 +21,7 @@ #include "libs/graphics/sdl/sdl_common.h" #include "libs/sound/sound_common.h" #include "libs/sound/trackplayer.h" -#include "SDL_mixer.h" -#include "SDL_sound.h" +#include #define VOICE_CHANNEL 0 @@ -36,52 +35,8 @@ static struct int text_spliced; UNICODE *text; Mix_Chunk *chunk; - Uint8 *speechdata; - Uint32 speechlen; - } track_clip[MAX_CLIPS]; - - -Uint8* Sound_Own_DecodeAll (Sound_Sample *sample, Uint32 bufsize, Uint32 *decoded_bytes) -{ - Uint8 *buf = NULL; - - *decoded_bytes = 0; - buf = (Uint8*) malloc (bufsize); - if (!buf) - { - fprintf (stderr, "Sound_Own_DecodeAll(): cannot allocate %d bytes\n", bufsize); - return NULL; - } - - while ( ((sample->flags & SOUND_SAMPLEFLAG_EOF) == 0) && - ((sample->flags & SOUND_SAMPLEFLAG_ERROR) == 0) ) - { - Uint32 br = Sound_Decode (sample); - - if (*decoded_bytes + br >= bufsize) - { - Uint8 *newbuf; - - bufsize *= 2; - newbuf = (Uint8*) realloc (buf, bufsize); - if (!newbuf) - { - fprintf (stderr, "Sound_Own_DecodeAll(): cannot realloc %d bytes\n", bufsize); - return buf; - } - buf = newbuf; - } - - memcpy (&buf[*decoded_bytes], sample->buffer, br); - *decoded_bytes += br; - } - - //fprintf(stderr, "Sound_Own_DecodeAll(): decoded %d bytes, allocated memory size %d\n", *decoded_bytes, bufsize); - return buf; -} - void JumpTrack (int abort) { @@ -167,13 +122,6 @@ StopTrack () Mix_FreeChunk (track_clip[tct].chunk); track_clip[tct].chunk = 0; } - if (track_clip[tct].speechdata) - { - //fprintf (stderr, "StopTrack(): freeing atleast %d bytes\n", track_clip[tct].speechlen); - free (track_clip[tct].speechdata); - track_clip[tct].speechdata = 0; - track_clip[tct].speechlen = 0; - } } tct = tcur = 0; no_voice = 0; @@ -207,60 +155,14 @@ SpliceTrack (UNICODE *TrackName, UNICODE *TrackText) } } else if (tct < MAX_CLIPS) - { - Sound_AudioInfo sound_desired; - Sound_Sample *sample; - Uint16 format; - int rate, channels; - - //fprintf(stderr, "SpliceTrack(): trackname %s\n", TrackName); + { + fprintf(stderr, "SpliceTrack(): loading %s\n", TrackName); - // this is needed because sample must be converted to mixer - // format or it doesn't play right - Mix_QuerySpec (&rate, &format, &channels); - sound_desired.rate = rate; - sound_desired.format = format; - sound_desired.channels = channels; - - sample = Sound_NewSampleFromFile (TrackName, &sound_desired, 16384); - - if (!sample) + track_clip[tct].chunk = Mix_LoadWAV (TrackName); + if (!track_clip[tct].chunk) { - fprintf (stderr, "SpliceTrack(): couldn't load %s: %s\n", - TrackName, Sound_GetError()); - track_clip[tct].chunk = NULL; - track_clip[tct].speechdata = NULL; - track_clip[tct].speechlen = 0; - } - else - { - track_clip[tct].speechdata = Sound_Own_DecodeAll (sample, 1048576, - &track_clip[tct].speechlen); - - if (track_clip[tct].speechdata) - { - track_clip[tct].chunk = Mix_QuickLoad_RAW (track_clip[tct].speechdata, - track_clip[tct].speechlen); - - if (!track_clip[tct].chunk) - { - fprintf (stderr, "SpliceTrack(): Mix_QuickLoad_RAW failed for %s: %s\n", - TrackName, Mix_GetError()); - - free (track_clip[tct].speechdata); - track_clip[tct].speechdata = NULL; - track_clip[tct].speechlen = 0; - } - } - else - { - fprintf (stderr, "SpliceTrack(): Sound_Own_DecodeAll failed for %s\n", TrackName); - track_clip[tct].chunk = NULL; - track_clip[tct].speechdata = NULL; - track_clip[tct].speechlen = 0; - } - - Sound_FreeSample (sample); + fprintf (stderr, "SpliceTrack(): Mix_LoadWAV failed for %s: %s\n", + TrackName, Mix_GetError()); } track_clip[tct].text = TrackText;