|
|
| version 1.15, 2004/03/24 06:07:57 | version 1.16, 2004/03/26 05:51:40 |
|---|---|
| Line 99 static void streamfilewrite(UINT samples | Line 99 static void streamfilewrite(UINT samples |
| UINT count; | UINT count; |
| SINT32 buf32[2*512]; | SINT32 buf32[2*512]; |
| BYTE buf[2*2*512]; | BYTE buf[2*2*512]; |
| UINT r; | |
| UINT i; | UINT i; |
| SINT32 samp; | SINT32 samp; |
| Line 110 static void streamfilewrite(UINT samples | Line 111 static void streamfilewrite(UINT samples |
| cb->cbfn(cb->hdl, buf32, count); | cb->cbfn(cb->hdl, buf32, count); |
| cb++; | cb++; |
| } | } |
| r = min(sndstream.remain, count); | |
| if (r) { | |
| CopyMemory(sndstream.ptr, buf32, r * 2 * sizeof(SINT32)); | |
| sndstream.ptr += r * 2; | |
| sndstream.remain -= r; | |
| } | |
| for (i=0; i<count*2; i++) { | for (i=0; i<count*2; i++) { |
| samp = buf32[i]; | samp = buf32[i]; |
| if (samp > 32767) { | if (samp > 32767) { |
| Line 126 static void streamfilewrite(UINT samples | Line 133 static void streamfilewrite(UINT samples |
| samples -= count; | samples -= count; |
| } | } |
| } | } |
| static void filltailsample(UINT count) { | |
| SINT32 *ptr; | |
| UINT orgsize; | |
| SINT32 sampl; | |
| SINT32 sampr; | |
| count = min(sndstream.remain, count); | |
| if (count) { | |
| ptr = sndstream.ptr; | |
| orgsize = (ptr - sndstream.buffer) / 2; | |
| if (orgsize == 0) { | |
| sampl = 0; | |
| sampr = 0; | |
| } | |
| else { | |
| sampl = *(ptr - 2); | |
| sampr = *(ptr - 1); | |
| } | |
| sndstream.ptr += count * 2; | |
| sndstream.remain -= count; | |
| do { | |
| ptr[0] = sampl; | |
| ptr[1] = sampr; | |
| ptr += 2; | |
| } while(--count); | |
| } | |
| } | |
| #endif | #endif |
| Line 261 void sound_sync(void) { | Line 297 void sound_sync(void) { |
| if (length == 0) { | if (length == 0) { |
| return; | return; |
| } | } |
| SNDCSEC_ENTER; | |
| #if defined(SUPPORT_WAVEREC) | #if defined(SUPPORT_WAVEREC) |
| if (sndstream.rec) { | if (sndstream.rec) { |
| streamfilewrite(length); | streamfilewrite(length); |
| soundcfg.lastclock += length * soundcfg.clockbase / soundcfg.hzbase; | |
| beep_eventreset(); | |
| return; | |
| } | } |
| else | |
| #endif | #endif |
| SNDCSEC_ENTER; | |
| streamprepare(length); | streamprepare(length); |
| soundcfg.lastclock += length * soundcfg.clockbase / soundcfg.hzbase; | soundcfg.lastclock += length * soundcfg.clockbase / soundcfg.hzbase; |
| beep_eventreset(); | beep_eventreset(); |
| Line 288 const SINT32 *sound_pcmlock(void) { | Line 322 const SINT32 *sound_pcmlock(void) { |
| const SINT32 *ret; | const SINT32 *ret; |
| #if defined(SUPPORT_WAVEREC) | |
| if (sndstream.rec) { | |
| return(NULL); | |
| } | |
| #endif | |
| if (locks) { | if (locks) { |
| TRACEOUT(("sound pcm lock: already locked")); | TRACEOUT(("sound pcm lock: already locked")); |
| return(NULL); | return(NULL); |
| Line 301 const SINT32 *ret; | Line 330 const SINT32 *ret; |
| ret = sndstream.buffer; | ret = sndstream.buffer; |
| if (ret) { | if (ret) { |
| SNDCSEC_ENTER; | SNDCSEC_ENTER; |
| if (sndstream.remain > sndstream.reserve) { | if (sndstream.remain > sndstream.reserve) |
| #if defined(SUPPORT_WAVEREC) | |
| if (sndstream.rec) { | |
| filltailsample(sndstream.remain - sndstream.reserve); | |
| } | |
| else | |
| #endif | |
| { | |
| streamprepare(sndstream.remain - sndstream.reserve); | streamprepare(sndstream.remain - sndstream.reserve); |
| soundcfg.lastclock = CPU_CLOCK + CPU_BASECLOCK - CPU_REMCLOCK; | soundcfg.lastclock = CPU_CLOCK + CPU_BASECLOCK - CPU_REMCLOCK; |
| beep_eventreset(); | beep_eventreset(); |