fix for gp2x audio regression

This commit is contained in:
kub 2020-03-30 23:54:11 +02:00
parent 02138162c4
commit 84e18560bb
3 changed files with 18 additions and 17 deletions

View file

@ -1057,11 +1057,11 @@ static int ym2612_write_local(u32 a, u32 d, int is_from_z80)
break;
}
PsndDoFM(get_scanline(is_from_z80));
#ifdef __GP2X__
if (PicoIn.opt & POPT_EXT_FM)
return YM2612Write_940(a, d, get_scanline(is_from_z80));
#endif
PsndDoFM(get_scanline(is_from_z80));
return YM2612Write_(a, d);
}

View file

@ -193,8 +193,8 @@ PICO_INTERNAL void PsndDoFM(int line_to)
// Q16, number of samples since last call
len = ((line_to-1) * Pico.snd.fm_mult) - Pico.snd.fm_pos;
// don't do this too often (no more than 256 per sec)
if (len >> 16 <= PicoIn.sndRate >> 9)
// don't do this too often (about every 4th scanline)
if (len >> 16 <= PicoIn.sndRate >> 12)
return;
// update position and calculate buffer offset and length
@ -281,22 +281,22 @@ static int PsndRender(int offset, int length)
{
int *buf32;
int stereo = (PicoIn.opt & 8) >> 3;
int fmlen = ((Pico.snd.fm_pos+0x8000) >> 16) - offset;
int daclen = ((Pico.snd.dac_pos+0x80000) >> 20) - offset;
int fmlen = ((Pico.snd.fm_pos+0x8000) >> 16);
int daclen = ((Pico.snd.dac_pos+0x80000) >> 20);
offset <<= stereo;
buf32 = PsndBuffer+offset;
buf32 = PsndBuffer+(offset<<stereo);
pprof_start(sound);
if (PicoIn.AHW & PAHW_PICO) {
PicoPicoPCMUpdate(PicoIn.sndOut+offset, length, stereo);
PicoPicoPCMUpdate(PicoIn.sndOut+(offset<<stereo), length-offset, stereo);
return length;
}
// Fill up DAC output in case of missing samples (Q16 rounding errors)
if (length-daclen > 0) {
short *dacbuf = PicoIn.sndOut + (daclen << stereo);
Pico.snd.dac_pos += (length-daclen) << 20;
for (; length-daclen > 0; daclen++) {
*dacbuf++ += Pico.snd.dac_val;
if (stereo) dacbuf++;
@ -305,14 +305,15 @@ static int PsndRender(int offset, int length)
// Add in parts of the FM buffer not yet done
if (length-fmlen > 0) {
int *fmbuf = buf32 + (fmlen << stereo);
int *fmbuf = buf32 + ((fmlen-offset) << stereo);
Pico.snd.fm_pos += (length-fmlen) << 16;
if (PicoIn.opt & POPT_EN_FM)
YM2612UpdateOne(fmbuf, length-fmlen, stereo, 1);
}
// CD: PCM sound
if (PicoIn.AHW & PAHW_MCD) {
pcd_pcm_update(buf32, length, stereo);
pcd_pcm_update(buf32, length-offset, stereo);
}
// CD: CDDA audio
@ -323,16 +324,16 @@ static int PsndRender(int offset, int length)
{
// note: only 44, 22 and 11 kHz supported, with forced stereo
if (Pico_mcd->cdda_type == CT_MP3)
mp3_update(buf32, length, stereo);
mp3_update(buf32, length-offset, stereo);
else
cdda_raw_update(buf32, length);
cdda_raw_update(buf32, length-offset);
}
if ((PicoIn.AHW & PAHW_32X) && (PicoIn.opt & POPT_EN_PWM))
p32x_pwm_update(buf32, length, stereo);
p32x_pwm_update(buf32, length-offset, stereo);
// convert + limit to normal 16bit output
PsndMix_32_to_16l(PicoIn.sndOut+offset, buf32, length);
PsndMix_32_to_16l(PicoIn.sndOut+(offset<<stereo), buf32, length-offset);
pprof_end(sound);