- Added FMOD_OPENONLY to the callback version of CreateStream() to prevent it

from doing prebuffering of the song. This was causing the Linux version to
  hang while waiting for input from the pipe, since Timidity hadn't been
  started yet. I tried using a select call in the FillStream() method, but it
  always seems to return the pipe as having nothing available. Unfortunately,
  the game still falls all over itself if Timidity isn't available. Instead
  of execvp failing nicely, X errors kill the game. I don't know why it's
  doing that. My advice for Linux music: Skip Timidity++ and get a DLS patch
  set (/WINDOWS/system32/drivers/gm.dls is probably the most common by far)
  and set the snd_midipatchset cvar to point to it. It's faster and also
  sounds a whole lot better than the crappy freepats Ubuntu wants to install
  with Timidity++.
- GCC fixes.



SVN r858 (trunk)
This commit is contained in:
Randy Heit 2008-03-27 04:25:52 +00:00
parent 6420d82a58
commit 39940fe20a
12 changed files with 93 additions and 33 deletions

View file

@ -1,5 +1,6 @@
# created on 4/12/2006 by James Bentler
FMOD_PREFIX = /usr/local
CXX ?= g++
CC ?= gcc
NASM ?= nasm
@ -16,13 +17,13 @@ endif
#endif
CFLAGS += -MMD -DHAVE_FILELENGTH -D__forceinline=inline `sdl-config --cflags` `pkg-config gtk+-2.0 --cflags`
CFLAGS += -Dstricmp=strcasecmp -Dstrnicmp=strncasecmp -DNEED_STRUPR
LDFLAGS += -lz -ljpeg -lfmodex `sdl-config --libs` `pkg-config gtk+-2.0 --libs`
LDFLAGS += -lz -ljpeg -`sdl-config --libs` `pkg-config gtk+-2.0 --libs` $(FMOD_PREFIX)/lib/libfmodex.so
NASMFLAGS += -f elf -DM_TARGET_LINUX
SRCDIRS = src/ $(addprefix src/,g_doom/ g_heretic/ g_hexen/ g_raven/ g_shared/ g_strife/ oplsynth/ sound/ sdl/ textures/ thingdef/ xlat/)
VPATH = $(SRCDIRS)
INCLUDES = $(addprefix -I,$(SRCDIRS))
INCLUDES += -Isnes_spc/snes_spc/ -I/usr/include/fmodex/
INCLUDES += -Isnes_spc/snes_spc/ -I$(FMOD_PREFIX)/include/fmodex/
CFLAGS += $(INCLUDES)
RELEASEOBJ ?= releaseobj

View file

@ -1,3 +1,19 @@
March 26, 2008
- Added FMOD_OPENONLY to the callback version of CreateStream() to prevent it
from doing prebuffering of the song. This was causing the Linux version to
hang while waiting for input from the pipe, since Timidity hadn't been
started yet. I tried using a select call in the FillStream() method, but it
always seems to return the pipe as having nothing available. Unfortunately,
the game still falls all over itself if Timidity isn't available. Instead
of execvp failing nicely, X errors kill the game. I don't know why it's
doing that. My advice for Linux music: Skip Timidity++ and get a DLS patch
set (/WINDOWS/system32/drivers/gm.dls is probably the most common by far)
and set the snd_midipatchset cvar to point to it. It's faster and also
sounds a whole lot better than the crappy freepats Ubuntu wants to install
with Timidity++ (thank goodness I have the official patches from a real
GUS so I don't need to use them).
- GCC fixes.
March 26, 2008 (Changes by Graf Zahl)
- Fixed: After starting new music the music volume has to be reset so that
the song's relative volume takes effect.
@ -16,7 +32,7 @@ March 25, 2008
- Added FMOD as MIDI device -1, to replace the MIDI mapper. This is still the
default device. By default, it uses exactly the same DLS instruments as the
Microsoft GS Wavetable Synth. If you have another set DLS level 1 patch set
you want to use, set the snd_midipatchfile cvar to specify where it should
you want to use, set the snd_midipatchset cvar to specify where it should
load the instruments from.
- Changed the ProduceMIDI function to store its output into a TArray<BYTE>.
An overloaded version wraps around it to continue to supply file-writing

View file

@ -242,7 +242,20 @@ static const char *IWADNames[] =
"hexen.wad",
"hexdd.wad",
"strife1.wad",
"strife0.wad",
"strife0.wad",
#ifdef unix
"DOOM2.WAD", // Also look for all-uppercase names
"PLUTONIA.WAD",
"TNT.WAD",
"DOOM.WAD",
"DOOM1.WAD",
"HERETIC.WAD",
"HERETIC1.WAD",
"HEXEN.WAD",
"HEXDD.WAD",
"STRIFE1.WAD",
"STRIFE0.WAD",
#endif
NULL
};

View file

@ -370,7 +370,8 @@ FSwitchDef *ParseSwitchDef (FScanner &sc, bool ignoreBad)
thisframe.Time = ((max - min + 1) << 16) | min;
}
else
{
{
thisframe.Time = 0; // Shush, GCC.
sc.ScriptError ("Must specify a duration for switch frame");
}
frames.Push(thisframe);

View file

@ -343,7 +343,7 @@ int P_TranslateSectorSpecial (int special)
}
}
if (special>=0 && special<SectorTranslations.Size())
if ((unsigned)special < SectorTranslations.Size())
{
if (SectorTranslations[special].bitmask_allowed && mask) special = 0;
else special = SectorTranslations[special].newtype;

View file

@ -193,8 +193,8 @@ void R_InitPicAnims (void)
if (debuganimated)
{
Printf("Defining animation '%s' (texture %d, lump %d, file %d) to '%s' (texture %d, lump %d, file %d)\n",
tex1->Name, tex1->GetSourceLump(), Wads.GetLumpFile(tex1->GetSourceLump()),
tex2->Name, tex2->GetSourceLump(), Wads.GetLumpFile(tex2->GetSourceLump()));
tex1->Name, pic1, tex1->GetSourceLump(), Wads.GetLumpFile(tex1->GetSourceLump()),
tex2->Name, pic2, tex2->GetSourceLump(), Wads.GetLumpFile(tex2->GetSourceLump()));
}
/* FIXME: doesn't work with hires texture replacements.

View file

@ -61,4 +61,5 @@ void restoreinterpolations();
void clearinterpolations();
void SerializeInterpolations(FArchive &arc);
#endif
#endif

View file

@ -502,7 +502,7 @@ void S_ParseSndSeq (int levellump)
FScanner sc(lump, "SNDSEQ");
while (sc.GetString ())
{
bool bDoorSound;
bool bDoorSound = false;
if (*sc.String == ':' || *sc.String == '[')
{

View file

@ -942,7 +942,7 @@ SoundStream *FMODSoundRenderer::CreateStream (SoundStreamCallback callback, int
capsule = new FMODStreamCapsule (userdata, callback, this);
mode = FMOD_2D | FMOD_OPENUSER | FMOD_LOOP_NORMAL | FMOD_SOFTWARE | FMOD_CREATESTREAM;
mode = FMOD_2D | FMOD_OPENUSER | FMOD_LOOP_NORMAL | FMOD_SOFTWARE | FMOD_CREATESTREAM | FMOD_OPENONLY;
sample_shift = (flags & SoundStream::Bits8) ? 0 : 1;
channel_shift = (flags & SoundStream::Mono) ? 0 : 1;

View file

@ -335,7 +335,7 @@ void *I_RegisterSong (const char *filename, char *musiccache, int offset, int le
{
BYTE *mus = new BYTE[len];
size_t did_read = fread(mus, 1, len, file);
if (did_read == len)
if (did_read == (size_t)len)
{
midi_made = ProduceMIDI(mus, midi);
}
@ -344,11 +344,6 @@ void *I_RegisterSong (const char *filename, char *musiccache, int offset, int le
}
if (midi_made)
{
/*
FILE *f = fopen("latest.mid", "wb");
fwrite(&midi[0], 1, midi.Size(), f);
fclose(f);
*/
info = new StreamSong((char *)&midi[0], -1, midi.Size());
if (!info->IsValid())
{

View file

@ -244,6 +244,7 @@ TimiditySong::TimiditySong (FILE *file, char * musiccache, int len)
void TimiditySong::PrepTimidity ()
{
int pipeSize;
#ifdef _WIN32
static SECURITY_ATTRIBUTES inheritable = { sizeof(inheritable), NULL, TRUE };
@ -267,6 +268,11 @@ void TimiditySong::PrepTimidity ()
pipeSize = (timidity_pipe * timidity_frequency / 1000)
<< (timidity_stereo + !timidity_8bit);
if (GSnd == NULL)
{ // Can't pipe if using no sound.
pipeSize = 0;
}
if (pipeSize != 0)
{
@ -520,11 +526,11 @@ bool TimiditySong::LaunchTimidity ()
close (WavePipe[0]);
dup2 (WavePipe[1], STDOUT_FILENO);
freopen ("/dev/null", "r", stdin);
freopen ("/dev/null", "w", stderr);
// freopen ("/dev/null", "w", stderr);
close (WavePipe[1]);
printf ("exec %s\n", words.we_wordv[0]);
execvp (words.we_wordv[0], words.we_wordv);
execvp (words.we_wordv[0], words.we_wordv);
fprintf(stderr,"execvp failed\n");
exit (0); // if execvp succeeds, we never get here
}
else if (forkres < 0)
@ -536,7 +542,12 @@ bool TimiditySong::LaunchTimidity ()
// printf ("child is %d\n", forkres);
ChildProcess = forkres;
close (WavePipe[1]);
WavePipe[1] = -1;
WavePipe[1] = -1;
/* usleep(1000000);
if (waitpid(ChildProcess, NULL, WNOHANG) == ChildProcess)
{
fprintf(stderr,"Launching timidity failed\n");
}*/
}
wordfree (&words);
@ -575,21 +586,36 @@ bool TimiditySong::FillStream (SoundStream *stream, void *buff, int len, void *u
}
}
#else
ssize_t got;
ssize_t got;
fd_set rfds;
struct timeval tv;
if (ChildQuit == song->ChildProcess)
{
ChildQuit = 0;
fprintf (stderr, "child gone\n");
song->ChildProcess = -1;
return false;
}
FD_ZERO(&rfds);
FD_SET(song->WavePipe[0], &rfds);
tv.tv_sec = 0;
tv.tv_usec = 50;
// fprintf(stderr,"select\n");
if (select(1, &rfds, NULL, NULL, &tv) <= 0 && 0)
{ // Nothing available, so play silence.
// fprintf(stderr,"nothing\n");
// memset(buff, 0, len);
return true;
}
// fprintf(stderr,"something\n");
got = read (song->WavePipe[0], (BYTE *)buff, len);
if (got < len)
{
memset ((BYTE *)buff+got, 0, len-got);
}
if (ChildQuit == song->ChildProcess)
{
ChildQuit = 0;
// printf ("child gone\n");
song->ChildProcess = -1;
return false;
}
#endif
return true;
}

View file

@ -50,8 +50,15 @@ StreamSong::~StreamSong ()
}
StreamSong::StreamSong (const char *filename_or_data, int offset, int len)
{
m_Stream = GSnd->OpenStream (filename_or_data, SoundStream::Loop, offset, len);
{
if (GSnd != NULL)
{
m_Stream = GSnd->OpenStream (filename_or_data, SoundStream::Loop, offset, len);
}
else
{
m_Stream = NULL;
}
}
bool StreamSong::IsPlaying ()