Commit 3c8e88b0 authored by Eric Wong's avatar Eric Wong

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
parent b59aa757
...@@ -26,7 +26,8 @@ ...@@ -26,7 +26,8 @@
#define ALSA_PCM_NEW_SW_PARAMS_API #define ALSA_PCM_NEW_SW_PARAMS_API
#define MPD_ALSA_BUFFER_TIME 500000 #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 "../conf.h"
#include "../log.h" #include "../log.h"
...@@ -211,7 +212,9 @@ static int alsa_openDevice(AudioOutput * audioOutput) ...@@ -211,7 +212,9 @@ static int alsa_openDevice(AudioOutput * audioOutput)
err = snd_pcm_hw_params_set_buffer_time_near(ad->pcmHandle, hwparams, err = snd_pcm_hw_params_set_buffer_time_near(ad->pcmHandle, hwparams,
&alsa_buffer_time, 0); &alsa_buffer_time, 0);
if(err < 0) goto error; 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"; cmd = "snd_pcm_hw_params_set_period_time_near";
err = snd_pcm_hw_params_set_period_time_near(ad->pcmHandle, hwparams, err = snd_pcm_hw_params_set_period_time_near(ad->pcmHandle, hwparams,
&alsa_period_time, 0); &alsa_period_time, 0);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment