Fixed a crash when trying to play a NULL sound when comparing filenames.
This commit is contained in:
parent
1e46c5f669
commit
6f4199658a
2 changed files with 29 additions and 42 deletions
|
@ -315,10 +315,10 @@ sfx_t *S_FindName (char *name)
|
|||
sfx_t *sfx;
|
||||
|
||||
if (!name)
|
||||
Sys_Error ("S_FindName: NULL\n");
|
||||
Sys_Error ("[SOUND] S_FindName: NULL\n");
|
||||
|
||||
if (strlen(name) >= MAX_QPATH)
|
||||
Sys_Error ("Sound name too long: %s", name);
|
||||
Sys_Error ("[SOUND] Name too long: %s", name);
|
||||
|
||||
// see if already loaded
|
||||
for (i=0 ; i < num_sfx ; i++)
|
||||
|
@ -328,7 +328,7 @@ sfx_t *S_FindName (char *name)
|
|||
}
|
||||
|
||||
if (num_sfx == MAX_SFX)
|
||||
Sys_Error ("S_FindName: out of sfx_t");
|
||||
Sys_Error ("[SOUND] S_FindName: out of sfx_t");
|
||||
|
||||
sfx = &known_sfx[i];
|
||||
strcpy (sfx->name, name);
|
||||
|
@ -495,6 +495,11 @@ void S_StartSound(int entnum, int entchannel, sfx_t *sfx, vec3_t origin, float f
|
|||
{
|
||||
if(!snd_initialized)
|
||||
return;
|
||||
if(!sfx->name)
|
||||
{
|
||||
Con_DPrintf("[SOUND] No path specified!\n");
|
||||
return;
|
||||
}
|
||||
|
||||
channel_t *target_chan, *check;
|
||||
sfxcache_t *sc;
|
||||
|
@ -535,10 +540,8 @@ void S_StartSound(int entnum, int entchannel, sfx_t *sfx, vec3_t origin, float f
|
|||
|
||||
if (!sound_started)
|
||||
return;
|
||||
|
||||
if (!sfx)
|
||||
return;
|
||||
|
||||
if (nosound->value)
|
||||
return;
|
||||
|
||||
|
@ -547,8 +550,6 @@ void S_StartSound(int entnum, int entchannel, sfx_t *sfx, vec3_t origin, float f
|
|||
if ((!strncmp(sfx->name,"player/",7)) && attenuation < 1)
|
||||
attenuation = 1;
|
||||
|
||||
|
||||
|
||||
itch = (float)s_pitchin->value; // leilei - get pitch for speed here
|
||||
vol = fvol*255;
|
||||
|
||||
|
@ -661,6 +662,12 @@ void S_StartSound2(int entnum, int entchannel, sfx_t *sfx, vec3_t origin, float
|
|||
if(!snd_initialized)
|
||||
return;
|
||||
|
||||
if(!sfx->name)
|
||||
{
|
||||
Con_DPrintf("[SOUND] No path specified!\n");
|
||||
return;
|
||||
}
|
||||
|
||||
channel_t *target_chan, *check;
|
||||
sfxcache_t *sc;
|
||||
int vol;
|
||||
|
@ -766,11 +773,6 @@ void S_StopAllSounds(qboolean clear)
|
|||
if (!sound_started)
|
||||
return;
|
||||
|
||||
#ifdef ASS_MIDI
|
||||
MUSIC_StopSong();
|
||||
Tracker_Stop();
|
||||
#endif
|
||||
|
||||
total_channels = MAX_DYNAMIC_CHANNELS + NUM_AMBIENTS; // no statics
|
||||
|
||||
for (i=0 ; i<MAX_CHANNELS ; i++)
|
||||
|
@ -791,9 +793,7 @@ void S_StopAllSoundsC (void)
|
|||
void S_ClearBuffer (void)
|
||||
{
|
||||
int clear;
|
||||
#ifdef ASS_MIDI
|
||||
// MUSIC_StopSong();
|
||||
#endif
|
||||
|
||||
#ifdef _WIN32
|
||||
if (!sound_started || !shm || (!shm->buffer && !pDSBuf))
|
||||
#else
|
||||
|
@ -820,14 +820,14 @@ void S_ClearBuffer (void)
|
|||
{
|
||||
if (hresult != DSERR_BUFFERLOST)
|
||||
{
|
||||
Con_Printf ("S_ClearBuffer: DS::Lock Sound Buffer Failed\n");
|
||||
Con_Printf ("[SOUND] DS::Lock Sound Buffer Failed\n");
|
||||
S_Shutdown ();
|
||||
return;
|
||||
}
|
||||
|
||||
if (++reps > 10000)
|
||||
{
|
||||
Con_Printf ("S_ClearBuffer: DS: couldn't restore buffer\n");
|
||||
Con_Printf ("[SOUND] DS: couldn't restore buffer\n");
|
||||
S_Shutdown ();
|
||||
return;
|
||||
}
|
||||
|
@ -861,7 +861,7 @@ void S_StaticSound (sfx_t *sfx, vec3_t origin, float vol, float attenuation)
|
|||
|
||||
if (total_channels == MAX_CHANNELS)
|
||||
{
|
||||
Con_Printf ("total_channels == MAX_CHANNELS\n");
|
||||
Con_Printf ("[SOUND] total_channels == MAX_CHANNELS\n");
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -874,7 +874,7 @@ void S_StaticSound (sfx_t *sfx, vec3_t origin, float vol, float attenuation)
|
|||
|
||||
if (sc->loopstart == -1)
|
||||
{
|
||||
Con_Printf ("Sound %s not looped\n", sfx->name);
|
||||
Con_Printf ("[SOUND] Sound %s not looped\n", sfx->name);
|
||||
return;
|
||||
}
|
||||
ss->step = 256;
|
||||
|
@ -1090,19 +1090,6 @@ void S_ExtraUpdate (void)
|
|||
S_Update_();
|
||||
}
|
||||
|
||||
void MIDI_Update(void)
|
||||
{
|
||||
|
||||
|
||||
#ifdef ASS_MIDI
|
||||
MUSIC_SetVolume( midivolume->value * 256);
|
||||
MUSIC_Update(); // leilei - IT WORKS! IT WOOOOOOOOORKS!!!!!!!!!
|
||||
|
||||
#endif
|
||||
|
||||
|
||||
}
|
||||
|
||||
int oldspat;
|
||||
int oldspatval;
|
||||
|
||||
|
@ -1153,7 +1140,7 @@ void S_Update_(void)
|
|||
if (pDSBuf)
|
||||
{
|
||||
if (pDSBuf->lpVtbl->GetStatus (pDSBuf, &dwStatus) != DD_OK)
|
||||
Con_Printf ("Couldn't get sound buffer status\n");
|
||||
Con_Printf ("[SOUND] Couldn't get buffer status\n");
|
||||
|
||||
if (dwStatus & DSBSTATUS_BUFFERLOST)
|
||||
pDSBuf->lpVtbl->Restore (pDSBuf);
|
||||
|
@ -1253,7 +1240,7 @@ void S_SoundList(void)
|
|||
Con_Printf (" ");
|
||||
Con_Printf("(%2db) %6i : %s\n",sc->width*8, size, sfx->name);
|
||||
}
|
||||
Con_Printf ("Total resident: %i\n", total);
|
||||
Con_Printf ("[SOUND] Total resident: %i\n", total);
|
||||
}
|
||||
|
||||
|
||||
|
@ -1269,7 +1256,7 @@ void S_LocalSound (char *sound)
|
|||
sfx = S_PrecacheSound (sound);
|
||||
if (!sfx)
|
||||
{
|
||||
Con_Printf ("S_LocalSound: can't cache %s\n", sound);
|
||||
Con_Printf ("[SOUND] Local Sound: can't cache %s\n", sound);
|
||||
return;
|
||||
}
|
||||
S_StartSound (cl.viewentity, -1, sfx, vec3_origin, 1, 1);
|
||||
|
|
|
@ -21,7 +21,7 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
|||
|
||||
#include "globaldef.h"
|
||||
|
||||
int cache_full_cycle;
|
||||
int cache_full_cycle;
|
||||
|
||||
byte *S_Alloc (int size);
|
||||
|
||||
|
@ -226,7 +226,7 @@ sfxcache_t *S_LoadSound (sfx_t *s)
|
|||
if (!fileinfo)
|
||||
// 2001-09-12 Returning information about loaded file by Maddes end
|
||||
{
|
||||
Con_Printf ("Couldn't load %s\n", namebuffer);
|
||||
Con_Printf ("[SOUND] Couldn't load %s\n", namebuffer);
|
||||
return NULL;
|
||||
}
|
||||
data = fileinfo->data; // 2001-09-12 Returning information about loaded file by Maddes
|
||||
|
@ -379,7 +379,7 @@ wavinfo_t GetWavinfo (char *name, byte *wav, int wavlength)
|
|||
FindChunk("RIFF");
|
||||
if (!(data_p && !strncmp(data_p+8, "WAVE", 4)))
|
||||
{
|
||||
Con_Printf("Missing RIFF/WAVE chunks\n");
|
||||
Con_Printf("[SOUND] Missing RIFF/WAVE chunks\n");
|
||||
return info;
|
||||
}
|
||||
|
||||
|
@ -390,14 +390,14 @@ wavinfo_t GetWavinfo (char *name, byte *wav, int wavlength)
|
|||
FindChunk("fmt ");
|
||||
if (!data_p)
|
||||
{
|
||||
Con_Printf("Missing fmt chunk\n");
|
||||
Con_Printf("[SOUND] Missing fmt chunk\n");
|
||||
return info;
|
||||
}
|
||||
data_p += 8;
|
||||
format = GetLittleShort();
|
||||
if (format != 1)
|
||||
{
|
||||
Con_Printf("Microsoft PCM format only\n");
|
||||
Con_Printf("[SOUND] Microsoft PCM format only\n");
|
||||
return info;
|
||||
}
|
||||
|
||||
|
@ -434,7 +434,7 @@ wavinfo_t GetWavinfo (char *name, byte *wav, int wavlength)
|
|||
FindChunk("data");
|
||||
if (!data_p)
|
||||
{
|
||||
Con_Printf("Missing data chunk\n");
|
||||
Con_Printf("[SOUND] Missing data chunk\n");
|
||||
return info;
|
||||
}
|
||||
|
||||
|
@ -444,7 +444,7 @@ wavinfo_t GetWavinfo (char *name, byte *wav, int wavlength)
|
|||
if (info.samples)
|
||||
{
|
||||
if (samples < info.samples)
|
||||
Sys_Error ("Sound %s has a bad loop length", name);
|
||||
Sys_Error ("[SOUND] %s has a bad loop length", name);
|
||||
}
|
||||
else
|
||||
info.samples = samples;
|
||||
|
|
Loading…
Reference in a new issue