From 983a7cfdccceaa612267a1b045110b4f831d1495 Mon Sep 17 00:00:00 2001 From: notaz Date: Wed, 5 Oct 2011 02:11:18 +0300 Subject: 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. --- plugins/dfsound/xa.c | 28 ++++++++++++++++++---------- 1 file changed, 18 insertions(+), 10 deletions(-) (limited to 'plugins/dfsound/xa.c') 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(space0) { 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 -- cgit v1.2.3