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;