diff options
author | Warren Dukes <warren.dukes@gmail.com> | 2005-03-05 05:45:39 +0000 |
---|---|---|
committer | Warren Dukes <warren.dukes@gmail.com> | 2005-03-05 05:45:39 +0000 |
commit | 7f183f687b2e4757898edb724bfb6f2eedd06d9c (patch) | |
tree | 26795df86d4eebf3caf62fa9d85bfe6dc935c399 /src/audioOutputs | |
parent | d1a4bb382f7d3445cea74813e8258798852a40ad (diff) | |
download | mpd-7f183f687b2e4757898edb724bfb6f2eedd06d9c.tar.gz mpd-7f183f687b2e4757898edb724bfb6f2eedd06d9c.tar.xz mpd-7f183f687b2e4757898edb724bfb6f2eedd06d9c.zip |
now alsa plugin should work
git-svn-id: https://svn.musicpd.org/mpd/trunk@3009 09075e82-0dd4-0310-85a5-a0d7c8717e4f
Diffstat (limited to 'src/audioOutputs')
-rw-r--r-- | src/audioOutputs/audioOutput_alsa.c | 20 |
1 files changed, 13 insertions, 7 deletions
diff --git a/src/audioOutputs/audioOutput_alsa.c b/src/audioOutputs/audioOutput_alsa.c index 63217e9fe..97dad496b 100644 --- a/src/audioOutputs/audioOutput_alsa.c +++ b/src/audioOutputs/audioOutput_alsa.c @@ -46,6 +46,7 @@ typedef struct _AlsaData { snd_pcm_t * pcm_handle; int mmap; alsa_writei_t * writei; + int sampleSize; } AlsaData; static AlsaData * newAlsaData() { @@ -122,10 +123,10 @@ static int alsa_openDevice(AudioOutput * audioOutput) goto error; } - err = snd_pcm_nonblock(ad->pcm_handle, 0); - if(err < 0) goto error; + /*err = snd_pcm_nonblock(ad->pcm_handle, 0); + if(err < 0) goto error;*/ - // configure HW params + /* configure HW params */ snd_pcm_hw_params_alloca(&hwparams); err = snd_pcm_hw_params_any(ad->pcm_handle, hwparams); @@ -148,7 +149,7 @@ static int alsa_openDevice(AudioOutput * audioOutput) err = snd_pcm_hw_params_set_access(ad->pcm_handle, hwparams, SND_PCM_ACCESS_RW_INTERLEAVED); if(err < 0) goto error; - ad->writei = snd_pcm_mmap_writei; + ad->writei = snd_pcm_writei; } err = snd_pcm_hw_params_set_format(ad->pcm_handle, hwparams, bitformat); @@ -160,7 +161,7 @@ static int alsa_openDevice(AudioOutput * audioOutput) } err = snd_pcm_hw_params_set_channels(ad->pcm_handle, hwparams, - (unsigned int)audioFormat->channels); + audioFormat->channels); if(err < 0) { ERROR("Alsa device \"%s\" does not support %i channels: " "%s\n", ad->device, (int)audioFormat->channels, @@ -193,7 +194,7 @@ static int alsa_openDevice(AudioOutput * audioOutput) err = snd_pcm_hw_params_get_period_size(hwparams, &alsa_period_size, 0); if(err < 0) goto error; - // configure SW params + /* configure SW params */ snd_pcm_sw_params_alloca(&swparams); snd_pcm_sw_params_current(ad->pcm_handle, swparams); @@ -204,6 +205,8 @@ static int alsa_openDevice(AudioOutput * audioOutput) err = snd_pcm_sw_params(ad->pcm_handle, swparams); if(err < 0) goto error; + ad->sampleSize = (audioFormat->bits/8)*audioFormat->channels; + audioOutput->open = 1; return 0; @@ -213,6 +216,7 @@ error: snd_strerror(-err)); fail: if(ad->pcm_handle) snd_pcm_close(ad->pcm_handle); + ad->pcm_handle = NULL; audioOutput->open = 0; return -1; } @@ -245,6 +249,8 @@ static int alsa_playAudio(AudioOutput * audioOutput, char * playChunk, AlsaData * ad = audioOutput->data; int ret; + size /= ad->sampleSize; + while (size > 0) { ret = ad->writei(ad->pcm_handle, playChunk, size); @@ -257,7 +263,7 @@ static int alsa_playAudio(AudioOutput * audioOutput, char * playChunk, alsa_closeDevice(audioOutput); return -1; } - playChunk += ret; + playChunk += ret * ad->sampleSize; size -= ret; } |