diff options
| author | SND\weimingzhi_cp <SND\weimingzhi_cp@e17a0e51-4ae3-4d35-97c3-1a29b211df97> | 2009-09-05 14:39:49 +0000 |
|---|---|---|
| committer | SND\weimingzhi_cp <SND\weimingzhi_cp@e17a0e51-4ae3-4d35-97c3-1a29b211df97> | 2009-09-05 14:39:49 +0000 |
| commit | 6af1c66b497435c9cb864020472e993bea548113 (patch) | |
| tree | a90f4ec92d9d34b7c2318102f80766bee1e52a12 /plugins | |
| parent | c921551cc28ad78a06e5be832123be5ede8d6a41 (diff) | |
| download | pcsxr-6af1c66b497435c9cb864020472e993bea548113.tar.gz | |
git-svn-id: https://pcsxr.svn.codeplex.com/svn/pcsxr@29035 e17a0e51-4ae3-4d35-97c3-1a29b211df97
Diffstat (limited to 'plugins')
| -rw-r--r-- | plugins/dfsound/alsa.c | 35 |
1 files changed, 32 insertions, 3 deletions
diff --git a/plugins/dfsound/alsa.c b/plugins/dfsound/alsa.c index 2a291f6a..e1fe46f6 100644 --- a/plugins/dfsound/alsa.c +++ b/plugins/dfsound/alsa.c @@ -248,14 +248,43 @@ void SoundFeedStreamData(unsigned char* pSound,long lBytes) iDisStereo ? lBytes / 2 : lBytes / 4); } +static unsigned char cdda_buf[23520]; + // PLAY CDDA CHANNEL void CALLBACK SPUplayCDDAchannel(short* pcm, int nbytes) { + int i, size, s; + unsigned char *p = (unsigned char *)pcm; + if (handle_cdda == NULL) return; - if (snd_pcm_state(handle_cdda) == SND_PCM_STATE_XRUN) - snd_pcm_prepare(handle_cdda); - snd_pcm_writei(handle_cdda, (unsigned char *)pcm, nbytes / 4); + while (nbytes > 0) + { + size = nbytes; + if (size > sizeof(cdda_buf)) size = sizeof(cdda_buf); + + for (i = 0; i < size / 4; i++) + { + s = p[i*2] | (p[i*2+1] << 8); + s *= iLeftXAVol; + s /= 32767; + cdda_buf[i*2] = (s & 0xFF); + cdda_buf[i*2+1] = ((s & 0xFF00) >> 8); + + s = p[i*2+2] | (p[i*2+3] << 8); + s *= iRightXAVol; + s /= 32767; + cdda_buf[i*2+2] = (s & 0xFF); + cdda_buf[i*2+3] = ((s & 0xFF00) >> 8); + } + + if (snd_pcm_state(handle_cdda) == SND_PCM_STATE_XRUN) + snd_pcm_prepare(handle_cdda); + snd_pcm_writei(handle_cdda, cdda_buf, size / 4); + + nbytes -= size; + p += size; + } } #endif |
