Thank you for your donation!


Use alsa dmix as default device
#1
Hello,
it would be great if moode could use alsa's dmix plugin as default output device. This is alsa's software mixer and enables multiple applications to output audio at the same time.

For example, one can have several bluetooth devices connected and play spotify at the same time.

While one can argue whether listening to several audio sources at once makes sense, but I think, there is use for it:
- one can keep bluetooth devices connected at all times. Currently, all bluetooth devices have to disconnect before playing something (e.g. spotify).
- one can use moode as computer speakers for occasional sounds while listening to music.

As a proof of concept (and for my own cenvenience) I set this up manually on my moode box and got bluetooth and spotify to work simultaneously. Now, I don't need to disconnect bluetooth devices before being able to stream spotify. Also, connecting a bluetooth device while something is playing doesn't result in an error to the effect that one needs to re-connect the device before being able to play something.

I did it as follows:


/etc/asound.conf
Code:
pcm.!default {
        type plug
        slave.pcm "dmix"
}
This makes the "plug:dmix" device the default output device for all alsa aware software. This step is probably superfluous if every program is passed the audio device it ought to use anyway.

/etc/bluealsaaplay.conf
Code:
AUDIODEV=plug:dmix
This ensures that bluetooth connections are sent to dmix.

/var/www/inc/playerlib.php
Change the librespot command to use plug:dmix as device. Or don't pass a device at all so the configured default device is used.

Using the dmix device would also allow for the possibility to keep MPD running while other sound sources are active.

The default configuration of the plug:dmix device for alsa uses hw:0,0 as output. If this is meant to be configurable by moode, it would be easy to configure another dmix based device in /etc/asound.conf which sends the final outout to another sound card. For details, see https://www.alsa-project.org/main/index....undrc#dmix
Reply
#2
The usage scenario "multiple applications to output audio at the same time." doesn't seem to be generally applicable to moOde which is designed to output high quality audio from a single source to a single device. The only case where moOde uses dmix is to enable Bluetooth speaker sharing which in itself is a niche use case. But even this is meant to only output a single source at a time.
Enjoy the Music!
http://moodeaudio.org | http://twitter.com/MoodeAudio | http://github.com/moodeaudio
Reply
#3
I agree, that one generally doesn't want to actually play multiple audio sources simultaneously. However, currently, the transition from one source to another isn't smooth except when going from MPD to another source.

I totally understand, that dmix comes at the cost of potential resampling if the source rate doesn't match the rate of dmix.

Ideally, every time you start playback from a new source, the old source is signaled to stop and free the audio device. At the moment, works for stopping MPD when other sources come in, but not in any other direction. An especially annoying situation is bluetooth which blocks the audio device even when silent.

But for those who need convenience (or the so-called "wife acceptance factor"), it would be nice if there was a setting to optionally use dmix. After all, all that's really needed is a setting that results in plug:dmix being passed to applications instead of the usual hw:X,0. Then everyone can choose what they prefer.
Reply
#4
I'm still not seeing a generally applicable usage scenario for having all the different audio renderers automatically coordinate with one another. Typically only one renderer is used at a time. Airplay already offers session interruption and Bluetooth offers speaker sharing but even these capabilities are niche use cases.
Enjoy the Music!
http://moodeaudio.org | http://twitter.com/MoodeAudio | http://github.com/moodeaudio
Reply
#5
From what I understand dmix is not bit perfect.
Reply


Forum Jump: