|
|
| version 1.5, 2003/10/21 16:27:54 | version 1.8, 2003/11/13 17:01:17 |
|---|---|
| Line 33 static SNDSTREAM sndstream; | Line 33 static SNDSTREAM sndstream; |
| static void streamreset(void) { | static void streamreset(void) { |
| SNDCSEC_ENTER; | |
| sndstream.ptr = sndstream.buffer; | sndstream.ptr = sndstream.buffer; |
| sndstream.remain = sndstream.samples + sndstream.reserve; | sndstream.remain = sndstream.samples + sndstream.reserve; |
| sndstream.cbreg = sndstream.cb; | sndstream.cbreg = sndstream.cb; |
| SNDCSEC_LEAVE; | |
| } | } |
| static void streamprepare(UINT samples) { | static void streamprepare(UINT samples) { |
| Line 95 BOOL sound_create(UINT rate, UINT ms) { | Line 97 BOOL sound_create(UINT rate, UINT ms) { |
| } | } |
| sndstream.samples = samples; | sndstream.samples = samples; |
| sndstream.reserve = reserve; | sndstream.reserve = reserve; |
| streamreset(); | |
| SNDCSEC_INIT; | SNDCSEC_INIT; |
| streamreset(); | |
| return(SUCCESS); | return(SUCCESS); |
| scre_err2: | scre_err2: |
| Line 110 scre_err1: | Line 112 scre_err1: |
| void sound_destroy(void) { | void sound_destroy(void) { |
| if (sndstream.buffer) { | if (sndstream.buffer) { |
| SNDCSEC_TERM; | |
| soundmng_stop(); | soundmng_stop(); |
| streamreset(); | |
| soundmng_destroy(); | soundmng_destroy(); |
| SNDCSEC_TERM; | |
| _MFREE(sndstream.buffer); | _MFREE(sndstream.buffer); |
| sndstream.buffer = NULL; | sndstream.buffer = NULL; |
| } | } |
| Line 188 void sound_sync(void) { | Line 190 void sound_sync(void) { |
| } | } |
| SNDCSEC_ENTER; | SNDCSEC_ENTER; |
| streamprepare(length); | streamprepare(length); |
| SNDCSEC_LEAVE; | |
| soundcfg.writecount += length; | |
| soundcfg.lastclock += length * soundcfg.clockbase / soundcfg.hzbase; | soundcfg.lastclock += length * soundcfg.clockbase / soundcfg.hzbase; |
| beep_eventreset(); | beep_eventreset(); |
| SNDCSEC_LEAVE; | |
| soundcfg.writecount += length; | |
| if (soundcfg.writecount >= 100) { | if (soundcfg.writecount >= 100) { |
| soundcfg.writecount = 0; | soundcfg.writecount = 0; |
| soundmng_sync(); | soundmng_sync(); |
| } | } |
| } | } |
| static volatile int locks = 0; | |
| const SINT32 *sound_pcmlock(void) { | const SINT32 *sound_pcmlock(void) { |
| const SINT32 *ret; | const SINT32 *ret; |
| if (locks) { | |
| return(NULL); | |
| } | |
| locks++; | |
| ret = sndstream.buffer; | ret = sndstream.buffer; |
| if (ret) { | if (ret) { |
| SNDCSEC_ENTER; | SNDCSEC_ENTER; |
| Line 223 void sound_pcmunlock(const SINT32 *hdl) | Line 231 void sound_pcmunlock(const SINT32 *hdl) |
| leng = sndstream.reserve - sndstream.remain; | leng = sndstream.reserve - sndstream.remain; |
| if (leng > 0) { | if (leng > 0) { |
| CopyMemory(sndstream.buffer, | CopyMemory(sndstream.buffer, |
| sndstream.buffer + sndstream.samples * 2, | sndstream.buffer + (sndstream.samples * 2), |
| leng * 2 * sizeof(SINT32)); | leng * 2 * sizeof(SINT32)); |
| } | } |
| sndstream.ptr = sndstream.buffer + (leng * 2); | sndstream.ptr = sndstream.buffer + (leng * 2); |
| sndstream.remain += sndstream.samples; | sndstream.remain = sndstream.samples + sndstream.reserve - leng; |
| // sndstream.remain += sndstream.samples; | |
| SNDCSEC_LEAVE; | SNDCSEC_LEAVE; |
| locks--; | |
| } | } |
| } | } |