Converted all speechs to ogg, now depends on SDL_sound lib too
git-svn-id: svn://svn.code.sf.net/p/sc2/code/trunk@133 8092fc87-c524-0410-9efc-e669fe64eaf9
This commit is contained in:
@@ -50,7 +50,7 @@ BSC32=bscmake.exe
|
||||
# ADD BSC32 /nologo
|
||||
LINK32=link.exe
|
||||
# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:console /machine:I386
|
||||
# ADD LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib SDL.lib SDLmain.lib SDL_image.lib SDL_mixer.lib /nologo /subsystem:console /machine:I386 /nodefaultlib:"msvcrtd.lib" /out:"../../Content/Starcon2.exe"
|
||||
# ADD LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib SDL.lib SDLmain.lib SDL_image.lib SDL_mixer.lib SDL_sound.lib /nologo /subsystem:console /machine:I386 /nodefaultlib:"msvcrtd.lib" /out:"../../Content/Starcon2.exe"
|
||||
|
||||
!ELSEIF "$(CFG)" == "Starcon2 - Win32 Debug"
|
||||
|
||||
@@ -74,7 +74,7 @@ BSC32=bscmake.exe
|
||||
# ADD BSC32 /nologo /o"Starcon2.bsc"
|
||||
LINK32=link.exe
|
||||
# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:console /debug /machine:I386 /pdbtype:sept
|
||||
# ADD LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib SDL.lib SDLmain.lib SDL_image.lib SDL_mixer.lib /nologo /subsystem:console /debug /machine:I386 /nodefaultlib:"msvcrt.lib" /out:"../../Content/Starcon2Debug.exe" /pdbtype:sept
|
||||
# ADD LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib SDL.lib SDLmain.lib SDL_image.lib SDL_mixer.lib SDL_sound.lib /nologo /subsystem:console /debug /machine:I386 /nodefaultlib:"msvcrt.lib" /out:"../../Content/Starcon2Debug.exe" /pdbtype:sept
|
||||
# SUBTRACT LINK32 /nodefaultlib
|
||||
|
||||
!ENDIF
|
||||
|
||||
@@ -21,6 +21,7 @@
|
||||
#include "libs/graphics/sdl/sdl_common.h"
|
||||
#include "libs/sound/sound_common.h"
|
||||
#include "SDL_mixer.h"
|
||||
#include "SDL_sound.h"
|
||||
|
||||
int
|
||||
TFB_InitSound (int driver, int flags, int frequency)
|
||||
@@ -38,12 +39,18 @@ TFB_InitSound (int driver, int flags, int frequency)
|
||||
|
||||
if (Mix_OpenAudio(frequency, AUDIO_S16, 2, 2048))
|
||||
{
|
||||
fprintf (stderr, "Unable to open audio!\n");
|
||||
fprintf (stderr, "Unable to open audio: %s\n", Mix_GetError());
|
||||
exit (-1);
|
||||
}
|
||||
|
||||
atexit (Mix_CloseAudio);
|
||||
|
||||
if (!Sound_Init())
|
||||
{
|
||||
fprintf(stderr, "Sound_Init() failed: %s\n", Sound_GetError());
|
||||
exit (-1);
|
||||
}
|
||||
|
||||
SDL_AudioDriverName (SoundcardName, sizeof (SoundcardName));
|
||||
|
||||
Mix_QuerySpec (&audio_rate, &audio_format, &audio_channels);
|
||||
@@ -105,7 +112,7 @@ int
|
||||
GetSoundInfo (int *length, int *offset)
|
||||
// Umm... How does it know which sound?
|
||||
{
|
||||
fprintf (stderr, "Unimplemented function activated: GetSoundInfo()\n");
|
||||
//fprintf (stderr, "Unimplemented function activated: GetSoundInfo()\n");
|
||||
*length = 1;
|
||||
*offset = 0;
|
||||
return 1;
|
||||
|
||||
@@ -22,6 +22,7 @@
|
||||
#include "libs/sound/sound_common.h"
|
||||
#include "libs/sound/trackplayer.h"
|
||||
#include "SDL_mixer.h"
|
||||
#include "SDL_sound.h"
|
||||
|
||||
|
||||
#define VOICE_CHANNEL 0
|
||||
@@ -33,10 +34,54 @@ static int tct, tcur, no_voice;
|
||||
static struct
|
||||
{
|
||||
int text_spliced;
|
||||
Mix_Chunk *chunk;
|
||||
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)
|
||||
{
|
||||
@@ -122,6 +167,13 @@ 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;
|
||||
@@ -156,8 +208,62 @@ 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);
|
||||
|
||||
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);
|
||||
}
|
||||
|
||||
track_clip[tct].text = TrackText;
|
||||
track_clip[tct].chunk = Mix_LoadWAV (TrackName);
|
||||
track_clip[tct].text_spliced = 0;
|
||||
++tct;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user