Linux version now defaults back to SDL_mixer (with no longer needing SDL_sound), also 3DO musics are now used by default

git-svn-id: svn://svn.code.sf.net/p/sc2/code/trunk@149 8092fc87-c524-0410-9efc-e669fe64eaf9
This commit is contained in:
gewlitys
2002-10-25 14:02:22 +00:00
parent 3a0d4b25d7
commit fb05a44ea4
7 changed files with 65 additions and 152 deletions
+6 -6
View File
@@ -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
+1 -1
View File
@@ -24,7 +24,7 @@
#include "compiler.h"
#include "options.h"
int optWhichMusic = MUSIC_PC;
int optWhichMusic = MUSIC_3DO;
BOOLEAN FileExists (char *filename)
+2 -2
View File
@@ -3,7 +3,7 @@
# Written by Mudry <mudry@user.sf.net>, 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
+30 -8
View File
@@ -18,16 +18,17 @@
#ifdef SOUNDMODULE_SDL
#include "libs/strings/strintrn.h"
#include "libs/sound/sndintrn.h"
#ifdef WIN32
#include <io.h>
#endif
#include <fcntl.h>
#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 <SDL/SDL_mixer.h>
MEM_HANDLE
@@ -162,19 +163,40 @@ _GetMusicData (FILE *fp, DWORD length)
h = 0;
if (_cur_resfile_name && (h = AllocMusicData (sizeof (void *))))
{
char filename[1000];
Mix_Music **pmus;
LockMusicData (h, &pmus);
if (pmus == 0 || (*pmus = Mix_LoadMUS (_cur_resfile_name)) == 0)
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)
{
UnlockMusicData (h);
mem_release (h);
h = 0;
}
else
{
//
}
UnlockMusicData (h);
}
+1 -1
View File
@@ -22,7 +22,7 @@
#include "libs/graphics/sdl/sdl_common.h"
#include "libs/sound/sound_common.h"
#include "SDL_mixer.h"
#include <SDL/SDL_mixer.h>
static MUSIC_REF curMusicRef;
+1 -12
View File
@@ -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 <SDL/SDL_mixer.h>
int
TFB_InitSound (int driver, int flags, int frequency)
@@ -67,16 +66,6 @@ TFB_InitSound (int driver, int flags, int frequency)
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;
}
+4 -102
View File
@@ -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 <SDL/SDL_mixer.h>
#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;
@@ -208,59 +156,13 @@ 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);
// 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)
{
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);
fprintf(stderr, "SpliceTrack(): loading %s\n", TrackName);
track_clip[tct].chunk = Mix_LoadWAV (TrackName);
if (!track_clip[tct].chunk)
{
fprintf (stderr, "SpliceTrack(): Mix_QuickLoad_RAW failed for %s: %s\n",
fprintf (stderr, "SpliceTrack(): Mix_LoadWAV 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);
}
track_clip[tct].text = TrackText;