TP-Link based DLNA Music Player

Everybody is building some kind of multimedia stuff with a Raspberry Pi these days. I’m no exception as I also have one connected to my (really shitty Philips) TV, running RaspBMC. But that’s not what this post is about, and it’s also pretty lame, since there isn’t really that much to it.

Objective

I also wanted something to connect to my stereo to play music, but I didn’t want to use a Pi for that for these reasons:

  • It’s rather wasteful. The Pi including a power supply and an SD-Card costs about 50,-€ and I wouldn’t even use most of the hardware it comes with.
  • The SD-Card will break eventually. Depending on how much logging I would forget/neglect to disable, rather sooner than later.
  • It doesn’t have wifi and I have no ethernet in the dining room where the stereo sits.
  • The audio output of the Pi sucks. Plain and simple. It’s about as far from HiFi as Fox News is from being a news network. So I’d have to use an external DAC to get decent audio output from it.
  • It’s about as lame as using a Pi for video playback. Perhaps even more so.
Now that we have established that a Raspberry Pi just isn’t the right tool for the job, what is? A cheap chinese wifi router seems to be a perfect fit, provided it has enough power to decode MP3s, OGGs, and FLACs (and it has). The only thing missing is the audio output, but that can be added as a USB device, the same way it would have to be done with a RasPi. Also, it obviously has wifi and it’s a lot cheaper than a RasPi.
Hardware

I went for a TP-Link WR841N V7.2 because that’s what I had lying around. I also had a Behringer USB DAC collecting dust. If anyone wants to replicate this project, I’d recommend getting another kind of router, since the WR841N doesn’t have a USB port. The processor does, however, but I had to solder the D+ and D- wires to some tiny ass resistors on the board and generate the +5V from the routers 9V supply voltage myself. Any version more recent than 7.2 of the router doesn’t even have traces for the data pins and the processor comes in a QFN package, so you’d have to cut away part of the processor package and solder the data lines directly to the processor pins. Some people have done that, but I’m just not that sick. I might be a cheap bastard, but putting a Dremel to a QFN package is where I draw the line.
Somewhere left of the processor are R601 and R602 where D+ and D- surface

Other than adding those data lines the hardware side of this build isn’t too interesting, so I will spare you the details.

Botched up a 7805 voltage regulator and a few caps on a piece of perfboard
OpenWRT

Since these cheap routers only have a few megs of flash, they can only run special embedded Linux distributions like OpenWRT, which is what I am using. But even with that, there was no way of fitting all the needed packages in there, so I added a flashdrive to deal with that. Since the processor only has one USB port a USB hub was also needed. That was actually the only thing I had to buy for this project.
The OpenWRT project provides lots of documentation about building minimal images and putting its root filesystem on an external storage, so I’ve done just that. With plenty of storage to install the needed packages, it’s for the hard part: Building the software.
GStreamer and gmrender-resurrect

There are quite a lot of projects out there that achieve a similar goal, but it seems that all of them use mpd for streaming. Frankly, I don’t like mpd very much, mainly because all clients I’ve seen so far lack in usability. Also, it seems to me that while it even supports gapless playback, it’s unlikely to be adopted by manufacturers (if it were, there would be a few commercially available players by now). DLNA on the other hand looks like it’s quickly becoming a de-facto industry standard as it already has been adopted by some very reputable HiFi manufacturers like Linn, Marantz, Denon and others.

For DLNA-Support there is a project based on the gstreamer framework, called gmrender-resurrect, and also an OpenWRT port of it. OpenWRT packages can be built using either the OpenWRT SDK or the OpenWRT buildroot. If you can live with the hopelessly outdated gstreamer packages provided by OpenWRT, it’s just a matter of building the gmrender-resurrect package and you’re done. I couldn’t, however, so I built packages for the current version of gstreamer, too, which took me forever.

I’d like to point out that no real coding or porting work was done on my part. I just updated and fixed a few Makefiles to make it build. All the real work was done by other people.

 

The finished thing: Router, USB-Hub, Flashdrive, USB-DAC
All patches needed to compile gmrender-resurrect and gstreamer (including plugins) are available on my github.
What it can do

These little routers are really amazing. With this I am now able to play music from any DLNA source (fileserver, phone, tablet, laptop, you name it…) to the stereo in my dining room. I’m using BubbleUPNP on Android as control point and it really works great! Also, it still acts as a WDS-router.

Where to go from here

There’s a lot more that can be done, given that all the LEDs and buttons in the router are actually GPIOs. So adding a LCD and putting it in a nice enclosure (like an old CD-Player) with Play/Pause/Skip-buttons should be pretty easy.

This entry was posted in Digital, Linux. Bookmark the permalink.

4 Responses to TP-Link based DLNA Music Player

  1. Daniel Zhu says:

    Hi, I have no idea how to use the Openwrt buildroot/SDK :(. So would it be possible for you share the gmediarender file under /usr/sbin/ of openwrt. I have installed related packages for OP chaos camler. Thanks!
    PS. if you could make ipk file for it, that wouls really save the day!

  2. Alexander says:

    It's a bit embarrassing, but I've already scrapped the project, since I wasn't able to get the gapless playback working properly, and I also had issues with the WIFI module, so there are binaries that I could give you. Don't give up on the buildroot, though, there's a lot of (admittedly sometimes confusing and contradicting) documentation. If I could do it, you can too! 🙂

  3. Daniel Zhu says:

    I spent some time learning the openwrt wiki for buildroot and used your patch for gmediarender. And I was able to compile gmediarender XXXXXX.ipk. So thank you!!
    I installed it on the OpenWRT CC 15.05-rc2. Not working….. 
    But, I found a work around. I deleted /etc/init.d/gemediarender ( I think there some problem with it, that’s why it is not starting) and installed the following packages: gst1-plugins-base/good/bad/ugly and start gmediarender from “/usr/sbin/gmediarender –d” in rc.local file. Now it’s working…. 
    As for the gapless playback, as long as it plays the next song in the queue, I ‘am OK with it.
    My question is: the four packages (gst1-plugins-base/good/bad/ugly) includes so many modules (gst1-mod-XX) and when I installed these four, the size became so big!! So could you tell which gst1-mod-XXs are essential and which r not so that I don’t have to install all of them?

  4. Alexander says:

    Most of them should only be needed to decode some obscure and/or obsolete data formats, like Real Media (R) (is that stuff still around?). I don't remember which ones are essential for mp3 decoding, as they usually don't have something like mp3 in their name, but most of the others do.

Comments are closed.