From: notaz Date: Mon, 25 Mar 2024 21:26:10 +0000 (+0200) Subject: spu: don't leave garbage in capture buffers X-Git-Url: https://notaz.gp2x.de/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=67c020eeafd6d3db7f9d2c314a77990177a1c4ff;p=pcsx_rearmed.git spu: don't leave garbage in capture buffers --- diff --git a/plugins/dfsound/externals.h b/plugins/dfsound/externals.h index ac0960f6..8e479c53 100644 --- a/plugins/dfsound/externals.h +++ b/plugins/dfsound/externals.h @@ -214,6 +214,7 @@ typedef struct int iLeftXAVol; int iRightXAVol; + int cdClearSamples; // extra samples to clear the capture buffers struct { // channel volume in the cd controller unsigned char ll, lr, rl, rr; // see cdr.Attenuator* in cdrom.c } cdv; // applied on spu side for easier emulation diff --git a/plugins/dfsound/freeze.c b/plugins/dfsound/freeze.c index bddf0ada..36b89959 100644 --- a/plugins/dfsound/freeze.c +++ b/plugins/dfsound/freeze.c @@ -338,6 +338,7 @@ long CALLBACK SPUfreeze(unsigned int ulFreezeMode, SPUFreeze_t * pF, spu.XAPlay = spu.XAFeed = spu.XAStart; spu.CDDAPlay = spu.CDDAFeed = spu.CDDAStart; + spu.cdClearSamples = 512; if (pFO && pFO->xa_left && pF->xaS.nsamples) { // start xa again FeedXA(&pF->xaS); spu.XAPlay = spu.XAFeed - pFO->xa_left; diff --git a/plugins/dfsound/spu.c b/plugins/dfsound/spu.c index 022a1e3d..ed5b4b5c 100644 --- a/plugins/dfsound/spu.c +++ b/plugins/dfsound/spu.c @@ -1389,6 +1389,7 @@ void CALLBACK SPUplayADPCMchannel(xa_decode_t *xap, unsigned int cycle, int is_s FeedXA(xap); // call main XA feeder spu.xapGlobal = xap; // store info for save states + spu.cdClearSamples = 512; } // CDDA AUDIO @@ -1401,6 +1402,7 @@ int CALLBACK SPUplayCDDAchannel(short *pcm, int nbytes, unsigned int cycle, int do_samples(cycle, 1); // catch up to prevent source underflows later FeedCDDA((unsigned char *)pcm, nbytes); + spu.cdClearSamples = 512; return 0; } diff --git a/plugins/dfsound/xa.c b/plugins/dfsound/xa.c index 6b5433fb..380d1388 100644 --- a/plugins/dfsound/xa.c +++ b/plugins/dfsound/xa.c @@ -152,8 +152,16 @@ INLINE void MixCD(int *SSumLR, int *RVB, int ns_to, int decode_pos) } spu.XALastVal = v; } - else + else if (spu.cdClearSamples > 0) + { + for(ns = 0; ns < ns_to; ns++) + { + spu.spuMem[cursor] = spu.spuMem[cursor + 0x400/2] = 0; + cursor = (cursor + 1) & 0x1ff; + } + spu.cdClearSamples -= ns_to; spu.XALastVal = 0; + } } ////////////////////////////////////////////////////////////////////////