defaults.pcm.device 0
defaults.pcm.subdevice -1
defaults.pcm.nonblock 1
+defaults.pcm.minperiodtime 5000 # in us
defaults.pcm.ipc_key 5678293
defaults.pcm.ipc_gid audio
defaults.pcm.ipc_perm 0660
const char *str;
char *buf = NULL, *buf1 = NULL;
int err;
- snd_config_t *conf, *type_conf = NULL;
+ snd_config_t *conf, *type_conf = NULL, *tmp;
snd_config_iterator_t i, next;
const char *id;
const char *lib = NULL, *open_name = NULL;
snd_dlclose(h);
}
}
+ if (err >= 0) {
+ err = snd_config_search(pcm_root, "defaults.pcm.minperiodtime", &tmp);
+ if (err >= 0)
+ snd_config_get_integer(tmp, &(*pcmp)->minperiodtime);
+ err = 0;
+ }
if (type_conf)
snd_config_delete(type_conf);
free(buf);
if (err < 0)
return err;
err = snd_pcm_hw_param_set_first(pcm, params, SND_PCM_HW_PARAM_RATE, NULL, 0);
- if (err < 0)
return err;
+ if (pcm->minperiodtime > 0) {
+ unsigned int min, max;
+ int dir = 1;
+ err = snd_pcm_hw_param_get_min(params, SND_PCM_HW_PARAM_PERIOD_TIME, &min, &dir);
+ if (err >= 0)
+ err = snd_pcm_hw_param_get_max(params, SND_PCM_HW_PARAM_PERIOD_TIME, &max, &dir);
+ if (err >= 0 && (long)min < pcm->minperiodtime &&
+ (long)max > pcm->minperiodtime) {
+ min = pcm->minperiodtime; dir = 1;
+ snd_pcm_hw_param_set_min(pcm, params, SND_CHANGE, SND_PCM_HW_PARAM_PERIOD_TIME, &min, &dir);
+ }
+ }
if (compat && *compat) {
/* old mode */
err = snd_pcm_hw_param_set_first(pcm, params, SND_PCM_HW_PARAM_PERIOD_TIME, NULL, 0);