From 4c566992e4288fbda2f0faeea74d1455b1a9c483 Mon Sep 17 00:00:00 2001 From: TimeServ Date: Tue, 9 May 2006 19:29:14 +0000 Subject: [PATCH] support non-power of 2 sound buffer sizes, attempted fix for command line not being parsed correctly with dedicated server crash restart git-svn-id: https://svn.code.sf.net/p/fteqw/code/trunk@2260 fc73d0e0-1445-4013-8a0c-d673dee63da5 --- engine/client/snd_mix.c | 12 ++++++------ engine/server/sv_ccmds.c | 1 - engine/server/sv_sys_win.c | 5 ++++- 3 files changed, 10 insertions(+), 8 deletions(-) diff --git a/engine/client/snd_mix.c b/engine/client/snd_mix.c index c6223604f..1bd54156e 100644 --- a/engine/client/snd_mix.c +++ b/engine/client/snd_mix.c @@ -56,7 +56,7 @@ void S_TransferPaintBuffer(soundcardinfo_t *sc, int endtime) { int startidx, out_idx; int count; - int out_mask; + int outlimit; int *p; int *skip; int *cskip; @@ -68,8 +68,8 @@ void S_TransferPaintBuffer(soundcardinfo_t *sc, int endtime) skip = paintskip[sc->sn.numchannels-1]; cskip = chnskip[sc->sn.numchannels-1]; count = (endtime - sc->paintedtime) * sc->sn.numchannels; - out_mask = sc->sn.samples - 1; - startidx = out_idx = (sc->paintedtime * sc->sn.numchannels) & out_mask; + outlimit = sc->sn.samples; + startidx = out_idx = (sc->paintedtime * sc->sn.numchannels) % outlimit; snd_vol = volume.value*256; pbuf = sc->Lock(sc); @@ -88,7 +88,7 @@ void S_TransferPaintBuffer(soundcardinfo_t *sc, int endtime) else if (val < (short)0x8000) val = (short)0x8000; out[out_idx] = val; - out_idx = (out_idx + 1) & out_mask; + out_idx = (out_idx + 1) % outlimit; skip += *cskip; cskip += *cskip; } @@ -99,7 +99,7 @@ void S_TransferPaintBuffer(soundcardinfo_t *sc, int endtime) if (out_idx <= startidx) // buffer looped { Media_RecordAudioFrame(out + startidx, (sc->sn.samples - startidx) / 2); - Media_RecordAudioFrame(out, out_idx / (2*2)); + Media_RecordAudioFrame(out, out_idx / 2); } else Media_RecordAudioFrame(out + startidx, (out_idx - startidx) / 2); @@ -117,7 +117,7 @@ void S_TransferPaintBuffer(soundcardinfo_t *sc, int endtime) else if (val < (short)0x8000) val = (short)0x8000; out[out_idx] = (val>>8) + 128; - out_idx = (out_idx + 1) & out_mask; + out_idx = (out_idx + 1) & outlimit; skip += *cskip; cskip += *cskip; } diff --git a/engine/server/sv_ccmds.c b/engine/server/sv_ccmds.c index 72284a92f..c216503b0 100644 --- a/engine/server/sv_ccmds.c +++ b/engine/server/sv_ccmds.c @@ -172,7 +172,6 @@ void SV_SetMaster_f (void) svs.last_heartbeat = -99999; } - /* ================== SV_Quit_f diff --git a/engine/server/sv_sys_win.c b/engine/server/sv_sys_win.c index 4eb803a47..f3c098d85 100644 --- a/engine/server/sv_sys_win.c +++ b/engine/server/sv_sys_win.c @@ -289,6 +289,8 @@ void Sys_Error (const char *error, ...) va_list argptr; char text[1024]; double end; + LPWSTR *szArglist; + int nArgs; va_start (argptr,error); vsnprintf (text,sizeof(text)-1, error,argptr); @@ -329,7 +331,8 @@ void Sys_Error (const char *error, ...) // free(host_parms.membase); //get rid of the mem. We don't need it now. // system("dqwsv.exe"); //spawn a new server to take over. This way, if debugging, then any key will quit, otherwise the server will just spawn a new one. GetModuleFileName(NULL, text, sizeof(text)); - spawnl(P_NOWAIT|P_OVERLAY, text, text, GetCommandLine(), NULL); + szArglist = CommandLineToArgV(GetCommandLine(), &nArgs); + spawnv(P_NOWAIT|P_OVERLAY, text, text, szArglist); Sys_Quit (); }