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:
@@ -72,7 +72,6 @@ Glitches (don't crash the game, medium priority):
|
|||||||
- Occasional clipping/popping/etc artifacts
|
- Occasional clipping/popping/etc artifacts
|
||||||
- Maybe caused by buggy soundcard drivers also
|
- Maybe caused by buggy soundcard drivers also
|
||||||
- Some unimplemented functions (for oscilloscope and dialogue seeking)
|
- 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,
|
- 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?)
|
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
|
- Stock SDL_sound package for VC is outdated and win32 users have to get
|
||||||
|
|||||||
+2
-2
@@ -9,7 +9,7 @@ INCLUDES = @SDL_CFLAGS@ \
|
|||||||
|
|
||||||
bin_PROGRAMS = sc2
|
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@
|
sc2_LDADD = sc2code/libsc2.la @SDL_LIBS@ @GL_LIBS@
|
||||||
noinst_HEADERS = port.h
|
noinst_HEADERS = port.h options.h
|
||||||
|
|
||||||
|
|||||||
@@ -3092,6 +3092,14 @@ SOURCE=..\port.h
|
|||||||
# End Source File
|
# End Source File
|
||||||
# Begin 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
|
SOURCE=..\starcon2.c
|
||||||
# End Source File
|
# End Source File
|
||||||
# End Group
|
# End Group
|
||||||
|
|||||||
@@ -20,6 +20,7 @@
|
|||||||
#ifdef SOUNDMODULE_OPENAL
|
#ifdef SOUNDMODULE_OPENAL
|
||||||
|
|
||||||
#include "sound.h"
|
#include "sound.h"
|
||||||
|
#include "options.h"
|
||||||
|
|
||||||
static MUSIC_REF curMusicRef;
|
static MUSIC_REF curMusicRef;
|
||||||
|
|
||||||
@@ -102,7 +103,7 @@ DestroyMusic (MUSIC_REF MusicRef)
|
|||||||
|
|
||||||
void
|
void
|
||||||
SetMusicVolume (COUNT Volume)
|
SetMusicVolume (COUNT Volume)
|
||||||
{
|
{
|
||||||
float f = (Volume / (ALfloat)MAX_VOLUME) * musicVolumeScale;
|
float f = (Volume / (ALfloat)MAX_VOLUME) * musicVolumeScale;
|
||||||
musicVolume = Volume;
|
musicVolume = Volume;
|
||||||
alSourcef (soundSource[MUSIC_SOURCE].handle, AL_GAIN, f);
|
alSourcef (soundSource[MUSIC_SOURCE].handle, AL_GAIN, f);
|
||||||
@@ -128,11 +129,36 @@ _GetMusicData (FILE *fp, DWORD length)
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
*pmus = (TFB_SoundSample *) HMalloc (sizeof (TFB_SoundSample));
|
char filename[1000];
|
||||||
|
|
||||||
if (((*pmus)->decoder = Sound_NewSampleFromFile (_cur_resfile_name, NULL, 4096)) == 0)
|
*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);
|
UnlockMusicData (h);
|
||||||
mem_release (h);
|
mem_release (h);
|
||||||
|
|||||||
@@ -235,7 +235,8 @@ _ReleaseSoundBankData (MEM_HANDLE Snd)
|
|||||||
sptr = (TFB_SoundSample **)((BYTE *)fxTab + fxTab->StringOffsets[0]);
|
sptr = (TFB_SoundSample **)((BYTE *)fxTab + fxTab->StringOffsets[0]);
|
||||||
while (snd_ct--)
|
while (snd_ct--)
|
||||||
{
|
{
|
||||||
Sound_FreeSample ((*sptr)->decoder);
|
if ((*sptr)->decoder)
|
||||||
|
Sound_FreeSample ((*sptr)->decoder);
|
||||||
alDeleteBuffers (NUM_SOUNDBUFFERS, (*sptr)->buffer);
|
alDeleteBuffers (NUM_SOUNDBUFFERS, (*sptr)->buffer);
|
||||||
HFree (*sptr);
|
HFree (*sptr);
|
||||||
*sptr++ = 0;
|
*sptr++ = 0;
|
||||||
|
|||||||
@@ -64,6 +64,7 @@ TFB_InitSound (int driver, int flags, int frequency)
|
|||||||
fprintf (stderr, " renderer: %s\n", alGetString (AL_RENDERER));
|
fprintf (stderr, " renderer: %s\n", alGetString (AL_RENDERER));
|
||||||
fprintf (stderr, " device: %s\n",
|
fprintf (stderr, " device: %s\n",
|
||||||
alcGetString (alcDevice, ALC_DEFAULT_DEVICE_SPECIFIER));
|
alcGetString (alcDevice, ALC_DEFAULT_DEVICE_SPECIFIER));
|
||||||
|
fprintf (stderr, " extensions: %s\n", alGetString (AL_EXTENSIONS));
|
||||||
|
|
||||||
fprintf (stderr, "Initializing SDL_sound.\n");
|
fprintf (stderr, "Initializing SDL_sound.\n");
|
||||||
if (!Sound_Init())
|
if (!Sound_Init())
|
||||||
|
|||||||
@@ -33,7 +33,7 @@
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
||||||
#define NUM_SOUNDBUFFERS 8
|
#define NUM_SOUNDBUFFERS 10
|
||||||
#define FIRST_SFX_SOURCE 0
|
#define FIRST_SFX_SOURCE 0
|
||||||
#define LAST_SFX_SOURCE 4
|
#define LAST_SFX_SOURCE 4
|
||||||
#define MUSIC_SOURCE (LAST_SFX_SOURCE + 1)
|
#define MUSIC_SOURCE (LAST_SFX_SOURCE + 1)
|
||||||
|
|||||||
@@ -21,7 +21,7 @@
|
|||||||
|
|
||||||
#include "sound.h"
|
#include "sound.h"
|
||||||
|
|
||||||
BOOLEAN speech_callback = FALSE;
|
BOOLEAN speech_advancetrack = FALSE;
|
||||||
|
|
||||||
|
|
||||||
void
|
void
|
||||||
@@ -115,9 +115,10 @@ StreamDecoderTaskFunc (void *data)
|
|||||||
for (i = MUSIC_SOURCE; i < NUM_SOUNDSOURCES; ++i)
|
for (i = MUSIC_SOURCE; i < NUM_SOUNDSOURCES; ++i)
|
||||||
{
|
{
|
||||||
ALuint processed;
|
ALuint processed;
|
||||||
//ALuint queued;
|
ALuint queued;
|
||||||
ALint state;
|
ALint state;
|
||||||
ALboolean finished = AL_FALSE;
|
ALboolean finished = AL_FALSE;
|
||||||
|
ALboolean do_speech_advancetrack = AL_FALSE;
|
||||||
|
|
||||||
LockMutex (soundSource[i].stream_mutex);
|
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);
|
//fprintf (stderr, "StreamDecoderTaskFunc(): source %d, processed %d queued %d\n", i, processed, queued);
|
||||||
|
|
||||||
while (processed && !finished)
|
while (processed && !finished)
|
||||||
@@ -161,14 +168,15 @@ StreamDecoderTaskFunc (void *data)
|
|||||||
}
|
}
|
||||||
|
|
||||||
decoded_bytes = Sound_Decode (soundSource[i].sample->decoder);
|
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 (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;
|
finished = AL_TRUE;
|
||||||
soundSource[i].stream_should_be_playing = FALSE;
|
soundSource[i].stream_should_be_playing = FALSE;
|
||||||
|
do_speech_advancetrack = AL_TRUE;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
@@ -228,6 +236,16 @@ StreamDecoderTaskFunc (void *data)
|
|||||||
}
|
}
|
||||||
|
|
||||||
UnlockMutex (soundSource[i].stream_mutex);
|
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);
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -14,7 +14,7 @@
|
|||||||
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
* 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
|
#ifndef STREAM_H
|
||||||
@@ -27,7 +27,7 @@ void ResumeStream (ALuint source);
|
|||||||
BOOLEAN PlayingStream (ALuint source);
|
BOOLEAN PlayingStream (ALuint source);
|
||||||
int StreamDecoderTaskFunc (void *data);
|
int StreamDecoderTaskFunc (void *data);
|
||||||
|
|
||||||
extern BOOLEAN speech_callback;
|
extern BOOLEAN speech_advancetrack;
|
||||||
void advance_track (int channel_finished);
|
void advance_track (int channel_finished);
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|||||||
@@ -38,7 +38,7 @@ static struct
|
|||||||
void
|
void
|
||||||
JumpTrack (int abort)
|
JumpTrack (int abort)
|
||||||
{
|
{
|
||||||
speech_callback = FALSE;
|
speech_advancetrack = FALSE;
|
||||||
|
|
||||||
if (track_clip[tcur].sample)
|
if (track_clip[tcur].sample)
|
||||||
{
|
{
|
||||||
@@ -85,12 +85,10 @@ ResumeTrack ()
|
|||||||
|
|
||||||
LockMutex (soundSource[SPEECH_SOURCE].stream_mutex);
|
LockMutex (soundSource[SPEECH_SOURCE].stream_mutex);
|
||||||
alGetSourcei (soundSource[SPEECH_SOURCE].handle, AL_SOURCE_STATE, &state);
|
alGetSourcei (soundSource[SPEECH_SOURCE].handle, AL_SOURCE_STATE, &state);
|
||||||
UnlockMutex (soundSource[SPEECH_SOURCE].stream_mutex);
|
|
||||||
|
|
||||||
if (!soundSource[SPEECH_SOURCE].stream_should_be_playing &&
|
if (!soundSource[SPEECH_SOURCE].stream_should_be_playing &&
|
||||||
state == AL_PAUSED)
|
state == AL_PAUSED)
|
||||||
{
|
{
|
||||||
LockMutex (soundSource[SPEECH_SOURCE].stream_mutex);
|
|
||||||
ResumeStream (SPEECH_SOURCE);
|
ResumeStream (SPEECH_SOURCE);
|
||||||
UnlockMutex (soundSource[SPEECH_SOURCE].stream_mutex);
|
UnlockMutex (soundSource[SPEECH_SOURCE].stream_mutex);
|
||||||
}
|
}
|
||||||
@@ -98,10 +96,15 @@ ResumeTrack ()
|
|||||||
{
|
{
|
||||||
if (tcur == 0)
|
if (tcur == 0)
|
||||||
{
|
{
|
||||||
speech_callback = TRUE;
|
speech_advancetrack = TRUE;
|
||||||
}
|
}
|
||||||
|
UnlockMutex (soundSource[SPEECH_SOURCE].stream_mutex);
|
||||||
advance_track (-1);
|
advance_track (-1);
|
||||||
}
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
UnlockMutex (soundSource[SPEECH_SOURCE].stream_mutex);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -133,7 +136,7 @@ PlayingTrack ()
|
|||||||
void
|
void
|
||||||
StopTrack ()
|
StopTrack ()
|
||||||
{
|
{
|
||||||
speech_callback = FALSE;
|
speech_advancetrack = FALSE;
|
||||||
LockMutex (soundSource[SPEECH_SOURCE].stream_mutex);
|
LockMutex (soundSource[SPEECH_SOURCE].stream_mutex);
|
||||||
StopStream (SPEECH_SOURCE);
|
StopStream (SPEECH_SOURCE);
|
||||||
UnlockMutex (soundSource[SPEECH_SOURCE].stream_mutex);
|
UnlockMutex (soundSource[SPEECH_SOURCE].stream_mutex);
|
||||||
@@ -223,8 +226,12 @@ SpliceTrack (UNICODE *TrackName, UNICODE *TrackText)
|
|||||||
void
|
void
|
||||||
PauseTrack ()
|
PauseTrack ()
|
||||||
{
|
{
|
||||||
/*if (tcur < tct && track_clip[tcur].chunk)
|
if (tcur < tct && track_clip[tcur].sample)
|
||||||
Mix_Pause (VOICE_CHANNEL);*/
|
{
|
||||||
|
LockMutex (soundSource[SPEECH_SOURCE].stream_mutex);
|
||||||
|
PauseStream (SPEECH_SOURCE);
|
||||||
|
UnlockMutex (soundSource[SPEECH_SOURCE].stream_mutex);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
|
|||||||
+12
-10
@@ -28,16 +28,8 @@
|
|||||||
#include "libs/sound/sound_common.h"
|
#include "libs/sound/sound_common.h"
|
||||||
#include "libs/input/input_common.h"
|
#include "libs/input/input_common.h"
|
||||||
#include "libs/tasklib.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
|
void
|
||||||
CDToContentDir (char *contentdir)
|
CDToContentDir (char *contentdir)
|
||||||
@@ -80,6 +72,8 @@ main (int argc, char *argv[])
|
|||||||
{"musicvol", 1, NULL, 'M'},
|
{"musicvol", 1, NULL, 'M'},
|
||||||
{"sfxvol", 1, NULL, 'S'},
|
{"sfxvol", 1, NULL, 'S'},
|
||||||
{"speechvol", 1, NULL, 'T'},
|
{"speechvol", 1, NULL, 'T'},
|
||||||
|
{"3domusic", 0, NULL, 'e'},
|
||||||
|
{"pcmusic", 0, NULL, 'm'},
|
||||||
{0, 0, 0, 0}
|
{0, 0, 0, 0}
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -89,7 +83,7 @@ main (int argc, char *argv[])
|
|||||||
strcpy (contentdir, "../../content");
|
strcpy (contentdir, "../../content");
|
||||||
#endif
|
#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) {
|
switch (c) {
|
||||||
case 'r':
|
case 'r':
|
||||||
@@ -143,6 +137,12 @@ main (int argc, char *argv[])
|
|||||||
vol = 100;
|
vol = 100;
|
||||||
speechVolumeScale = vol / 100.0f;
|
speechVolumeScale = vol / 100.0f;
|
||||||
break;
|
break;
|
||||||
|
case 'e':
|
||||||
|
optWhichMusic = MUSIC_3DO;
|
||||||
|
break;
|
||||||
|
case 'm':
|
||||||
|
optWhichMusic = MUSIC_PC;
|
||||||
|
break;
|
||||||
default:
|
default:
|
||||||
printf ("\nOption %s not found!\n", long_options[option_index].name);
|
printf ("\nOption %s not found!\n", long_options[option_index].name);
|
||||||
case '?':
|
case '?':
|
||||||
@@ -161,6 +161,8 @@ main (int argc, char *argv[])
|
|||||||
printf(" -M, --musicvol=VOLUME (0-100)\n");
|
printf(" -M, --musicvol=VOLUME (0-100)\n");
|
||||||
printf(" -S, --sfxvol=VOLUME (0-100)\n");
|
printf(" -S, --sfxvol=VOLUME (0-100)\n");
|
||||||
printf(" -T, --speechvol=VOLUME (0-100)\n");
|
printf(" -T, --speechvol=VOLUME (0-100)\n");
|
||||||
|
printf(" -e, --3domusic\n");
|
||||||
|
printf(" -m, --pcmusic\n");
|
||||||
return 0;
|
return 0;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user