Re: Invalid argument when setting periods, buffer, rate

Kai Vehmanen <[email protected]>
Newsgroups gmane.linux.alsa.user
Organization Intel Finland Oy - BIC 0357606-4 - Westendinkatu 7 02160 Espoo
Message-ID <[email protected]>
Hey,

On Wed, 24 Jun 2020, Sleep wrote:

> Why does the program below issue errors for
> snd_pcm_hw_params_set_period_size(), snd_pcm_hw_params_set_buffer_size(), and
> snd_pcm_hw_params_set_rate()? If I raise the value of SAMPLES to 768 it only

I highly recommend to review well known clients like aplay.c in alsa-utils 
for reference. 

E.g. here, it's not guaranteed all hardware drivers support all period 
sizes. Typically you either use the ALSA plugin layer and not access hw 
devices directly, and/or use the "_near" variants like aplay does:

aplay.c:
	if (period_time > 0)
		err = snd_pcm_hw_params_set_period_time_near(handle, params,
							     &period_time, 
							     0);

... with _near(), you of course need to handle the case where the value 
set doesn't exactly match what you requested.

Br, Kai
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.