Tuesday, July 4, 2017

DLNA Output for Linux

Many of my favorite bands stream their concerts these days, sometimes live, sometimes afterwards. It's fine to listen on the computer sometimes, but other times I'd like to listen to the show over something a bit better-sounding, like my stereo. I figured there had to be a way to do this, and it turns out that, indeed, there is. The Logitech Transporter I use as a digital source will function as a DLNA renderer (i.e., you can send it a DLNA audio signal). And I know that Linux plays nice with DLNA, since I often stream video to my TV that way (using minidlna, aka, ReadyMedia). So the only question is: How can I convince Linux to send audio from the computer to the Transporter?

Assuming you are using Pulse Audio, this sort of thing turns out not to be very hard. (See here for another set of instructions.) First, you will need to install pulseaudio-dlna, which is a little program that sets up any DLNA renderers it finds on your network as PulseAudio output devices. (For Fedora, there is a copr repo, which you can read about here.) There are a ton of options to set the audio format and bitrate and so forth, so check the manpage, as usual.

That can be it, if you wish. Once pulseaudio-dlna is running, you can just start up whatever you want to 'cast' and use the PulseAudio Volume Control (pavucontrol) to set the output device for that stream.

One note: To get this to work on my laptop, I have had to disable the firewall. I guess it would probably be enough to enable traffic on 8080, which is the port that pulseaudio-dlna runs on by default, but I've not bothered finding out. I only do this when home, and I'm not worried about the firewall then.

There's another useful trick I found, which is especially nice when you're trying to sort out problems, namely: You can bind two devices together with PulseAudio, so you get sound through both of them. In my case, what I wanted to do was have the audio output both from the computer and from the DLNA renderer. The command to do this will be something like:
pacmd load-module module-combine-sink sink_name=combined1 slaves=alsa_output.pci-0000_00_1b.0.analog-stereo,familyroomtransporter_dlna
Here, the sink_name is what this new device will be known as in PulseAudio. The 'slaves' are the devices to which that is, in effect, an alias. To figure out what names you need to use here, just do:
pacmd list-sinks | grep name:
where the grep part will limit the output just to the relevant names. Of course you can omit it to see more information.


No comments:

Post a Comment

Comments welcome, but they are expected to be civil.
Please don't bother spamming me. I'm only going to delete it.