[alsa-devel] Problem with setting period time and buffer time.

Clemens Ladisch clemens at ladisch.de
Tue Feb 19 09:17:15 CET 2008


Ignacy Kasperowicz wrote:
> I need to set proper period time for my application. What I need my
> code to do is to play sine wave with set frequency and for exact time
> of 1/1200 s (something about 834 us).

The period time specifies after which interval the sound hardware issues
an interrupt, i.e., after which time your application gets waken up when
it is waiting for the sound buffer to become non-empty.  This has
nothing to do with the actual sounds that are being played.

You are not required to write data in period-sized chunks, so you don't
actually need to care about the period time.

> When I try to set period time for 834 us I've got this error:
> Unable to set period time 834 for playback: Invalid argument .
> Honestly speaking  I've got this error message no matter what value I
> try to set).

Period (and buffer) times are hardware dependent; you cannot be sure
that any specific value is supported by the sound card.

(And you're calling snd_pcm_hw_params_set_period_time_max() which would
allow the driver to choose any lower value.)


HTH
Clemens


More information about the Alsa-devel mailing list