alsa: fix option parsing and restore default period_time
Two bugs here led to a large number of interrupts being generated on the sound card when ALSA output is being used. Because we specify no default period_time, the sound card gives us 3000 interrupts/sec rather than a more sane 20 or 30. This completes the revert of dd7711 already started by 4ca24f. The larger bug was in the change to config_get_block_unsigned() and using 0 as the default value for both 'buffer_time' and 'period_time'. This means any pre-setting of these options in newAlsaData() gets wiped out. Add a new default for period_time, and ensure default values for buffer_time and period_time are used if none are provided by the user. Signed-off-by: Dan McGee <dan@archlinux.org> [mk: set defaults in newAlsaData() to fix auto-configuration; renamed "_MS" back to "_US" because ALSA expects microseconds, not milliseconds] Signed-off-by: Max Kellermann <max@duempel.org>
This commit is contained in:
parent
16796b1209
commit
27baf6913e
@ -32,6 +32,7 @@ static const char default_device[] = "default";
|
|||||||
|
|
||||||
enum {
|
enum {
|
||||||
MPD_ALSA_BUFFER_TIME_US = 500000,
|
MPD_ALSA_BUFFER_TIME_US = 500000,
|
||||||
|
MPD_ALSA_PERIOD_TIME_US = 125000,
|
||||||
};
|
};
|
||||||
|
|
||||||
#define MPD_ALSA_RETRY_NR 5
|
#define MPD_ALSA_RETRY_NR 5
|
||||||
@ -72,7 +73,7 @@ static AlsaData *newAlsaData(void)
|
|||||||
ret->writei = snd_pcm_writei;
|
ret->writei = snd_pcm_writei;
|
||||||
ret->useMmap = 0;
|
ret->useMmap = 0;
|
||||||
ret->buffer_time = MPD_ALSA_BUFFER_TIME_US;
|
ret->buffer_time = MPD_ALSA_BUFFER_TIME_US;
|
||||||
ret->period_time = 0;
|
ret->period_time = MPD_ALSA_PERIOD_TIME_US;
|
||||||
|
|
||||||
//use alsa mixer by default
|
//use alsa mixer by default
|
||||||
mixer_init(&ret->mixer, &alsa_mixer);
|
mixer_init(&ret->mixer, &alsa_mixer);
|
||||||
@ -94,8 +95,10 @@ alsa_configure(AlsaData *ad, struct config_param *param)
|
|||||||
|
|
||||||
ad->useMmap = config_get_block_bool(param, "use_mmap", false);
|
ad->useMmap = config_get_block_bool(param, "use_mmap", false);
|
||||||
|
|
||||||
ad->buffer_time = config_get_block_unsigned(param, "buffer_time", 0);
|
ad->buffer_time = config_get_block_unsigned(param, "buffer_time",
|
||||||
ad->period_time = config_get_block_unsigned(param, "period_time", 0);
|
MPD_ALSA_BUFFER_TIME_US);
|
||||||
|
ad->period_time = config_get_block_unsigned(param, "period_time",
|
||||||
|
MPD_ALSA_PERIOD_TIME_US);
|
||||||
|
|
||||||
#ifdef SND_PCM_NO_AUTO_RESAMPLE
|
#ifdef SND_PCM_NO_AUTO_RESAMPLE
|
||||||
if (!config_get_block_bool(param, "auto_resample", true))
|
if (!config_get_block_bool(param, "auto_resample", true))
|
||||||
|
Loading…
Reference in New Issue
Block a user