You are not logged in.

#1 2021-10-07 06:38:53

medicineman2500
Member
Registered: 2021-10-07
Posts: 66

module-echo-cancel defaults to wrong sink/source

EDIT: I've now rebooted and the only option to show up was jack sources/sinks which I can't figure out how to route through to HDMI audio. Rebooting again without doing anything and the ATR mic disappears, rebooting again brings up the ATR usb mic. Why is this so random?

********

EDIT 2: Just discovered another problem, every time the screen goes black (which is essentially the HDMI turning off) it completely wipes the settings and I have to either reboot or if I'm lucky just restart pulseaudio

********


I am trying to get module-echo-cancel to work and I'm having an issue where it will pair with the wrong sink and source.

There are 2 sinks on my system:

1. Analog stereo (built-in speaker)
2. HDMI audio

There are 3 sources:

1. Analog stereo
2. ATR USB Mic
3. Logi USB Camera Mic

If I look in pasystray, I can see sink/source options:

Built-in Audio Digital Stereo (HDMI)
Built-in Audio Analog Stereo
Built-in Audio Analog Stereo with echo cancellation
ATR4697 USB Microphone
Built-in Audio Analog Stereo
Built-in Audio Analog Stereo with echo cancellation

There seems to be no discernible pattern to the matching with echo cancellation module to sink or source and it will seemingly match based on how it feels at that moment. Initially it was showing changes with the usb camera plugged in or out, then between reboots and manually killing pulseaudio after booting. However, no pattern has emerged after having restarted pulseaudio across a number of different configurations.

So I tried to configure manually to pair the echo module with the usb mic and the hdmi, but then the module will not load. I suspect because I am doing something wrong. Here are the options I put in manually:

load-module module-echo-cancel source_master alsa_input.usb-Conference_USB_microphone_ATR4697-USB-00.mono-fallback sink_master alsa_output.pci-0000_00_03.0.hdmi-stereo

### Make some devices default
set-default-sink alsa_output.pci-0000_00_03.0.hdmi-stereo
set-default-source alsa_input.usb-Conference_USB_microphone_ATR4697-USB-00.mono-fallback

Removing this code and just having "load-module module-echo-cancel" seems to work, but as I said: not reliably or with any kind of consistency.

Could someone shed some light on configuration here and why or how to set manually? Is it based on index default?

Last edited by medicineman2500 (2021-10-07 08:55:14)

Offline

#2 2021-10-07 10:50:24

V1del
Forum Moderator
Registered: 2012-10-16
Posts: 21,414

Re: module-echo-cancel defaults to wrong sink/source

You need to use = for assigning parameter values, so

load-module module-echo-cancel source_master=alsa_input.usb-Conference_USB_microphone_ATR4697-USB-00.mono-fallback sink_master=alsa_output.pci-0000_00_03.0.hdmi-stereo sink_name="EchoCancelled Sink" source_name="EchoCancelled Source"

set-default-sink "EchoCancelled Sink"
set-default-source "EchoCancelled Source"

As for the edits, It's random because linux/udev device detection is random (if the devices actually completely disappear, check your dmesg, often you have a wrong modprobe.d config definition which can lead to internal conflicts), which is why pulse generates predictable names that should hold by the time it reaches the loading of your echo-cancel sink. As for the second edit that is indeed a problem that's going to be a bit tricky to work around. I don't think pulse can logically reinit the echo cancel on the reappearing hdmi device (... though if you do the load properly as mentioned above that might work) in which case you'd have to define a post-suspend script which unloads/reloads the relevant echo-cancel sink when it's feasible again

Offline

#3 2021-10-07 13:35:52

medicineman2500
Member
Registered: 2021-10-07
Posts: 66

Re: module-echo-cancel defaults to wrong sink/source

V1del wrote:

You need to use = for assigning parameter values, so

load-module module-echo-cancel source_master=alsa_input.usb-Conference_USB_microphone_ATR4697-USB-00.mono-fallback sink_master=alsa_output.pci-0000_00_03.0.hdmi-stereo sink_name="EchoCancelled Sink" source_name="EchoCancelled Source"

set-default-sink "EchoCancelled Sink"
set-default-source "EchoCancelled Source"

OOPS!!! Won't make that mistake again haha

As for the edits, It's random because linux/udev device detection is random (if the devices actually completely disappear, check your dmesg, often you have a wrong modprobe.d config definition which can lead to internal conflicts), which is why pulse generates predictable names that should hold by the time it reaches the loading of your echo-cancel sink.

Re udev: ah yes of course. Hmmmmm, ok I'll have a dig and see what I can find... tbh I need to also set some outstanding udev rules regardless so this is a good excuse to stop procrastinating and just write the damned things.

As for the second edit that is indeed a problem that's going to be a bit tricky to work around. I don't think pulse can logically reinit the echo cancel on the reappearing hdmi device (... though if you do the load properly as mentioned above that might work) in which case you'd have to define a post-suspend script which unloads/reloads the relevant echo-cancel sink when it's feasible again

Here's the thing though: it's not necessarily after a suspend. My screen or hdmi output just randomly goes to sleep after a period of inactivity, which is expected on most systems but I don't recall putting that in place. A feature of i3 perhaps? Default system? If it's post system-suspend then absolutely you're a genius and why didn't I think of that... otherwise, perhaps another udev rule to detect hdmi activity?

A day of udev. Look at me go.

Offline

#4 2021-10-08 07:16:07

medicineman2500
Member
Registered: 2021-10-07
Posts: 66

Re: module-echo-cancel defaults to wrong sink/source

Ok so I've got as far as DPMS, which I didn't know about previously, and now looking at ways to detect the display state dynamically. It looks like the easiest and dirtiest solution is to simply turn DMPS off.

Turning DPMS off as a workaround is perfectly suitable for me as I lock my screen when walking away. Which means the only thing I need to worry about is running a script on wake up as mentioned above by V1del.

I am using i3lock and triggering with XF86Sleep which comes from a power button on my keyboard. Not sure how to run scripts on unlock as I can't see any kind of signal coming from i3. Anyone know?

The only thing I can find is ACPI events which can be altered according to this https://wiki.archlinux.org/title/Laptop … ake_events as for detecting I'm at a loss here.

##
EDIT: I've found a python util that interfaces with ACPI events but it's 9 years old and doesn't make mention of unlock, only lock https://github.com/ltworf/python-acpi/b … er/acpi.py

Also looking in /sys/class/wakeup there are just a bunch of things I can't even begin to understand but looks like a way to WRITE a wakeup event and trigger one rather than read from after it occurs.

I've asked on the i3lock github if there is a signal. If not I'll probably switch to another lock manager, I know that the gnome one does emit at least lock events.
##


********************

There is another suggestion to detect via Linux Real Mode Interface, found here: https://sourceforge.net/projects/lrmi/

Here is an example extracted from SO:

#include "lrmi.h"

int main(void)
{
   struct LRMI_regs r = {0};
   r.eax = 0x4F10;
   r.ebx = 0x02;

   ioperm( 0, 1024, 1 );
   iopl( 3 );

   if( !LRMI_init() || !LRMI_int( 0x10, &r ) )
   {
      return -1;
   }
   return (r.ebx >> 8) & 0xFF;
}

This could work, it might not, who knows. I'm honestly too lazy to test it.

Last edited by medicineman2500 (2021-10-08 07:36:10)

Offline

#5 2021-10-08 08:44:35

medicineman2500
Member
Registered: 2021-10-07
Posts: 66

Re: module-echo-cancel defaults to wrong sink/source

Solution to the lock signal is to forget about a signal and just run i3lock in a shell with "no forking" enabled.

i3/config:

bindsym XF86Sleep exec /etc/git/dotfiles/ArchLinux-Grout/.config/i3/wakeupconfig.sh

wakeupconfig.sh:

#!/bin/sh

killpa(){
	echo "killing pa"
	/usr/bin/pkill pasystray
	/usr/bin/pulseaudio -k
	echo "killed pa"
}
startpa(){
	echo "start pa"
	/usr/bin/pulseaudio --start
	exec /usr/bin/pasystray &
	echo "started pa"
}
killpa
i3lock -n --color "354350"
startpa

Example found here: https://manpages.debian.org/testing/i3l … .html#DPMS

Last edited by medicineman2500 (2021-10-08 11:48:22)

Offline

Board footer

Powered by FluxBB