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
This commit is contained in:
Eric Wong 2006-07-16 16:52:06 +00:00
parent b59aa75720
commit 3c8e88b053
1 changed files with 5 additions and 2 deletions

View File

@ -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);