diff options
Diffstat (limited to 'plugins/dfsound/alsa.c')
| -rw-r--r-- | plugins/dfsound/alsa.c | 130 |
1 files changed, 1 insertions, 129 deletions
diff --git a/plugins/dfsound/alsa.c b/plugins/dfsound/alsa.c index 90ce26b8..67b10396 100644 --- a/plugins/dfsound/alsa.c +++ b/plugins/dfsound/alsa.c @@ -30,86 +30,6 @@ static snd_pcm_t *handle = NULL; static snd_pcm_uframes_t buffer_size; -static snd_pcm_t *handle_cdda = NULL; - -// SETUP CDDA SOUND -void SetupCDDASound(void) -{ - snd_pcm_hw_params_t *hwparams; - unsigned int pspeed; - int pchannels = 2; - int format; - unsigned int buffer_time = 500000; - unsigned int period_time = buffer_time / 4; - int err; - - pspeed = 44100; - format = SND_PCM_FORMAT_S16_LE; - - if ((err = snd_pcm_open(&handle_cdda, "default", - SND_PCM_STREAM_PLAYBACK, SND_PCM_NONBLOCK)) < 0) - { - printf("Audio open error: %s\n", snd_strerror(err)); - return; - } - - if((err = snd_pcm_nonblock(handle_cdda, 0))<0) - { - printf("Can't set blocking moded: %s\n", snd_strerror(err)); - return; - } - - snd_pcm_hw_params_alloca(&hwparams); - - if((err=snd_pcm_hw_params_any(handle_cdda, hwparams))<0) - { - printf("Broken configuration for this PCM: %s\n", snd_strerror(err)); - return; - } - - if((err=snd_pcm_hw_params_set_access(handle_cdda, hwparams, SND_PCM_ACCESS_RW_INTERLEAVED))<0) - { - printf("Access type not available: %s\n", snd_strerror(err)); - return; - } - - if((err=snd_pcm_hw_params_set_format(handle_cdda, hwparams, format))<0) - { - printf("Sample format not available: %s\n", snd_strerror(err)); - return; - } - - if((err=snd_pcm_hw_params_set_channels(handle_cdda, hwparams, pchannels))<0) - { - printf("Channels count not available: %s\n", snd_strerror(err)); - return; - } - - if((err=snd_pcm_hw_params_set_rate_near(handle_cdda, hwparams, &pspeed, 0))<0) - { - printf("Rate not available: %s\n", snd_strerror(err)); - return; - } - - if((err=snd_pcm_hw_params_set_buffer_time_near(handle_cdda, hwparams, &buffer_time, 0))<0) - { - printf("Buffer time error: %s\n", snd_strerror(err)); - return; - } - - if((err=snd_pcm_hw_params_set_period_time_near(handle_cdda, hwparams, &period_time, 0))<0) - { - printf("Period time error: %s\n", snd_strerror(err)); - return; - } - - if((err=snd_pcm_hw_params(handle_cdda, hwparams))<0) - { - printf("Unable to install hw params: %s\n", snd_strerror(err)); - return; - } -} - // SETUP SOUND void SetupSound(void) { @@ -118,7 +38,7 @@ void SetupSound(void) unsigned int pspeed; int pchannels; int format; - unsigned int buffer_time = 50000; + unsigned int buffer_time = 100000; unsigned int period_time = buffer_time / 4; int err; @@ -199,8 +119,6 @@ void SetupSound(void) } buffer_size = snd_pcm_status_get_avail(status); - - SetupCDDASound(); } // REMOVE SOUND @@ -212,13 +130,6 @@ void RemoveSound(void) snd_pcm_close(handle); handle = NULL; } - - if(handle_cdda != NULL) - { - snd_pcm_drop(handle_cdda); - snd_pcm_close(handle_cdda); - handle_cdda = NULL; - } } // GET BYTES BUFFERED @@ -248,43 +159,4 @@ 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; - - while (nbytes > 0) - { - size = nbytes; - if (size > sizeof(cdda_buf)) size = sizeof(cdda_buf); - - for (i = 0; i < size / 4; i++) - { - s = (short)(p[i*4] | (p[i*4+1] << 8)); - s *= iLeftXAVol; - s /= 32767; - cdda_buf[i*4] = (s & 0xFF); - cdda_buf[i*4+1] = ((s & 0xFF00) >> 8); - - s = (short)(p[i*4+2] | (p[i*4+3] << 8)); - s *= iRightXAVol; - s /= 32767; - cdda_buf[i*4+2] = (s & 0xFF); - cdda_buf[i*4+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 |
