[alsa-devel] Hotplug plugin
Sorry for crossposting, but this is a problem I am not quite sure might be solved by users or developers. Also I am not too lazy to do a little development myself, if that appears to be necessary.
This is my setup:
- internal snd-hda soundcard connected to speakers in the bathroom playing 24x7 music; - jvc amplifier in living room with integrated USB sound device.
The USB sound device in the amplifier vanishes when the amplifier is powered down.
So... this is my problem. I want to have 24x7 music on the internal soundcard and on the amplifier. When the amplifier is switched off, no audio should be send there (of course) but playback should resume as soon as the amplifier is switched on and the USB device re-appears.
I created a "tee" construction using asound.conf which adresses both soundcards, this works. At least... until the amplifer is switched off and the USB device disappears. Then the sound playing application gets an error and quits.
I tried these approaches for a solution:
- pulseaudio, using hal-detection and "combined" device: doesn't work because a removed device is never reinserted into the combined device; - alsa extplug: easy to create, no worries about the "slave" device, you get it for free, but I abandoned the idea as there is probably no way to recreate the slave pcm while the "owner" remains active. - alsa ioplug, attempt 1: there is probably no way to to address and recreate the "slave" (which I open myself in the plugin using snd_pcm_open) in such a way that it is completely transparent to the application that it is talking to the "slave" (not a "real" alsa slave) instead of the ioplug plugin - alsa ioplug, attempt 2: I tried to make the callback functions of the ioplug call the callbacks of the "slave" directly, but that probably isn't going to work either (too much callbacks in the pcm struct that have no equivalent in the ioplug struct) - alsa ioplug, attempt 3: open and write to the hardware devices directly. Abonded it as well because this cannot practically be done, as you'd need parts copies of header files from the kernel and alsalib for hidden data structures.
Anyone ideas to solve this in a neat way? (preferrably using an alsa plugin; for the moment I am using a self-made external program that alsa dumps it sound to (file plugin) and uses two alsa-player processes to get the audio to the devices)
On Mon, 31.12.07 15:18, Erik Slagter (erik@slagter.name) wrote:
- pulseaudio, using hal-detection and "combined" device: doesn't work
because a removed device is never reinserted into the combined device;
Of course it is. Just install PA 0.9.7 or newer.
Lennart
Lennart Poettering wrote:
- pulseaudio, using hal-detection and "combined" device: doesn't work
because a removed device is never reinserted into the combined device;
Of course it is. Just install PA 0.9.7 or newer.
I have pulseaudio 0.9.7 actually installed (F8, from package pulseaudio-0.9.7-0.17.svn20071017.fc8.x86_64) and I didn't get it to work like you describe. I will try again if you say it should work like this.
BTW there is one thing that puzzles me with pulseaudio, I have enabled the "create a sink that covers all devices" (or something similar) option, but I never see the sink. It looks like this would be the functionality I am searching for.
I have a slight clue why it doesn't work ;-) I am running the pulseaudio daemon system-wide (the concept of a sound daemon per user login repels me), so the gui tools (which run with my uid) probably don't have the access rights to change the config files. That's actually good. At least, if I could set all parameters by editing the config files. But I can't find the config file option for the "create an all devices device" function.
Lennart Poettering wrote:
- pulseaudio, using hal-detection and "combined" device: doesn't work
because a removed device is never reinserted into the combined device;
Of course it is. Just install PA 0.9.7 or newer.
Nope, really.
The relevant config file sections (using pa 0.9.7):
***
load-module module-hal-detect load-module module-combine sink_name=all -> master=alsa_output.pci_8086_27d8_alsa_playback_0 -> slaves=alsa_output.usb_device_8bb_2704_noserial_if0_alsa_playback_0 -> adjust_time=5 resample_method=src-sinc-best-quality
- or -
load-module module-detect load-module module-combine sink_name=all master=alsa_output.hw_0 -> slaves=alsa_output.hw_1 adjust_time=10 -> resample_method=src-sinc-best-quality
- or -
load-module module-alsa-sink device=hw:0 format=s16 rate=44100 -> channels=2 sink_name=alc883 channel_map=left,right load-module module-alsa-sink device=hw:1 format=s16 rate=44100 -> channels=2 sink_name=jvc channel_map=left,right load-module module-combine sink_name=all master=alc883 slaves=jvc -> adjust_time=10 resample_method=src-sinc-best-quality
***
-> is line continuation
These combinations all yield the same result: at startup I have an "all" sink that combines both devices, and does that pretty well, I must say. But as soon as the USB device is removed, it is removed from the combined "all" sink. Then when the USB device is reinserted, it gets detected (module-hal-detect) or not (module-detect, static config). Using module-hal-detect the reinserted just sits there, it isn't added to the combined sink. Using the other methods, it's not even detected that the USB device is back...
The only solution I can think of, is a udev script that casts some magic spells towards pulse when the USB device is inserted or removed... But then I could skip pulse altogether, because mpd has an option to activate and deactivate selected outputs at runtime, as well.
On Tue, 01.01.08 19:26, Erik Slagter (erik@slagter.name) wrote:
load-module module-alsa-sink device=hw:0 format=s16 rate=44100 -> channels=2 sink_name=alc883 channel_map=left,right load-module module-alsa-sink device=hw:1 format=s16 rate=44100 -> channels=2 sink_name=jvc channel_map=left,right load-module module-combine sink_name=all master=alc883 slaves=jvc -> adjust_time=10 resample_method=src-sinc-best-quality
-> is line continuation
These combinations all yield the same result: at startup I have an "all" sink that combines both devices, and does that pretty well, I must say. But as soon as the USB device is removed, it is removed from the combined "all" sink. Then when the USB device is reinserted, it gets detected (module-hal-detect) or not (module-detect, static config). Using module-hal-detect the reinserted just sits there, it isn't added to the combined sink. Using the other methods, it's not even detected that the USB device is back...
Hmm, if that doesn't work with module-hal-detect, then please provide me with a full output of pulseaudio -vv when this happens. However, the ALSA ML is probably not the right place to discuss this. Please post this in the PA ML.
The only solution I can think of, is a udev script that casts some magic spells towards pulse when the USB device is inserted or removed... But then I could skip pulse altogether, because mpd has an option to activate and deactivate selected outputs at runtime, as well.
No. If module-hal-detect finds the device, but module-combine doesn't then this is some real problem we need to debug.
Lennart
participants (2)
-
Erik Slagter
-
Lennart Poettering