From 8730ce552b5d78aabccd575fda6692fbff0cafcc Mon Sep 17 00:00:00 2001 From: Christoph Oelckers Date: Thu, 24 Oct 2019 20:28:46 +0200 Subject: [PATCH] - make things compile again. Let's hope it still works... --- source/CMakeLists.txt | 15 +- source/audiolib/include/multivoc.h | 2 - source/audiolib/src/driver_sdl.cpp | 2 +- source/audiolib/src/driver_winmm.h | 33 --- source/audiolib/src/drivers.cpp | 3 +- source/audiolib/src/music_external.cpp | 318 ---------------------- source/blood/src/blood.cpp | 1 - source/blood/src/sound.cpp | 3 +- source/build/include/cache1d.h | 8 +- source/common/gamecvars.cpp | 9 + source/common/gamecvars.h | 1 + source/duke3d/src/menus.cpp | 4 +- source/duke3d/src/sounds.cpp | 10 +- source/libsmackerdec/include/FileStream.h | 1 + source/libsmackerdec/src/FileStream.cpp | 1 + source/rr/src/sounds.cpp | 2 +- source/sw/src/sounds.cpp | 6 +- 17 files changed, 41 insertions(+), 378 deletions(-) delete mode 100644 source/audiolib/src/driver_winmm.h delete mode 100644 source/audiolib/src/music_external.cpp diff --git a/source/CMakeLists.txt b/source/CMakeLists.txt index f72109512..b3b23e303 100644 --- a/source/CMakeLists.txt +++ b/source/CMakeLists.txt @@ -510,8 +510,8 @@ set( PLAT_WIN32_SOURCES ) set( PLAT_POSIX_SOURCES - audiolib/src/driver_sdl.cpp - audiolib/src/sdlmusic.cpp + #audiolib/src/driver_sdl.cpp + #audiolib/src/sdlmusic.cpp ) set( PLAT_SDL_SOURCES @@ -702,11 +702,6 @@ set( FASTMATH_SOURCES thirdparty/src/lz4.c thirdparty/src/xxhash.c - # Will we need this anymore with ZLib being available? - #thirdparty/src/miniz.c - #thirdparty/src/miniz_tdef.c - #thirdparty/src/miniz_tinfl.c - # Another bit of cruft just to make S(hit)DL happy... sdlappicon.cpp ) @@ -714,7 +709,9 @@ set( FASTMATH_SOURCES set (PCH_SOURCES audiolib/src/drivers.cpp + audiolib/src/driver_adlib.cpp audiolib/src/driver_nosound.cpp + audiolib/src/driver_sdl.cpp audiolib/src/flac.cpp audiolib/src/formats.cpp audiolib/src/fx_man.cpp @@ -722,14 +719,14 @@ set (PCH_SOURCES audiolib/src/midi.cpp audiolib/src/mix.cpp audiolib/src/mixst.cpp - audiolib/src/mpu401.cpp audiolib/src/multivoc.cpp audiolib/src/music.cpp + audiolib/src/opl3.cpp audiolib/src/pitch.cpp audiolib/src/vorbis.cpp audiolib/src/xa.cpp audiolib/src/xmp.cpp - + glbackend/gl_hwtexture.cpp glbackend/gl_samplers.cpp glbackend/gl_shader.cpp diff --git a/source/audiolib/include/multivoc.h b/source/audiolib/include/multivoc.h index ea31ce9e5..949e9dfdf 100644 --- a/source/audiolib/include/multivoc.h +++ b/source/audiolib/include/multivoc.h @@ -132,6 +132,4 @@ void MV_UnhookMusicRoutine(void); static inline void MV_SetPrintf(void (*function)(const char *, ...)) { if (function) MV_Printf = function; } -#ifdef __cplusplus -} #endif diff --git a/source/audiolib/src/driver_sdl.cpp b/source/audiolib/src/driver_sdl.cpp index c1a6a2a9b..2d06915c1 100644 --- a/source/audiolib/src/driver_sdl.cpp +++ b/source/audiolib/src/driver_sdl.cpp @@ -189,7 +189,7 @@ int SDLDrv_PCM_Init(int *mixrate, int *numchannels, void * initdata) auto drivername = Xstrdup(SDL_GetCurrentAudioDriver()); for (int i=0;drivername[i] != 0;++i) - drivername[i] = toupperlookup[drivername[i]]; + drivername[i] = toupper(drivername[i]); auto devname = Xstrdup(SDL_GetAudioDeviceName(0, 0)); auto pdevname = Bstrchr(devname, '('); diff --git a/source/audiolib/src/driver_winmm.h b/source/audiolib/src/driver_winmm.h deleted file mode 100644 index 51c71d2b6..000000000 --- a/source/audiolib/src/driver_winmm.h +++ /dev/null @@ -1,33 +0,0 @@ -/* - Copyright (C) 2009 Jonathon Fowler - - This program is free software; you can redistribute it and/or - modify it under the terms of the GNU General Public License - as published by the Free Software Foundation; either version 2 - of the License, or (at your option) any later version. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. - - See the GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program; if not, write to the Free Software - Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. - - */ - -#include "midifuncs.h" - -int WinMMDrv_GetError(void); -const char *WinMMDrv_ErrorString( int ErrorNumber ); - -int WinMMDrv_MIDI_Init(midifuncs *); -void WinMMDrv_MIDI_Shutdown(void); -int WinMMDrv_MIDI_StartPlayback(void (*service)(void)); -void WinMMDrv_MIDI_HaltPlayback(void); -void WinMMDrv_MIDI_SetTempo(int tempo, int division); -void WinMMDrv_MIDI_Lock(void); -void WinMMDrv_MIDI_Unlock(void); - diff --git a/source/audiolib/src/drivers.cpp b/source/audiolib/src/drivers.cpp index d33da4c5c..700fd06de 100644 --- a/source/audiolib/src/drivers.cpp +++ b/source/audiolib/src/drivers.cpp @@ -34,7 +34,6 @@ #ifdef _WIN32 # include "driver_directsound.h" -# include "driver_winmm.h" #endif int ASS_PCMSoundDriver = ASS_AutoDetect; @@ -140,6 +139,7 @@ static struct { nullptr, }, +#if 0 // Windows MultiMedia system { "WinMM", @@ -160,6 +160,7 @@ static struct { UNSUPPORTED_COMPLETELY #endif }, +#endif }; diff --git a/source/audiolib/src/music_external.cpp b/source/audiolib/src/music_external.cpp deleted file mode 100644 index f6ffe1099..000000000 --- a/source/audiolib/src/music_external.cpp +++ /dev/null @@ -1,318 +0,0 @@ -//------------------------------------------------------------------------- -/* -Copyright (C) 2010 EDuke32 developers and contributors - -This file is part of EDuke32. - -EDuke32 is free software; you can redistribute it and/or -modify it under the terms of the GNU General Public License version 2 -as published by the Free Software Foundation. - -This program is distributed in the hope that it will be useful, -but WITHOUT ANY WARRANTY; without even the implied warranty of -MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. - -See the GNU General Public License for more details. - -You should have received a copy of the GNU General Public License -along with this program; if not, write to the Free Software -Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. -*/ -//------------------------------------------------------------------------- - -#include "compat.h" -#include "multivoc.h" -#include "music.h" -#include "vfs.h" -#include "winbits.h" - -// fork/exec based external music player -#ifndef _WIN32 -#include -#include -#include - -#define INVALID_HANDLE_VALUE -1 -typedef pid_t proc_t; -#else -typedef HANDLE proc_t; -#endif - -static char ** g_musicPlayerArgv; -static int g_musicPlayerEnabled; -static proc_t g_musicPlayerHandle = INVALID_HANDLE_VALUE; -static int g_musicPlayerReady; -static int8_t g_musicPlayerRestart; -static char * g_musicPlayerCommandLine; - -static char g_musicFileName[BMAX_PATH]; -static int g_musicFileNameArgvPos; - -char const *errorMessage; - -int MUSIC_Init(int SoundCard) -{ - // Use an external music player - g_musicPlayerCommandLine = getenv("EDUKE32_MUSIC_CMD"); - - UNREFERENCED_PARAMETER(SoundCard); - - if (g_musicPlayerReady) - { - errorMessage = "MUSIC_Init: external player already initialized!"; - return MUSIC_Error; - } // if - - g_musicPlayerEnabled = (g_musicPlayerCommandLine && g_musicPlayerCommandLine[0]); - - if (!g_musicPlayerEnabled) - { - errorMessage = "MUSIC_Init: no external player configured!"; - return MUSIC_Error; - } - - MV_Printf("Using external music player: \"%s\"\n", g_musicPlayerCommandLine); - -#ifndef _WIN32 - int ws=1, numargs=0, pagesize=Bgetpagesize(); - char *c, *cmd; - size_t sz; - - if (pagesize == -1) - { - errorMessage = "MUSIC_Init: unable to determine system page size"; - return MUSIC_Error; - } - for (c=g_musicPlayerCommandLine; *c; c++) - { - if (isspace(*c)) - ws = 1; - else if (ws) - { - ws = 0; - numargs++; - } - } - - if (numargs == 0) - { - errorMessage = "MUSIC_Init: not enough arguments for external player"; - return MUSIC_Error; - } - - sz = (numargs+2)*sizeof(char *) + (c-g_musicPlayerCommandLine+1); - sz = ((sz+pagesize-1)/pagesize)*pagesize; - g_musicPlayerArgv = (char **)Xaligned_alloc(pagesize, sz); - cmd = (char *)g_musicPlayerArgv + (numargs+2)*sizeof(intptr_t); - Bmemcpy(cmd, g_musicPlayerCommandLine, c-g_musicPlayerCommandLine+1); - - ws = 1; - numargs = 0; - for (c=cmd; *c; c++) - { - if (isspace(*c)) - { - ws = 1; - *c = 0; - } - else if (ws) - { - ws = 0; - g_musicPlayerArgv[numargs++] = c; - } - } - g_musicFileNameArgvPos = numargs; - g_musicPlayerArgv[numargs] = g_musicFileName; - g_musicPlayerArgv[numargs+1] = nullptr; - -#if 0 - if (mprotect(g_musicPlayerArgv, sz, PROT_READ)==-1) // make argv and command string read-only - { - initprintf("MUSIC_Init: mprotect(): %s\n"); - errorMessage = "MUSIC_Init: mprotect() failure"; - return MUSIC_Error; - } -#endif -#endif - - g_musicPlayerReady = 1; - return MUSIC_Ok; -} - - -int MUSIC_Shutdown(void) -{ - MUSIC_StopSong(); - g_musicPlayerReady = 0; - - return MUSIC_Ok; -} // MUSIC_Shutdown - -int MUSIC_StopSong(void) -{ - if (!g_musicPlayerEnabled) - return MUSIC_Ok; - - if (g_musicPlayerHandle != INVALID_HANDLE_VALUE) - { - g_musicPlayerRestart = 0; // make SIGCHLD handler a no-op - -#ifndef _WIN32 - struct timespec ts; - - ts.tv_sec = 0; - ts.tv_nsec = 5000000; // sleep 5ms at most - - kill(g_musicPlayerHandle, SIGTERM); - nanosleep(&ts, nullptr); - - if (int ret = waitpid(g_musicPlayerHandle, nullptr, WNOHANG|WUNTRACED) != g_musicPlayerHandle) - { - if (ret==-1) - initprintf("%s: waitpid: %s\n", __func__, strerror(errno)); - else - { - // we tried to be nice, but no... - kill(g_musicPlayerHandle, SIGKILL); - - initprintf("%s: SIGTERM timed out--trying SIGKILL\n", __func__); - - if (waitpid(g_musicPlayerHandle, nullptr, WUNTRACED)==-1) - initprintf("%s: waitpid: %s\n", __func__, strerror(errno)); - } - } -#else - TerminateProcess(g_musicPlayerHandle, 0); -#endif - g_musicPlayerHandle = INVALID_HANDLE_VALUE; - } - - return MUSIC_Ok; -} // MUSIC_StopSong - -static int MUSIC_PlayExternal() -{ -#ifdef _WIN32 - STARTUPINFO si; - PROCESS_INFORMATION pi; - - ZeroMemory(&si,sizeof(si)); - ZeroMemory(&pi,sizeof(pi)); - si.cb = sizeof(si); - - if (!CreateProcess(nullptr,g_musicPlayerCommandLine,nullptr,nullptr,0,0,nullptr,nullptr,&si,&pi)) - { - MV_Printf("%s: CreateProcess: %s\n", __func__, windowsGetErrorMessage(GetLastError())); - return MUSIC_Error; - } - else - g_musicPlayerHandle = pi.hProcess; -#else - proc_t pid = vfork(); - - if (pid==-1) // error - { - initprintf("%s: vfork: %s\n", __func__, strerror(errno)); - return MUSIC_Error; - } - else if (pid==0) // child - { - // exec without PATH lookup - if (execv(g_musicPlayerArgv[0], g_musicPlayerArgv) < 0) - { - initprintf("%s: execv: %s\n", __func__, strerror(errno)); - _exit(EXIT_FAILURE); - } - } - else // parent - { - g_musicPlayerHandle = pid; - } -#endif - return MUSIC_Ok; -} - -#ifndef _WIN32 -static void sigchld_handler(int signo) -{ - if (g_musicPlayerHandle <= 0 || !g_musicPlayerRestart || signo != SIGCHLD) - return; - - int status; - - if (waitpid(g_musicPlayerHandle, &status, WUNTRACED)==-1) - initprintf("%s: waitpid: %s\n", __func__, strerror(errno)); - - if (WIFEXITED(status) && WEXITSTATUS(status)==0) - { - // loop ... - MUSIC_PlayExternal(); - } -} -#endif - -int MUSIC_PlaySong(char *song, int songsize, int loopflag, const char *fn /*= nullptr*/) -{ - if (!g_musicPlayerEnabled) - { - errorMessage = "MUSIC_Init: no external player configured!"; - return MUSIC_Error; - } - -#ifndef _WIN32 - static int sigchld_handler_set; - - if (!sigchld_handler_set) - { - struct sigaction sa; - sa.sa_handler=sigchld_handler; - sa.sa_flags=0; - sigemptyset(&sa.sa_mask); - - if (sigaction(SIGCHLD, &sa, nullptr)==-1) - initprintf("%s: sigaction: %s\n", __func__, strerror(errno)); - - sigchld_handler_set = 1; - } -#endif - - auto ext = Xstrdup(fn); - auto const c = Bsnprintf(g_musicFileName, sizeof(g_musicFileName), "%s/external%s", Bgethomedir(), strtok(ext,".")); - g_musicFileName[c] = '\0'; - Xfree(ext); - - if (auto fp = buildvfs_fopen_write(g_musicFileName)) - { - buildvfs_fwrite(song, 1, songsize, fp); - buildvfs_fclose(fp); - - g_musicPlayerRestart = loopflag; - g_musicPlayerArgv[g_musicFileNameArgvPos] = g_musicFileName; - - if (int retval = MUSIC_PlayExternal() != MUSIC_Ok) - return retval; - } - else - { - MV_Printf("%s: fopen: %s\n", __func__, strerror(errno)); - return MUSIC_Error; - } - - return MUSIC_Ok; -} - - -void MUSIC_Update(void) -{ -#ifdef _WIN32 - if (g_musicPlayerHandle == INVALID_HANDLE_VALUE || !g_musicPlayerRestart) - return; - - DWORD exitCode = -1; - - GetExitCodeProcess(g_musicPlayerHandle, &exitCode); - - if (exitCode != STILL_ACTIVE) - MUSIC_PlayExternal(); -#endif -} diff --git a/source/blood/src/blood.cpp b/source/blood/src/blood.cpp index 47d436999..ec15bfeb6 100644 --- a/source/blood/src/blood.cpp +++ b/source/blood/src/blood.cpp @@ -1500,7 +1500,6 @@ int app_main(int argc, char const * const * argv) #ifdef DEBUGGINGAIDS extern int32_t (*check_filename_casing_fn)(void); check_filename_casing_fn = check_filename_casing; -#endif #endif OSD_SetLogFile(APPBASENAME ".log"); diff --git a/source/blood/src/sound.cpp b/source/blood/src/sound.cpp index 7c30594be..930c5b317 100644 --- a/source/blood/src/sound.cpp +++ b/source/blood/src/sound.cpp @@ -32,6 +32,7 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. #include "resource.h" #include "sound.h" #include "renderlayer.h" +#include "al_midi.h" BEGIN_BLD_NS @@ -451,7 +452,7 @@ void InitMusicDevice(void) DICTNODE *hTmb = gSoundRes.Lookup("GMTIMBRE", "TMB"); if (hTmb) AL_RegisterTimbreBank((unsigned char*)gSoundRes.Load(hTmb)); - MUSIC_SetVolume(MusicVolume); + MUSIC_SetVolume(mus_volume); } void DeinitMusicDevice(void) diff --git a/source/build/include/cache1d.h b/source/build/include/cache1d.h index d39db1ed2..b175cbee0 100644 --- a/source/build/include/cache1d.h +++ b/source/build/include/cache1d.h @@ -71,6 +71,11 @@ enum { CACHE1D_FIND_DRIVE = 4, CACHE1D_FIND_NOCURDIR = 8, + BUILDVFS_FIND_FILE = 1, + BUILDVFS_FIND_DIR = 2, + BUILDVFS_FIND_DRIVE = 4, + BUILDVFS_FIND_NOCURDIR = 8, + CACHE1D_OPT_NOSTACK = 0x100, // the lower the number, the higher the priority @@ -79,12 +84,13 @@ enum { CACHE1D_SOURCE_PATH = 2, // + path stack depth CACHE1D_SOURCE_ZIP = 0x7ffffffe, CACHE1D_SOURCE_GRP = 0x7fffffff, + BUILDVFS_SOURCE_GRP = 0x7fffffff, }; typedef struct _CACHE1D_FIND_REC { char *name; int32_t type, source; struct _CACHE1D_FIND_REC *next, *prev, *usera, *userb; -} CACHE1D_FIND_REC; +} CACHE1D_FIND_REC, BUILDVFS_FIND_REC; int32_t klistaddentry(CACHE1D_FIND_REC **rec, const char *name, int32_t type, int32_t source); void klistfree(CACHE1D_FIND_REC *rec); CACHE1D_FIND_REC *klistpath(const char *path, const char *mask, int type); diff --git a/source/common/gamecvars.cpp b/source/common/gamecvars.cpp index 0bc2adbcf..65fb5328c 100644 --- a/source/common/gamecvars.cpp +++ b/source/common/gamecvars.cpp @@ -154,6 +154,15 @@ CUSTOM_CVARD(Int, mus_volume, 255, CVAR_ARCHIVE|CVAR_GLOBALCONFIG, "controls mus if (self > 255) self = 255; } +int MusicDevice; +CUSTOM_CVARD(Int, mus_device, 1, CVAR_ARCHIVE | CVAR_GLOBALCONFIG, "selects music device") +{ + if (self < 0) self = 0; + else if (self > 1) self = 1; + else MusicDevice = self; // must be copied because it gets altered by the music code. +} + + // HUD // This was particularly messy. EDuke and Rednukem had no consistent setting for this but a complex combination fo 4 CVARs and lots of mod flags controlling the HUD layout diff --git a/source/common/gamecvars.h b/source/common/gamecvars.h index aee371c25..8d35f4478 100644 --- a/source/common/gamecvars.h +++ b/source/common/gamecvars.h @@ -48,6 +48,7 @@ EXTERN_CVAR(Int, snd_numchannels) EXTERN_CVAR(Int, snd_numvoices) EXTERN_CVAR(Int, snd_speech) EXTERN_CVAR(Int, mus_volume) +extern int MusicDevice; EXTERN_CVAR(Int, hud_layout) EXTERN_CVAR(Int, hud_scale) diff --git a/source/duke3d/src/menus.cpp b/source/duke3d/src/menus.cpp index cdd8d974c..717618ef9 100644 --- a/source/duke3d/src/menus.cpp +++ b/source/duke3d/src/menus.cpp @@ -3237,7 +3237,7 @@ static void Menu_EntryLinkActivate(MenuEntry_t *entry) { snd_mixrate = soundrate; snd_numvoices = soundvoices; - ud.config.MusicDevice = musicdevice; + MusicDevice = musicdevice; S_SoundShutdown(); S_MusicShutdown(); @@ -4260,7 +4260,7 @@ static void Menu_AboutToStartDisplaying(Menu_t * m) case MENU_ADVSOUND: soundrate = snd_mixrate; soundvoices = snd_numvoices; - musicdevice = ud.config.MusicDevice; + musicdevice = MusicDevice; break; default: diff --git a/source/duke3d/src/sounds.cpp b/source/duke3d/src/sounds.cpp index 434562759..7e48d13d1 100644 --- a/source/duke3d/src/sounds.cpp +++ b/source/duke3d/src/sounds.cpp @@ -67,7 +67,7 @@ void S_SoundStartup(void) initprintf("Initializing sound... "); - int status = FX_Init(ud.config.NumVoices, ud.config.NumChannels, ud.config.MixRate, initdata); + int status = FX_Init(snd_numvoices, snd_numchannels, snd_mixrate, initdata); if (status != FX_Ok) { initprintf("failed! %s\n", FX_ErrorString(status)); @@ -118,14 +118,14 @@ void S_MusicStartup(void) initprintf("Initializing MIDI driver... "); int status; - if ((status = MUSIC_Init(ud.config.MusicDevice)) == MUSIC_Ok) + if ((status = MUSIC_Init(MusicDevice)) == MUSIC_Ok) { - if (ud.config.MusicDevice == ASS_AutoDetect) - ud.config.MusicDevice = MIDI_GetDevice(); + if (MusicDevice == ASS_AutoDetect) + MusicDevice = MIDI_GetDevice(); } else if ((status = MUSIC_Init(ASS_AutoDetect)) == MUSIC_Ok) { - ud.config.MusicDevice = MIDI_GetDevice(); + MusicDevice = MIDI_GetDevice(); } else { diff --git a/source/libsmackerdec/include/FileStream.h b/source/libsmackerdec/include/FileStream.h index 3ddd05c1c..f9ef83c23 100644 --- a/source/libsmackerdec/include/FileStream.h +++ b/source/libsmackerdec/include/FileStream.h @@ -24,6 +24,7 @@ #include "vfs.h" #include "compat.h" #include +#include "files.h" namespace SmackerCommon { diff --git a/source/libsmackerdec/src/FileStream.cpp b/source/libsmackerdec/src/FileStream.cpp index 1cea5dbcd..a14428392 100644 --- a/source/libsmackerdec/src/FileStream.cpp +++ b/source/libsmackerdec/src/FileStream.cpp @@ -18,6 +18,7 @@ */ #include "FileStream.h" +#include "cache1d.h" #include namespace SmackerCommon { diff --git a/source/rr/src/sounds.cpp b/source/rr/src/sounds.cpp index 25ba5f646..aa060937b 100644 --- a/source/rr/src/sounds.cpp +++ b/source/rr/src/sounds.cpp @@ -98,7 +98,7 @@ void S_MusicStartup(void) { initprintf("Initializing music...\n"); - if (MUSIC_Init(0, 0) == MUSIC_Ok || MUSIC_Init(1, 0) == MUSIC_Ok) + if (MUSIC_Init(MusicDevice) == MUSIC_Ok) { MUSIC_SetVolume(mus_volume); return; diff --git a/source/sw/src/sounds.cpp b/source/sw/src/sounds.cpp index 7cb1db122..596aef16a 100644 --- a/source/sw/src/sounds.cpp +++ b/source/sw/src/sounds.cpp @@ -1131,7 +1131,7 @@ SoundStartup(void) //snd_enabled = TRUE; - int status = FX_Init(NumVoices, NumChannels, MixRate, initdata); + int status = FX_Init(snd_numvoices, snd_numchannels, snd_mixrate, initdata); if (status != FX_Ok) { buildprintf("Sound error: %s\n", FX_ErrorString(status)); @@ -1199,11 +1199,11 @@ void MusicStartup(void) } MusicInitialized = TRUE; - MUSIC_SetVolume(gs.MusicVolume); + MUSIC_SetVolume(mus_volume); auto fil = kopenFileReader("swtimbr.tmb", 0); - if (fil.isOpem()) + if (fil.isOpen()) { auto tmb = fil.Read(); if (tmb.Size())