As I recently bough a soundsystem with a built-in USB Soundcard and I already had a Router running OpenWRT, I wanted to set this router up as a soundserver. I already knew OpenWRT has packages for usb sound support and pulseaudio a network sound server. So the idea was close to make the soundsystem availbable over the network through the Router running OpenWRT.

As there are not complete manuals on which steps to take I just want to note down the steps I took to save me the fiddling next time and also help other doing the same thing.

Preconditions: A router with an USB port running OpenWRT (tested on version 14.07 "Barrier Braker"). Preferably with USB essentials already installed. A USB soundcard (probably built into your sound system) you want to make available in the local network.


First of all of course I consulted the OpenWRT wiki which almost helped me all the way through.

Here is what needs to be done step by step:

1. Make sure you have all the necessary USB packages installed to support basic USB functionality as well as USB soundcards. See here what to install: OpenWRT Wiki USB-Audio
For easy debugging of USB devices detected I would also install usbutils, otherwise the required packages are enough.
So that would be an opkg install kmod-usb-audio kmod-sound-core usbutils

2. Connect the USB Soundcard and make sure it's powered on. Then check if it appears using lsusb. There should be (among others) a sound device in that list.

3. Once we have USB sorted out we can move on to the sound driver level. See this wiki page: OpenWRT Wiki Pulseaudio. Again I recomend the alsa-utils package for not flying blind.
So do a opkg install alsa-libs libsndfile alsa-utils to get alsa (sound drivers) working. At this point I did a reboot to make sure everything gets loaded correctly. But it might just work right away. In this case you might want to run alsactl init to load drivers for detected hardware

4. You can now run alsamixer to confirm that you indeed have a soundcard working which volumes you are able to control.

5. Once all that works, we just need our pulseaudio soundserver. Install the pulseaudio-daemon package (if not already done in the previous steps). Then you have to change the configuration file in /etc/pulse/system.pa.
Unfortunately this file contains stuff that doesn't make sense for the OpenWRT package of pulseaudio (explained here). So you can strip it down to just two lines by either commenting or deleting what's already there. Add instead the two lines:

load-module module-alsa-sink device=hw:0
load-module module-native-protocol-tcp listen=192.168.1.1 auth-ip-acl=127.0.0.1;192.168.0.0/16

If your Router has anothe IP address change the listen address accordingly.

6. Do a /etc/init.d/pulseaudio restart to make sure the config is loaded. I also made sure that puleaudio gets loaded on boot (I used the Luci Webinterface > System > Startup for that). That was it. Your sound server should now be working, accepting connection from the local network!

7. Check if you can reach the sound server from another machine in the LAN. On any Linux box with pavucontrol installed (apt-get install pavucontrol for ubuntu), you can open the volume control connected to your routers soundserver with PULSE_SERVER=192.168.1.1 pavucontrol. This should display the detected soundcard on your router. If the soundcard shows up there this means it was detected by the pulseaudio server and you were able to connect to the server too. So you can move on to configuring the client(s).

Unfortunately zeroconf doesn't work on the current OpenWRT, so clients have to be configured manually. So on the client side (any linux machine that has pulse installed), run this command
pacmd load-module module-tunnel-sink server=192.168.1.1.
Then just select the sound output in the sound settings. See Client configuration on the Pulseaudio Wiki page again.

That's it. So after selecting the remote sound output you can just use any player to play some sound and it will automatically directed to that output.

Details on my Setup
Router Model: TP-Link TL-WDR4900 v1
OpenWRT Version: OpenWrt Barrier Breaker 14.07
Soundsystem: Teufel Concept E Digital 5.1 System (with integrated Soundcard)
Soundcard identifies as: C-Media Electronics, Inc. CM106 Like Sound Device
Client system: Ubuntu 15.04

2 Kommentare

Linear

  • aris  
    *I followed the tuto, I'm on bb14.07 and the client is ubuntu 16.04 lts 64 bit, on virtual box.
    The service is running on openwrt : < /usr/bin/pulseaudio --system --disallow-exit --disallow-module-loading --disable-shm --exit-idle-time=-1 --realtime=false
    and the client also find it on sound output : tunnel-sink.192.168.1.201 ..volume 89% ..muted no..
    but I cant hear any sound on testsound (in the ubuntu machine)
    On openwrt: I tested, and its just fine, using madplay to play some mp3 and the sound is working.
    Any clue ?

    thanks
    • Stefan Horning  
      *Sorry, can't think of anything, as you seem to have excluded all possible sources of error I can think of (sound generally works on OpenWRT, Network detection too, unmutet...).

Kommentar schreiben

Die angegebene E-Mail-Adresse wird nicht dargestellt, sondern nur für eventuelle Benachrichtigungen verwendet.
Umschließende Sterne heben ein Wort hervor (*wort*), per _wort_ kann ein Wort unterstrichen werden.
Gravatar, Twitter, Wavatars, Favatar Autoren-Bilder werden unterstützt.