|
|
| version 1.4, 2003/10/20 06:36:33 | version 1.5, 2003/10/21 16:27:54 |
|---|---|
| Line 22 typedef struct { | Line 22 typedef struct { |
| SINT32 *buffer; | SINT32 *buffer; |
| SINT32 *ptr; | SINT32 *ptr; |
| UINT samples; | UINT samples; |
| UINT reserve; | |
| UINT remain; | UINT remain; |
| CBTBL *cbreg; | CBTBL *cbreg; |
| CBTBL cb[STREAM_CBMAX]; | CBTBL cb[STREAM_CBMAX]; |
| Line 33 static SNDSTREAM sndstream; | Line 34 static SNDSTREAM sndstream; |
| static void streamreset(void) { | static void streamreset(void) { |
| sndstream.ptr = sndstream.buffer; | sndstream.ptr = sndstream.buffer; |
| sndstream.remain = sndstream.samples; | sndstream.remain = sndstream.samples + sndstream.reserve; |
| sndstream.cbreg = sndstream.cb; | sndstream.cbreg = sndstream.cb; |
| } | } |
| Line 61 static void streamprepare(UINT samples) | Line 62 static void streamprepare(UINT samples) |
| BOOL sound_create(UINT rate, UINT ms) { | BOOL sound_create(UINT rate, UINT ms) { |
| UINT samples; | UINT samples; |
| UINT reserve; | |
| ZeroMemory(&sndstream, sizeof(sndstream)); | ZeroMemory(&sndstream, sizeof(sndstream)); |
| switch(rate) { | switch(rate) { |
| Line 81 BOOL sound_create(UINT rate, UINT ms) { | Line 83 BOOL sound_create(UINT rate, UINT ms) { |
| soundcfg.rate = rate; | soundcfg.rate = rate; |
| sound_changeclock(); | sound_changeclock(); |
| sndstream.buffer = (SINT32 *)_MALLOC(samples * 2 * sizeof(SINT32), | #if defined(SOUNDRESERVE) |
| "stream"); | reserve = rate * SOUNDRESERVE / 1000; |
| #else | |
| reserve = 0; | |
| #endif | |
| sndstream.buffer = (SINT32 *)_MALLOC((samples + reserve) * 2 | |
| * sizeof(SINT32), "stream"); | |
| if (sndstream.buffer == NULL) { | if (sndstream.buffer == NULL) { |
| goto scre_err2; | goto scre_err2; |
| } | } |
| sndstream.samples = samples; | sndstream.samples = samples; |
| sndstream.reserve = reserve; | |
| streamreset(); | streamreset(); |
| SNDCSEC_INIT; | SNDCSEC_INIT; |
| Line 198 const SINT32 *ret; | Line 206 const SINT32 *ret; |
| ret = sndstream.buffer; | ret = sndstream.buffer; |
| if (ret) { | if (ret) { |
| SNDCSEC_ENTER; | SNDCSEC_ENTER; |
| if (sndstream.remain) { | if (sndstream.remain > sndstream.reserve) { |
| streamprepare(sndstream.remain); | streamprepare(sndstream.remain - sndstream.reserve); |
| soundcfg.lastclock = I286_CLOCK + I286_BASECLOCK - I286_REMCLOCK; | soundcfg.lastclock = I286_CLOCK + I286_BASECLOCK - I286_REMCLOCK; |
| beep_eventreset(); | beep_eventreset(); |
| } | } |
| Line 209 const SINT32 *ret; | Line 217 const SINT32 *ret; |
| void sound_pcmunlock(const SINT32 *hdl) { | void sound_pcmunlock(const SINT32 *hdl) { |
| int leng; | |
| if (hdl) { | if (hdl) { |
| sndstream.ptr = sndstream.buffer; | leng = sndstream.reserve - sndstream.remain; |
| sndstream.remain = sndstream.samples; | if (leng > 0) { |
| CopyMemory(sndstream.buffer, | |
| sndstream.buffer + sndstream.samples * 2, | |
| leng * 2 * sizeof(SINT32)); | |
| } | |
| sndstream.ptr = sndstream.buffer + (leng * 2); | |
| sndstream.remain += sndstream.samples; | |
| SNDCSEC_LEAVE; | SNDCSEC_LEAVE; |
| } | } |
| } | } |