Warm tip: This article is reproduced from stackoverflow.com, please click
audio embedded embedded-linux linux alsa

ALSA capture stream with 8 channels but opening stream as 4

发布于 2020-03-27 15:43:15

I'm writing an app for embedded device. The device is connected to an 8 mic board, so 8 channels are transferred into the board. In ALSA this device is visible as HW:3,0.

I've opened the HW:3,0 stream and with:

snd_pcm_hw_params_test_channels()

I've checked the number of allowed channels. The output was 1 - 8.

What happens, if I open the stream and set the number of channels to 4? Does ALSA drops the rest of 4 channels and I get a buffer of CH1 | CH2 | CH3 | CH4 samples or I get CH1 | ... | CH8 in a buffer?

Thank you for help, Renegade

Questioner
ST Renegade
Viewed
110
CL. 2020-01-31 19:06

The hw_params_* constraints are managed by the driver. So the driver gets told that the stream has four channels, and the driver is then responsible to configure the hardware to generate four samples per frame.