It's me again...

I have following function to play a sound (it's called in while loop). This function plays a beginning sound, if the beginning sound is over, it plays the loop sound:

Code:
#define SND_MULTIPLIER 0.75
#define SND_RANGE 20
var SND_sfx_volume=100;

void ent_sound_start(ENTITY* ent_,SOUND* sndBegin,SOUND* sndLoop,SOUND* sndEnd,var* sndBeginHndl,var* sndLoopHndl,var* sndEndHndl)
{
	snd_stop(*sndEndHndl);
	if(sndBegin!=NULL
	&& !snd_playing(*sndBeginHndl)
	&& !snd_playing(*sndLoopHndl)
	&& *sndBeginHndl==0)
	{*sndBeginHndl=ent_playsound(ent_,sndBegin,SND_sfx_volume*SND_MULTIPLIER*SND_RANGE);}
	if(sndLoop!=NULL
	&& !snd_playing(*sndBeginHndl)
	&& !snd_playing(*sndLoopHndl))
	{*sndLoopHndl=ent_playloop(ent_,sndLoop,SND_sfx_volume*SND_MULTIPLIER*SND_RANGE);}
}



99% percent of the time I call this function, it works very well. But sometimes I get a random crash in the instruction "snd_playing(*sndLoopHndl)". I really don't know what's wrong. I guess it's something with pointers.

Last edited by oliver2s; 10/09/13 15:29.