srcval = *src >> 4;
do_sample();
- for (needsamples += stepsamples; needsamples > (1<<10) && length > 0; needsamples -= (1<<10), length--) {
- *buffer++ += sample;
- if (stereo) { buffer[0] = buffer[-1]; buffer++; }
- }
+ if (buffer)
+ for (needsamples += stepsamples; needsamples > (1<<10) && length > 0; needsamples -= (1<<10), length--) {
+ *buffer++ += sample;
+ if (stereo) { buffer[0] = buffer[-1]; buffer++; }
+ }
srcval = *src & 0xf;
do_sample();
- for (needsamples += stepsamples; needsamples > (1<<10) && length > 0; needsamples -= (1<<10), length--) {
- *buffer++ += sample;
- if (stereo) { buffer[0] = buffer[-1]; buffer++; }
- }
+ if (buffer)
+ for (needsamples += stepsamples; needsamples > (1<<10) && length > 0; needsamples -= (1<<10), length--) {
+ *buffer++ += sample;
+ if (stereo) { buffer[0] = buffer[-1]; buffer++; }
+ }
// lame normalization stuff, needed due to wrong adpcm algo
sgn += (sample < 0) ? -1 : 1;
PicoPicohw.xpcm_ptr = PicoPicohw.xpcm_buffer;
end:
- if (stereo)
+ if (buffer && stereo)
// still must expand SN76496 to stereo
for (; length > 0; buffer+=2, length--)
buffer[1] = buffer[0];
\r
pprof_start(sound);\r
\r
+ // Add in parts of the PSG output not yet done\r
+ if (length-psglen > 0 && PicoIn.sndOut) {\r
+ s16 *psgbuf = PicoIn.sndOut + (psglen << stereo);\r
+ Pico.snd.psg_pos += (length-psglen) << 20;\r
+ if (PicoIn.opt & POPT_EN_PSG)\r
+ SN76496Update(psgbuf, length-psglen, stereo);\r
+ }\r
+\r
if (PicoIn.AHW & PAHW_PICO) {\r
- // XXX ugly hack, need to render sound for interrupts\r
- s16 *buf16 = PicoIn.sndOut ? PicoIn.sndOut : (s16 *)PsndBuffer;\r
- PicoPicoPCMUpdate(buf16+(offset<<stereo), length-offset, stereo);\r
+ // always need to render sound for interrupts\r
+ s16 *buf16 = PicoIn.sndOut ? PicoIn.sndOut + (offset<<stereo) : NULL;\r
+ PicoPicoPCMUpdate(buf16, length-offset, stereo);\r
return length;\r
}\r
\r
Pico.snd.dac_val2 = Pico.snd.dac_val;\r
}\r
\r
- // Add in parts of the PSG output not yet done\r
- if (length-psglen > 0 && PicoIn.sndOut) {\r
- s16 *psgbuf = PicoIn.sndOut + (psglen << stereo);\r
- Pico.snd.psg_pos += (length-psglen) << 20;\r
- if (PicoIn.opt & POPT_EN_PSG)\r
- SN76496Update(psgbuf, length-psglen, stereo);\r
- }\r
-\r
// Add in parts of the FM buffer not yet done\r
if (length-fmlen > 0 && PicoIn.sndOut) {\r
s32 *fmbuf = buf32 + ((fmlen-offset) << stereo);\r