diff --git a/plugins/dfsound/externals.h b/plugins/dfsound/externals.h index ac0960f6e..8e479c531 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 bddf0adad..36b899592 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 022a1e3d3..ed5b4b5c7 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 6b5433fbd..380d1388c 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; + } } ////////////////////////////////////////////////////////////////////////