--- np2/sound/sound.c 2003/10/22 15:21:23 1.6 +++ np2/sound/sound.c 2004/01/13 05:30:59 1.12 @@ -1,13 +1,12 @@ #include "compiler.h" #include "soundmng.h" -#include "i286.h" +#include "cpucore.h" #include "pccore.h" #include "iocore.h" #include "sound.h" #include "sndcsec.h" #include "beep.h" - SOUNDCFG soundcfg; @@ -33,9 +32,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 +96,9 @@ BOOL sound_create(UINT rate, UINT ms) { } sndstream.samples = samples; sndstream.reserve = reserve; - streamreset(); SNDCSEC_INIT; + streamreset(); return(SUCCESS); scre_err2: @@ -111,6 +112,7 @@ void sound_destroy(void) { if (sndstream.buffer) { soundmng_stop(); + streamreset(); soundmng_destroy(); SNDCSEC_TERM; _MFREE(sndstream.buffer); @@ -123,7 +125,7 @@ void sound_reset(void) { if (sndstream.buffer) { soundmng_reset(); streamreset(); - soundcfg.lastclock = I286_CLOCK; + soundcfg.lastclock = CPU_CLOCK; beep_eventreset(); } } @@ -139,7 +141,7 @@ void sound_changeclock(void) { } // とりあえず 25で割り切れる。 - clock = pc.realclock / 25; + clock = pccore.realclock / 25; hz = soundcfg.rate / 25; // で、クロック数に合せて調整。(64bit演算しろよな的) @@ -151,7 +153,7 @@ void sound_changeclock(void) { soundcfg.hzbase = hz; soundcfg.clockbase = clock; soundcfg.minclock = 2 * clock / hz; - soundcfg.lastclock = I286_CLOCK; + soundcfg.lastclock = CPU_CLOCK; } void sound_streamregist(void *hdl, SOUNDCB cbfn) { @@ -177,7 +179,7 @@ void sound_sync(void) { return; } - length = I286_CLOCK + I286_BASECLOCK - I286_REMCLOCK - soundcfg.lastclock; + length = CPU_CLOCK + CPU_BASECLOCK - CPU_REMCLOCK - soundcfg.lastclock; if (length < soundcfg.minclock) { return; } @@ -205,6 +207,7 @@ const SINT32 *sound_pcmlock(void) { const SINT32 *ret; if (locks) { + TRACEOUT(("sound pcm lock: already locked")); return(NULL); } locks++; @@ -213,10 +216,13 @@ const SINT32 *ret; SNDCSEC_ENTER; if (sndstream.remain > sndstream.reserve) { streamprepare(sndstream.remain - sndstream.reserve); - soundcfg.lastclock = I286_CLOCK + I286_BASECLOCK - I286_REMCLOCK; + soundcfg.lastclock = CPU_CLOCK + CPU_BASECLOCK - CPU_REMCLOCK; beep_eventreset(); } } + else { + locks--; + } return(ret); }