From 3c8e88b053e901de804a7d38f709056444155161 Mon Sep 17 00:00:00 2001 From: Eric Wong Date: Sun, 16 Jul 2006 16:52:06 +0000 Subject: audioOutput_alsa: calculate period size from sample rate ... instead of hard-coding it to a ridiculously high value that makes bandwidth-starved devices unhappy. libao (in SVN) does the same thing, and this calculation was indeed taken from it. Low-bandwidth USB (1.1) sound devices seem to need this to prevent underrun / broken pipe errors (during hw setup, no less) from being triggered. git-svn-id: https://svn.musicpd.org/mpd/trunk@4362 09075e82-0dd4-0310-85a5-a0d7c8717e4f --- src/audioOutputs/audioOutput_alsa.c | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) (limited to 'src/audioOutputs/audioOutput_alsa.c') diff --git a/src/audioOutputs/audioOutput_alsa.c b/src/audioOutputs/audioOutput_alsa.c index 976b72d31..0842b9f83 100644 --- a/src/audioOutputs/audioOutput_alsa.c +++ b/src/audioOutputs/audioOutput_alsa.c @@ -26,7 +26,8 @@ #define ALSA_PCM_NEW_SW_PARAMS_API #define MPD_ALSA_BUFFER_TIME 500000 -#define MPD_ALSA_PERIOD_TIME 50000 +#define MPD_ALSA_PERIOD_TIME 0 +#define MPD_ALSA_SAMPLE_XFER 256 #include "../conf.h" #include "../log.h" @@ -211,7 +212,9 @@ static int alsa_openDevice(AudioOutput * audioOutput) err = snd_pcm_hw_params_set_buffer_time_near(ad->pcmHandle, hwparams, &alsa_buffer_time, 0); if(err < 0) goto error; - + + if (!alsa_period_time && sampleRate > 0) + alsa_period_time = 1000000 * MPD_ALSA_SAMPLE_XFER / sampleRate; cmd = "snd_pcm_hw_params_set_period_time_near"; err = snd_pcm_hw_params_set_period_time_near(ad->pcmHandle, hwparams, &alsa_period_time, 0); -- cgit v1.2.3