Commandline switch between PC and 3DO musics, OpenAL code fixes

git-svn-id: svn://svn.code.sf.net/p/sc2/code/trunk@145 8092fc87-c524-0410-9efc-e669fe64eaf9
This commit is contained in:
gewlitys
2002-10-24 20:33:59 +00:00
parent bdb2573ca1
commit b4acbace78
11 changed files with 96 additions and 34 deletions
-1
View File
@@ -72,7 +72,6 @@ Glitches (don't crash the game, medium priority):
- Occasional clipping/popping/etc artifacts
- Maybe caused by buggy soundcard drivers also
- Some unimplemented functions (for oscilloscope and dialogue seeking)
- Occasionally some speech oggs don't play
- When mod music is looping, there's some volume fade at the end of tune,
then it starts playing again. This shouldn't happen? (modplug only?)
- Stock SDL_sound package for VC is outdated and win32 users have to get
+2 -2
View File
@@ -9,7 +9,7 @@ INCLUDES = @SDL_CFLAGS@ \
bin_PROGRAMS = sc2
sc2_SOURCES = port.c starcon2.c
sc2_SOURCES = port.c starcon2.c options.c
sc2_LDADD = sc2code/libsc2.la @SDL_LIBS@ @GL_LIBS@
noinst_HEADERS = port.h
noinst_HEADERS = port.h options.h
+8
View File
@@ -3092,6 +3092,14 @@ SOURCE=..\port.h
# End Source File
# Begin Source File
SOURCE=..\options.c
# End Source File
# Begin Source File
SOURCE=..\options.h
# End Source File
# Begin Source File
SOURCE=..\starcon2.c
# End Source File
# End Group
+31 -5
View File
@@ -20,6 +20,7 @@
#ifdef SOUNDMODULE_OPENAL
#include "sound.h"
#include "options.h"
static MUSIC_REF curMusicRef;
@@ -102,7 +103,7 @@ DestroyMusic (MUSIC_REF MusicRef)
void
SetMusicVolume (COUNT Volume)
{
{
float f = (Volume / (ALfloat)MAX_VOLUME) * musicVolumeScale;
musicVolume = Volume;
alSourcef (soundSource[MUSIC_SOURCE].handle, AL_GAIN, f);
@@ -128,11 +129,36 @@ _GetMusicData (FILE *fp, DWORD length)
}
else
{
*pmus = (TFB_SoundSample *) HMalloc (sizeof (TFB_SoundSample));
if (((*pmus)->decoder = Sound_NewSampleFromFile (_cur_resfile_name, NULL, 4096)) == 0)
char filename[1000];
*pmus = (TFB_SoundSample *) HMalloc (sizeof (TFB_SoundSample));
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)->decoder = Sound_NewSampleFromFile (filename, NULL, 4096)) == 0)
{
fprintf (stderr, "_GetMusicData(): couldn't load %s\n", _cur_resfile_name);
fprintf (stderr, "_GetMusicData(): couldn't load %s\n", filename);
UnlockMusicData (h);
mem_release (h);
+2 -1
View File
@@ -235,7 +235,8 @@ _ReleaseSoundBankData (MEM_HANDLE Snd)
sptr = (TFB_SoundSample **)((BYTE *)fxTab + fxTab->StringOffsets[0]);
while (snd_ct--)
{
Sound_FreeSample ((*sptr)->decoder);
if ((*sptr)->decoder)
Sound_FreeSample ((*sptr)->decoder);
alDeleteBuffers (NUM_SOUNDBUFFERS, (*sptr)->buffer);
HFree (*sptr);
*sptr++ = 0;
@@ -64,6 +64,7 @@ TFB_InitSound (int driver, int flags, int frequency)
fprintf (stderr, " renderer: %s\n", alGetString (AL_RENDERER));
fprintf (stderr, " device: %s\n",
alcGetString (alcDevice, ALC_DEFAULT_DEVICE_SPECIFIER));
fprintf (stderr, " extensions: %s\n", alGetString (AL_EXTENSIONS));
fprintf (stderr, "Initializing SDL_sound.\n");
if (!Sound_Init())
+1 -1
View File
@@ -33,7 +33,7 @@
#endif
#define NUM_SOUNDBUFFERS 8
#define NUM_SOUNDBUFFERS 10
#define FIRST_SFX_SOURCE 0
#define LAST_SFX_SOURCE 4
#define MUSIC_SOURCE (LAST_SFX_SOURCE + 1)
+23 -5
View File
@@ -21,7 +21,7 @@
#include "sound.h"
BOOLEAN speech_callback = FALSE;
BOOLEAN speech_advancetrack = FALSE;
void
@@ -115,9 +115,10 @@ StreamDecoderTaskFunc (void *data)
for (i = MUSIC_SOURCE; i < NUM_SOUNDSOURCES; ++i)
{
ALuint processed;
//ALuint queued;
ALuint queued;
ALint state;
ALboolean finished = AL_FALSE;
ALboolean do_speech_advancetrack = AL_FALSE;
LockMutex (soundSource[i].stream_mutex);
@@ -142,7 +143,13 @@ StreamDecoderTaskFunc (void *data)
}
}
//alGetSourcei (soundSource[i].handle, AL_BUFFERS_QUEUED, &queued);
alGetSourcei (soundSource[i].handle, AL_BUFFERS_QUEUED, &queued);
if (queued != NUM_SOUNDBUFFERS)
{
fprintf (stderr, "StreamDecoderTaskFunc(): warning, queued %d != NUM_SOUNDBUFFERS %d\n",
queued, NUM_SOUNDBUFFERS);
}
//fprintf (stderr, "StreamDecoderTaskFunc(): source %d, processed %d queued %d\n", i, processed, queued);
while (processed && !finished)
@@ -161,14 +168,15 @@ StreamDecoderTaskFunc (void *data)
}
decoded_bytes = Sound_Decode (soundSource[i].sample->decoder);
//fprintf (stderr, "StreamDecoderTaskFunc(): decoded_bytes %d, source %d\n", decoded_bytes, i);
if (soundSource[i].sample->decoder->flags & SOUND_SAMPLEFLAG_EOF)
{
if (i == SPEECH_SOURCE && speech_callback)
if (i == SPEECH_SOURCE && speech_advancetrack)
{
advance_track (0);
finished = AL_TRUE;
soundSource[i].stream_should_be_playing = FALSE;
do_speech_advancetrack = AL_TRUE;
}
else
{
@@ -228,6 +236,16 @@ StreamDecoderTaskFunc (void *data)
}
UnlockMutex (soundSource[i].stream_mutex);
if (i == SPEECH_SOURCE)
{
if (do_speech_advancetrack)
{
//fprintf (stderr, "StreamDecoderTaskFunc(): calling advance_track\n");
do_speech_advancetrack = AL_FALSE;
advance_track (0);
}
}
}
}
+2 -2
View File
@@ -14,7 +14,7 @@
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*/
/* OpenAL specific code by Mika Kolehmainen, 2002-10-23
/* By Mika Kolehmainen, 2002-10-23
*/
#ifndef STREAM_H
@@ -27,7 +27,7 @@ void ResumeStream (ALuint source);
BOOLEAN PlayingStream (ALuint source);
int StreamDecoderTaskFunc (void *data);
extern BOOLEAN speech_callback;
extern BOOLEAN speech_advancetrack;
void advance_track (int channel_finished);
#endif
@@ -38,7 +38,7 @@ static struct
void
JumpTrack (int abort)
{
speech_callback = FALSE;
speech_advancetrack = FALSE;
if (track_clip[tcur].sample)
{
@@ -85,12 +85,10 @@ ResumeTrack ()
LockMutex (soundSource[SPEECH_SOURCE].stream_mutex);
alGetSourcei (soundSource[SPEECH_SOURCE].handle, AL_SOURCE_STATE, &state);
UnlockMutex (soundSource[SPEECH_SOURCE].stream_mutex);
if (!soundSource[SPEECH_SOURCE].stream_should_be_playing &&
state == AL_PAUSED)
{
LockMutex (soundSource[SPEECH_SOURCE].stream_mutex);
ResumeStream (SPEECH_SOURCE);
UnlockMutex (soundSource[SPEECH_SOURCE].stream_mutex);
}
@@ -98,10 +96,15 @@ ResumeTrack ()
{
if (tcur == 0)
{
speech_callback = TRUE;
speech_advancetrack = TRUE;
}
UnlockMutex (soundSource[SPEECH_SOURCE].stream_mutex);
advance_track (-1);
}
else
{
UnlockMutex (soundSource[SPEECH_SOURCE].stream_mutex);
}
}
}
@@ -133,7 +136,7 @@ PlayingTrack ()
void
StopTrack ()
{
speech_callback = FALSE;
speech_advancetrack = FALSE;
LockMutex (soundSource[SPEECH_SOURCE].stream_mutex);
StopStream (SPEECH_SOURCE);
UnlockMutex (soundSource[SPEECH_SOURCE].stream_mutex);
@@ -223,8 +226,12 @@ SpliceTrack (UNICODE *TrackName, UNICODE *TrackText)
void
PauseTrack ()
{
/*if (tcur < tct && track_clip[tcur].chunk)
Mix_Pause (VOICE_CHANNEL);*/
if (tcur < tct && track_clip[tcur].sample)
{
LockMutex (soundSource[SPEECH_SOURCE].stream_mutex);
PauseStream (SPEECH_SOURCE);
UnlockMutex (soundSource[SPEECH_SOURCE].stream_mutex);
}
}
void
+12 -10
View File
@@ -28,16 +28,8 @@
#include "libs/sound/sound_common.h"
#include "libs/input/input_common.h"
#include "libs/tasklib.h"
#include "options.h"
BOOLEAN FileExists (char *filename)
{
FILE *fp;
if ((fp = fopen(filename, "rb")) == NULL)
return FALSE;
fclose (fp);
return TRUE;
}
void
CDToContentDir (char *contentdir)
@@ -80,6 +72,8 @@ main (int argc, char *argv[])
{"musicvol", 1, NULL, 'M'},
{"sfxvol", 1, NULL, 'S'},
{"speechvol", 1, NULL, 'T'},
{"3domusic", 0, NULL, 'e'},
{"pcmusic", 0, NULL, 'm'},
{0, 0, 0, 0}
};
@@ -89,7 +83,7 @@ main (int argc, char *argv[])
strcpy (contentdir, "../../content");
#endif
while ((c = getopt_long(argc, argv, "r:d:fobq:ptc:?hM:S:T:", long_options, &option_index)) != -1)
while ((c = getopt_long(argc, argv, "r:d:fobq:ptc:?hM:S:T:em", long_options, &option_index)) != -1)
{
switch (c) {
case 'r':
@@ -143,6 +137,12 @@ main (int argc, char *argv[])
vol = 100;
speechVolumeScale = vol / 100.0f;
break;
case 'e':
optWhichMusic = MUSIC_3DO;
break;
case 'm':
optWhichMusic = MUSIC_PC;
break;
default:
printf ("\nOption %s not found!\n", long_options[option_index].name);
case '?':
@@ -161,6 +161,8 @@ main (int argc, char *argv[])
printf(" -M, --musicvol=VOLUME (0-100)\n");
printf(" -S, --sfxvol=VOLUME (0-100)\n");
printf(" -T, --speechvol=VOLUME (0-100)\n");
printf(" -e, --3domusic\n");
printf(" -m, --pcmusic\n");
return 0;
break;
}