[alsa-devel] Problem with setting period time and buffer time.
Hello.
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). 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). The same situation take place when I try to set buffer time for something about 1000us (so one period could fit in my buffer).
The purpose of this program is to generate sine wave for AFSK (audio frequency-shift keying). I want to play wave for period_time (834us) then if needed change frequency and play changed wave again for period_time with phase shifting.
Wave generation with phase shifting for variable frequencies works, but not with period_time I need.
Could anyone look at source and tell me why I can't set this values?
I placed code with syntax highlighting at: http://pygments.org/demo/606/ . (Don't look at prepare_message function, it isn't used right now).
Thanks from advice.
Ignacy.
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
participants (2)
-
Clemens Ladisch
-
Ignacy Kasperowicz