diff options
author | notaz | 2011-10-05 02:11:18 +0300 |
---|---|---|
committer | notaz | 2011-10-08 03:29:24 +0300 |
commit | 983a7cfdccceaa612267a1b045110b4f831d1495 (patch) | |
tree | 9db370d4f7a553f078d8ab4793324ca220a90bc5 /plugins/dfsound | |
parent | 4600ba0381ea86bdfdcba8f4f762c89f5c51af5b (diff) | |
download | pcsx_rearmed-983a7cfdccceaa612267a1b045110b4f831d1495.tar.gz pcsx_rearmed-983a7cfdccceaa612267a1b045110b4f831d1495.tar.bz2 pcsx_rearmed-983a7cfdccceaa612267a1b045110b4f831d1495.zip |
spu/cdda: sync cdda to spu playback
this will probably make cdrom/vsync timing desync situation
worse (those were never in sync anyway) but fix some cdda
related sound stuttering.
Those magic values are used trying to preserve other SPU plugin
compatibility.
Diffstat (limited to 'plugins/dfsound')
-rw-r--r-- | plugins/dfsound/spu.c | 12 | ||||
-rw-r--r-- | plugins/dfsound/spu.h | 2 | ||||
-rw-r--r-- | plugins/dfsound/xa.c | 28 | ||||
-rw-r--r-- | plugins/dfsound/xa.h | 2 |
4 files changed, 27 insertions, 17 deletions
diff --git a/plugins/dfsound/spu.c b/plugins/dfsound/spu.c index f84ef77..b3bd057 100644 --- a/plugins/dfsound/spu.c +++ b/plugins/dfsound/spu.c @@ -132,6 +132,8 @@ int lastch=-1; // last channel processed on spu irq in timer mode static int lastns=0; // last ns pos static int iSecureStart=0; // secure start counter +#define CDDA_BUFFER_SIZE (16384 * sizeof(uint32_t)) // must be power of 2 + //////////////////////////////////////////////////////////////////////// // CODE AREA //////////////////////////////////////////////////////////////////////// @@ -948,12 +950,12 @@ void CALLBACK SPUplayADPCMchannel(xa_decode_t *xap) } // CDDA AUDIO -void CALLBACK SPUplayCDDAchannel(short *pcm, int nbytes) +int CALLBACK SPUplayCDDAchannel(short *pcm, int nbytes) { - if (!pcm) return; - if (nbytes<=0) return; + if (!pcm) return -1; + if (nbytes<=0) return -1; - FeedCDDA((unsigned char *)pcm, nbytes); + return FeedCDDA((unsigned char *)pcm, nbytes); } // SETUPTIMER: init of certain buffers and threads/timers @@ -1011,7 +1013,7 @@ void SetupStreams(void) XAFeed = XAStart; CDDAStart = // alloc cdda buffer - (uint32_t *)malloc(16384 * sizeof(uint32_t)); + (uint32_t *)malloc(CDDA_BUFFER_SIZE); CDDAEnd = CDDAStart + 16384; CDDAPlay = CDDAStart; CDDAFeed = CDDAStart; diff --git a/plugins/dfsound/spu.h b/plugins/dfsound/spu.h index 8912684..048f643 100644 --- a/plugins/dfsound/spu.h +++ b/plugins/dfsound/spu.h @@ -18,4 +18,4 @@ void SetupTimer(void);
void RemoveTimer(void);
void CALLBACK SPUplayADPCMchannel(xa_decode_t *xap);
-void CALLBACK SPUplayCDDAchannel(short *pcm, int bytes);
\ No newline at end of file +int CALLBACK SPUplayCDDAchannel(short *pcm, int bytes);
diff --git a/plugins/dfsound/xa.c b/plugins/dfsound/xa.c index b45aef2..b1efe10 100644 --- a/plugins/dfsound/xa.c +++ b/plugins/dfsound/xa.c @@ -389,21 +389,29 @@ INLINE void FeedXA(xa_decode_t *xap) // FEED CDDA //////////////////////////////////////////////////////////////////////// -INLINE void FeedCDDA(unsigned char *pcm, int nBytes) +INLINE int FeedCDDA(unsigned char *pcm, int nBytes) { + int space; + space=(CDDAPlay-CDDAFeed-1)*4 & (CDDA_BUFFER_SIZE - 1); + if(space<nBytes) + return 0x7761; // rearmed_wait + while(nBytes>0) { if(CDDAFeed==CDDAEnd) CDDAFeed=CDDAStart; - while(CDDAFeed==CDDAPlay-1|| - (CDDAFeed==CDDAEnd-1&&CDDAPlay==CDDAStart)) - { - if (!iUseTimer) usleep(1000); - else return; - } - *CDDAFeed++=(*pcm | (*(pcm+1)<<8) | (*(pcm+2)<<16) | (*(pcm+3)<<24)); - nBytes-=4; - pcm+=4; + space=(CDDAPlay-CDDAFeed-1)*4 & (CDDA_BUFFER_SIZE - 1); + if(CDDAFeed+space/4>CDDAEnd) + space=(CDDAEnd-CDDAFeed)*4; + if(space>nBytes) + space=nBytes; + + memcpy(CDDAFeed,pcm,space); + CDDAFeed+=space/4; + nBytes-=space; + pcm+=space; } + + return 0x676f; // rearmed_go } #endif diff --git a/plugins/dfsound/xa.h b/plugins/dfsound/xa.h index 0928eba..cbf2843 100644 --- a/plugins/dfsound/xa.h +++ b/plugins/dfsound/xa.h @@ -17,4 +17,4 @@ INLINE void MixXA(void);
INLINE void FeedXA(xa_decode_t *xap);
-INLINE void FeedCDDA(unsigned char *pcm, int nBytes); +INLINE int FeedCDDA(unsigned char *pcm, int nBytes); |