diff options
author | Max Kellermann <max@duempel.org> | 2009-03-08 03:55:01 +0100 |
---|---|---|
committer | Max Kellermann <max@duempel.org> | 2009-03-08 03:55:01 +0100 |
commit | 554a34fb958cfa15c00a81671a72079cae00ca5f (patch) | |
tree | d1679a457a676b1dc836c1aa8da111df109aae69 | |
parent | 27193d84026dca7dce8e864da5a703e203347cdc (diff) | |
download | mpd-554a34fb958cfa15c00a81671a72079cae00ca5f.tar.gz mpd-554a34fb958cfa15c00a81671a72079cae00ca5f.tar.xz mpd-554a34fb958cfa15c00a81671a72079cae00ca5f.zip |
alsa: better period_time default value for high sample rates
The default values for buffer_time and period_time were both capped by
the hardware limits on practically all chips. The result was a
period_time which was half as big as the buffer_time. On some chips,
this led to lots of underruns when using a high sample rate (192 kHz),
because MPD had very little time to send new samples to ALSA.
A period time which is one fourth of the buffer time turned out to be
much better. If no period_time is configured, see how much
buffer_time the hardware accepts, and try to configure one fourth of
it as period_time, instead of hard-coding the default period_time
value.
This is yet another attempt to provide a solution which is valid for
all sound chips. Using the SND_PCM_NONBLOCK flag also seemed to solve
the underruns, but put a lot more CPU load to MPD.
Diffstat (limited to '')
-rw-r--r-- | NEWS | 1 | ||||
-rw-r--r-- | src/output/alsa_plugin.c | 11 |
2 files changed, 9 insertions, 3 deletions
@@ -28,6 +28,7 @@ ver 0.15 - (200?/??/??) - mvp: check for reopen errors - mvp: fixed default device detection - pipe: new audio output plugin which runs a command + - alsa: better period_time default value for high sample rates * commands: - "playlistinfo" supports a range now - added "sticker database", command "sticker", which allows clients diff --git a/src/output/alsa_plugin.c b/src/output/alsa_plugin.c index fb748fdec..489d4f32b 100644 --- a/src/output/alsa_plugin.c +++ b/src/output/alsa_plugin.c @@ -32,7 +32,6 @@ static const char default_device[] = "default"; enum { MPD_ALSA_BUFFER_TIME_US = 500000, - MPD_ALSA_PERIOD_TIME_US = 125000, }; #define MPD_ALSA_RETRY_NR 5 @@ -118,8 +117,7 @@ alsa_configure(struct alsa_data *ad, const struct config_param *param) ad->buffer_time = config_get_block_unsigned(param, "buffer_time", MPD_ALSA_BUFFER_TIME_US); - ad->period_time = config_get_block_unsigned(param, "period_time", - MPD_ALSA_PERIOD_TIME_US); + ad->period_time = config_get_block_unsigned(param, "period_time", 0); #ifdef SND_PCM_NO_AUTO_RESAMPLE if (!config_get_block_bool(param, "auto_resample", true)) @@ -313,6 +311,13 @@ configure_hw: goto error; } + if (period_time_ro == 0 && buffer_time >= 10000) { + period_time_ro = period_time = buffer_time / 4; + + g_debug("default period_time = buffer_time/4 = %u/4 = %u", + buffer_time, period_time); + } + if (period_time_ro > 0) { period_time = period_time_ro; cmd = "snd_pcm_hw_params_set_period_time_near"; |