[alsa-devel] Warning/error from ALSA’s pcm_min.c example. Possible problem?

Louise Hoffman louise.hoffman at gmail.com
Sun Jan 31 21:53:33 CET 2010


>> The correct way is to use snd_pcm_get_params() to get buffer_size and
> period_size
>
> *snd_pcm_set_params() has limitation
>
> The most common sound card (e.g. HDA ) has the following constraints
> on period bytes and buffer bytes
>
>     snd_pcm_hw_constraint_step(runtime, 0, SNDRV_PCM_HW_PARAM_BUFFER_BYTES,
>                                    128);
>     snd_pcm_hw_constraint_step(runtime, 0, SNDRV_PCM_HW_PARAM_PERIOD_BYTES,
>                                   128);

I am probably not good enough to understand these changes =( Pretty
hard core stuff =)


> you cannot get exactly 0.5 second period time when rate is multiple of 3 (
> e.g. 48000 Hz )

Does this mean, that I shouldn't give snd_pcm_writei() the number of
all the frames in the buffer, but only

sample_rate * latency = frames

?

So if I e.g. have:
sample_rate = 44100
latency = 0.5 [s]
all_frames = 100000

The number of frames that I should give to snd_pcm_writei() would be

sample_rate * latency = frames
44100*0.5 = 22050

and the number of iterations the for-loop should be?:

(int) 100000/22050 = 4; with frames=22050

and one extra, but only with

100000 mod 22050 = 11800

frames?


More information about the Alsa-devel mailing list