ALSA: Relation between period size of speaker and mic
Asked Answered
M

1

6

I have audio conferencing device which has a mic and speaker. Both mic and speaker having same sampling rate set by snd_pcm_hw_params_set_rate_near() say 8000 Hz. Do I need to set period size and number of periods to be same for both (for two such devices communicate each other) ?

Or can I choose a different period/period size for speaker than the one configured for mic ? How do I decide on which period and period size to use ?

I am using snd_pcm_hw_params_set_period_size_near() and snd_pcm_hw_params_set_periods_near() APIs to set period size and period for both speaker and mic.

(I am new to ALSA).

Mandeville answered 5/4, 2013 at 13:53 Comment(0)
B
5

What period sized and buffer sizes are supported depends on the driver, but if it's the same device, it's likely that the playback and capture devices support the same parameters.

Whether the parameters need to be the same depends on how your application accesses these devices. As far as the driver is concerned, these devices work independently.

What buffer/period sizes to use depends on how you want to balance latency, power usage, and over/underrun safety. Latency is directly proportional with the buffer size on playback devices or the period siz on capture devices. Power usage is increased slightly by shorter periods. Xrun safety is increased by larger buffers, and a little by shorter periods.

Bucky answered 6/4, 2013 at 7:58 Comment(1)
How do you determine what buffer/period size your device supports? Is there not a general programmatic way to setup alsa period/buffer size that will work with any driver?Optician

© 2022 - 2024 — McMap. All rights reserved.