udev rule for running a ALSA to Jack bridge when USB device is plugged in

classic Classic list List threaded Threaded
5 messages Options
Max
Reply | Threaded
Open this post in threaded view
|

udev rule for running a ALSA to Jack bridge when USB device is plugged in

Max
Hi list,

I was trying to create a udev rule to start a zita-a2j ALSA to Jack
bridge automatically if i plug in a specific USB device.
Has anyone succeeded doing something like this?
One issue is that the user is wrong, udev rules are not launched by the
user account.

m.
_______________________________________________
Linux-audio-user mailing list
[hidden email]
https://lists.linuxaudio.org/listinfo/linux-audio-user
Reply | Threaded
Open this post in threaded view
|

Re: udev rule for running a ALSA to Jack bridge when USB device is plugged in

Len Ovens
On Tue, 3 Dec 2019, Max wrote:

> I was trying to create a udev rule to start a zita-a2j ALSA to Jack
> bridge automatically if i plug in a specific USB device.
> Has anyone succeeded doing something like this?
> One issue is that the user is wrong, udev rules are not launched by the
> user account.

I chose the other route and listen to the system side of dbus for the
right signal. This does mean there has to be something running to monitor
dbus. The up side is that daemon also knows that jack is actually running
and so only starts zita-ajbridge if there is a jack to work with.

If you are not running dbus then you will need to set your user in the
script udev calls. Then check that jack is running and then you can run
zita-ajbridge and detach it so the udev script can exit.

From experience, you will also need to send the zita-ajbridge a SIGINT
when UDEV detects that device has left. If you do not have anything
sitting around to read the exit info from zita-ajbridge it will leave
zombie processes. While having zombies hanging around is not really a
problem, actually having zita-ajbridge continue to run after the USB
device has vanished tends to use a lot of cpu.

--
Len Ovens
www.ovenwerks.net
_______________________________________________
Linux-audio-user mailing list
[hidden email]
https://lists.linuxaudio.org/listinfo/linux-audio-user
Max
Reply | Threaded
Open this post in threaded view
|

Re: udev rule for running a ALSA to Jack bridge when USB device is plugged in

Max
On 03.12.19 17:32, Len Ovens wrote:

> On Tue, 3 Dec 2019, Max wrote:
>
>> I was trying to create a udev rule to start a zita-a2j ALSA to Jack
>> bridge automatically if i plug in a specific USB device.
>> Has anyone succeeded doing something like this?
>> One issue is that the user is wrong, udev rules are not launched by
>> the user account.
>
> I chose the other route and listen to the system side of dbus for the
> right signal. This does mean there has to be something running to
> monitor dbus. The up side is that daemon also knows that jack is
> actually running and so only starts zita-ajbridge if there is a jack to
> work with.

Ah, that's interesting. I'm curious about the approach but have no idea
where you would install such a dbus listening script. Would it be
possible to be a bit more specific or even share such script for
everyone to adapt?

M.
_______________________________________________
Linux-audio-user mailing list
[hidden email]
https://lists.linuxaudio.org/listinfo/linux-audio-user
Reply | Threaded
Open this post in threaded view
|

Re: udev rule for running a ALSA to Jack bridge when USB device is plugged in

Len Ovens
On Tue, 3 Dec 2019, Max wrote:

> Ah, that's interesting. I'm curious about the approach but have no idea
> where you would install such a dbus listening script. Would it be
> possible to be a bit more specific or even share such script for
> everyone to adapt?

The script is a part of ubuntustudio-controls:
https://git.launchpad.net/ubuntustudio-controls/tree/usr/bin/autojack

There are more fixes coming that have not been pushed yet including
changing the signal to SIGINT and catching the return code for no zombies.
The gui, as always, is taking time.

--
Len Ovens
www.ovenwerks.net
_______________________________________________
Linux-audio-user mailing list
[hidden email]
https://lists.linuxaudio.org/listinfo/linux-audio-user
Reply | Threaded
Open this post in threaded view
|

Re: udev rule for running a ALSA to Jack bridge when USB device is plugged in

Christopher Arndt
In reply to this post by Max
Am 03.12.19 um 14:01 schrieb Max:
> I was trying to create a udev rule to start a zita-a2j ALSA to Jack
> bridge automatically if i plug in a specific USB device.
> Has anyone succeeded doing something like this?

My app jack-select [1] use pyudev [2] to listen for changes in the
attached sound devices. Relevant pieces of the code are:

*
https://github.com/SpotlightKid/jack-select/blob/master/jackselect/devmonitor.py
*
https://github.com/SpotlightKid/jack-select/blob/master/jackselect/pyudev_gobject.py
*
https://github.com/SpotlightKid/jack-select/blob/master/jackselect/jackselect.py#L85
*
https://github.com/SpotlightKid/jack-select/blob/master/jackselect/jackselect.py#L326


HTH, Chris

[1] https://github.com/SpotlightKid/jack-select
[2] https://github.com/pyudev/pyudev
_______________________________________________
Linux-audio-user mailing list
[hidden email]
https://lists.linuxaudio.org/listinfo/linux-audio-user