26 May
2009
26 May
'09
10:15 a.m.
At Mon, 25 May 2009 15:12:17 +0200, Canella Matteo wrote:
Hi everybody, I'm writing a little software that play a tone on a pcm device. In the hw param initialization I'm hardcoding the "periods" and "period_size" values:
unsigned int periods = 4; if (snd_pcm_hw_params_set_periods_near(buzzer_device.pcm_handle, buzzer_device.hwparams, &periods, 0) < 0) { fprintf(stderr, "Error setting periods.\n"); return 1; } ///* set the period time */ period_size = 8192; err = snd_pcm_hw_params_set_period_size_near(buzzer_device.pcm_handle, buzzer_device.hwparams, &period_size, 0); if (err < 0) { printf("Unable to get period size for playback: %s\n", snd_strerror(err)); return err; }
I'd like to read this parameter form the .asoundrc file, so I'm wondering if there were API that does this task.
You can call snd_config_search() with snd_config as root config. For example,
snd_config_t *n; long val; if (snd_config_search(snd_config, "YOUR.CONFIG", &n) < 0) error(); if (snd_config_get_integer(n, &val) < 0) error();
Takashi