Pulseaudio and module-echo-cancel YOCTO recipe

Hello @jbruno,

I apologize the for the delay on this topic, it has been hard to get the calling feature to work on my setup.
However, one of our domain experts got a setup to work, which includes the use of the webrtc echo cancellation configuration.

The following script was used to configure pulseaudio and the bluetooth functionality:

#!/bin/bash

# to check if PulseAudio is running
check_pulseaudio() {
    ps aux | grep -i pulseaudio | grep -v grep > /dev/null
    return $?
}

echo "Killing and unblocking bluetooth"
rfkill unblock bluetooth

sleep 1
echo "Powering bluetooth" 
bluetoothctl power on

echo "Turn on agent"
bluetoothctl agent on 

sleep 1
echo "setting default agent"
bluetoothctl default-agent 

# Check for PulseAudio processes
process_id=$(ps aux | grep -i pulseaudio | grep -v grep | awk '{print $2}')

# If a PulseAudio process is found
if [ ! -z "$process_id" ]; then
    echo "PulseAudio process found with PID: $process_id"
    
    # Kill the PulseAudio process
    kill -9 $process_id
    
    # Verify if the process is killed
    if [ $? -eq 0 ]; then
        echo "PulseAudio process killed successfully."
    else
        echo "Failed to kill the PulseAudio process."
    fi
else
    echo "No PulseAudio process found."
fi

echo "starting Pulseaudio"
pulseaudio --start

# Wait for PulseAudio process to start
while ! check_pulseaudio; do
    echo "Waiting for PulseAudio to start..."
    sleep 1
done

echo "PulseAudio is now running."


echo "Loading sink/output device"
pactl load-module module-alsa-sink device=hw:0,0

sleep 1

#echo "Setting default sink/output"
#pactl set-default-sink alsa_output.hw_0_0

echo "Loading source/input"
pactl load-module module-alsa-source device=hw:0,0

#echo "Setting default source/input"
#pactl set-default-source alsa_input.hw_0_0

echo "Loading echo cancellation module"
pactl load-module module-echo-cancel sink_name=echosink source_name=echosource \
    aec_method=webrtc aec_args="analog_gain_control=0\ digital_gain_control=1" \
    source_master=alsa_input.hw_0_0 sink_master=alsa_output.hw_0_0

echo "Setting echo cancellation as default sink and source"
pactl set-default-sink echosink
pactl set-default-source echosource



echo "Enabling SCO "
hcitool -i hci0 cmd 0x3F 0x001D 0x00

echo "Device ready to connect/pair"

Please note that this was done with the bluealsa service disabled.

Best Regards,
Bruno