--- np2/sound/sound.c 2003/10/22 15:21:23 1.6 +++ np2/sound/sound.c 2003/11/28 08:01:33 1.9 @@ -33,9 +33,11 @@ static SNDSTREAM sndstream; static void streamreset(void) { + SNDCSEC_ENTER; sndstream.ptr = sndstream.buffer; sndstream.remain = sndstream.samples + sndstream.reserve; sndstream.cbreg = sndstream.cb; + SNDCSEC_LEAVE; } static void streamprepare(UINT samples) { @@ -95,9 +97,9 @@ BOOL sound_create(UINT rate, UINT ms) { } sndstream.samples = samples; sndstream.reserve = reserve; - streamreset(); SNDCSEC_INIT; + streamreset(); return(SUCCESS); scre_err2: @@ -111,6 +113,7 @@ void sound_destroy(void) { if (sndstream.buffer) { soundmng_stop(); + streamreset(); soundmng_destroy(); SNDCSEC_TERM; _MFREE(sndstream.buffer); @@ -205,6 +208,7 @@ const SINT32 *sound_pcmlock(void) { const SINT32 *ret; if (locks) { + TRACEOUT(("sound pcm lock: already locked")); return(NULL); } locks++; @@ -217,6 +221,9 @@ const SINT32 *ret; beep_eventreset(); } } + else { + locks--; + } return(ret); }