aboutsummaryrefslogtreecommitdiffstats
path: root/src/audioOutputs
diff options
context:
space:
mode:
authorEric Wong <normalperson@yhbt.net>2006-07-16 16:52:06 +0000
committerEric Wong <normalperson@yhbt.net>2006-07-16 16:52:06 +0000
commit3c8e88b053e901de804a7d38f709056444155161 (patch)
tree89399b629b5e0dd6d76239fec764997d4716a7f8 /src/audioOutputs
parentb59aa757205b2dc330d7864d88381c67beefb254 (diff)
downloadmpd-3c8e88b053e901de804a7d38f709056444155161.tar.gz
mpd-3c8e88b053e901de804a7d38f709056444155161.tar.xz
mpd-3c8e88b053e901de804a7d38f709056444155161.zip
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
Diffstat (limited to '')
-rw-r--r--src/audioOutputs/audioOutput_alsa.c7
1 files changed, 5 insertions, 2 deletions
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);