From d98413121d6525b3e7d71f35d216c00b8e485417 Mon Sep 17 00:00:00 2001 From: JonnyPtn Date: Thu, 26 Sep 2024 23:18:01 +0100 Subject: [PATCH] Just skip sounds for now if not found --- linuxdoom-1.10/i_sound.cpp | 38 ++++++++++++++++++++++---------------- 1 file changed, 22 insertions(+), 16 deletions(-) diff --git a/linuxdoom-1.10/i_sound.cpp b/linuxdoom-1.10/i_sound.cpp index 93d6a08..a750565 100644 --- a/linuxdoom-1.10/i_sound.cpp +++ b/linuxdoom-1.10/i_sound.cpp @@ -45,7 +45,6 @@ import wad; import argv; import doomdef; - // Update all 30 millisecs, approx. 30fps synchronized. // Linux resolution is allegedly 10 millisecs, // scale is microseconds. @@ -356,7 +355,14 @@ void I_SetMusicVolume(int volume) { // Retrieve the raw data lump index // for a given SFX name. // -int I_GetSfxLumpNum(sfxinfo_t *sfx) { return W_GetNumForName(sfx->name); } +int I_GetSfxLumpNum(sfxinfo_t *sfx) { + if (W_CheckNumForName(sfx->name) != -1) { + return W_GetNumForName(sfx->name); + } else { + I_Debug("Failed getting sfx lump number for: {}", sfx->name); + return -1; + } +} // // Starting a sound means adding it @@ -562,7 +568,7 @@ void I_ShutdownSound(void) { I_SoundDelTimer(); // Cleaning up -releasing the DSP device. - //close(audio_fd); + // close(audio_fd); // Done. return; @@ -578,27 +584,27 @@ void I_InitSound() { // Secure and configure sound device first. fprintf(stderr, "I_InitSound: "); - //audio_fd = open("/dev/dsp", O_WRONLY); - //if (audio_fd < 0) - // fprintf(stderr, "Could not open /dev/dsp\n"); + // audio_fd = open("/dev/dsp", O_WRONLY); + // if (audio_fd < 0) + // fprintf(stderr, "Could not open /dev/dsp\n"); i = 11 | (2 << 16); - //myioctl(audio_fd, SNDCTL_DSP_SETFRAGMENT, &i); - //myioctl(audio_fd, SNDCTL_DSP_RESET, 0); + // myioctl(audio_fd, SNDCTL_DSP_SETFRAGMENT, &i); + // myioctl(audio_fd, SNDCTL_DSP_RESET, 0); i = SAMPLERATE; - //myioctl(audio_fd, SNDCTL_DSP_SPEED, &i); + // myioctl(audio_fd, SNDCTL_DSP_SPEED, &i); i = 1; - //myioctl(audio_fd, SNDCTL_DSP_STEREO, &i); + // myioctl(audio_fd, SNDCTL_DSP_STEREO, &i); - //myioctl(audio_fd, SNDCTL_DSP_GETFMTS, &i); + // myioctl(audio_fd, SNDCTL_DSP_GETFMTS, &i); - //if (i &= AFMT_S16_LE) - //myioctl(audio_fd, SNDCTL_DSP_SETFMT, &i); - //else - //fprintf(stderr, "Could not play signed 16 data\n"); + // if (i &= AFMT_S16_LE) + // myioctl(audio_fd, SNDCTL_DSP_SETFMT, &i); + // else + // fprintf(stderr, "Could not play signed 16 data\n"); fprintf(stderr, " configured audio device\n"); @@ -609,7 +615,7 @@ void I_InitSound() { // Alias? Example is the chaingun sound linked to pistol. if (!S_sfx[i].link) { // Load data from WAD file. - //S_sfx[i].data = getsfx(S_sfx[i].name, &lengths[i]); + // S_sfx[i].data = getsfx(S_sfx[i].name, &lengths[i]); } else { // Previously loaded already? S_sfx[i].data = S_sfx[i].link->data;