AudioProvider.cpp initializing fails when using 4 channels.
TheJollyDuck opened this issue · comments
Hi,
I'm having problems with the AudioProvider.cpp
code when allChannels = true
in AudioProvider.cfg
. I'd like to utilize all 4 channels. Here is the part I've had problems with in the code:
AudioProvider::AudioProvider()
{
allChannels ? channels = 4 : channels = 2;
int brokenFirst = (theDamageConfigurationHead.audioChannelsDefect[0] ? 1 : 0) + (theDamageConfigurationHead.audioChannelsDefect[1] ? 1 : 0);
int brokenSecond = (theDamageConfigurationHead.audioChannelsDefect[2] ? 1 : 0) + (theDamageConfigurationHead.audioChannelsDefect[3] ? 1 : 0);
unsigned i;
for(i = 0; i < retries; ++i)
{
if(brokenFirst > brokenSecond)
FAIL("Cannot handle broken microphones");
if(snd_pcm_open(&handle, allChannels ? "PCH_input" : "default", SND_PCM_STREAM_CAPTURE, 0) >= 0)
break;
Thread::sleep(retryDelay);
}
ASSERT(i < retries);
// Rest of the code....
For some reason snd_pcm_open()
returns a negative value, meaning that it fails to make the connection, which I found out as ASSERT(i < retries);
fails. That leads me to ask these questions:
- What is the significance
"PCH_input"
and"default"
, and why is"default"
used for 2 channels, and the other used for 4 channels? - Are there some things I should do to avoid this issue, while being able to use all 4 channels?
I'm not sure if we have ever tried using all channels after switching to the Ubuntu-based image.
"PCH_input" and "default" were the respective "PCM handle identifiers" (ALSA nomenclature is a bit complicated) on the standard NAO6 image.
Maybe one needs to do additional things in the ALSA configuration to actually get a 4-channel audio stream (https://www.alsa-project.org/alsa-doc/alsa-lib/pcm_plugins.html#pcm_plugins_multi). I remember something like that was done in the original Ubuntu image generator script by the Nao Devils, so they may know more.
I am closing this since, although it's arguably a bug, it's not something that occurs in the default configuration of the system and is therefore out of the scope of things we fix after a release.