UPnP / DLNA music playing with gmrender


19 posts
by scphillips » Mon Jan 14, 2013 3:14 pm
I have written a tutorial on my blog (http://blog.scphillips.com/2013/01/using-a-raspberry-pi-with-android-phones-for-media-streaming/) about how to install gmrender as a UPnP renderer (player) for music on a RPi. The tutorial also describes using minidlna and BubbleUPnP server on a media server and the BubbleUPnP controller for Android.

The solution presented gives a headless (no screen) system (or systems) that can be controlled from multiple Android devices all of which share the same playlist. It uses UPnP/DLNA so is compatible with many modern Smart TVs and many media centres as alternative sources or sinks. The BubbleUPnP controller software also lets you get music from Shoutcast streams (via Xiialive) and from Google Music (the "cloud").

I should note that none of the software was written by me, I just pulled it all together and wrote a tutorial. Isn't it amazing that we have all this excellent free software and an amazing low-cost computer to run it on?

There is quite a long discussion thread on the blog and it has been suggested that we have a place on the forum here to bash out the fine details of various problems, so here it is.

Many of the issues are to do with getting the sound on the RPi to work. The solution presented in my tutorial configures gmrender (which uses GStreamer) to send sound through PulseAudio (running in system mode) and thence to ALSA. It works fine (for me) apart from popping noises between tracks (which do not seem to be fixed by the often-suggested solution of stopping the PulseAudio module from dynamically unloading).
Posts: 10
Joined: Thu Jan 10, 2013 5:08 pm
by xnosek00 » Mon Jan 14, 2013 4:34 pm
We have a problem with the tutorial and maybe we need somebody, who is guru in pulseaudio :)

Tutorial by author is working on a clean raspbian. But Me and colleague have problem with installing. We can heard any noise. I controled each step in tutorial and my settings are same. But music is not playing. I tried a aplay and I can't hear sound too.

When I do:
root@raspberrypi:/home/pi# alsactl store

I have this error:
xcb_connection_has_error() returned true

But author has no error.

I have compiled XBMC on my raspbian, but when I'm testing tutorial, XBMC is closed.

Second difference is in kernel. I have:
pi@raspberrypi ~ $ uname -a
Linux raspberrypi 3.6.11+ #354 PREEMPT Sun Jan 13 16:13:26 GMT 2013 armv6l GNU/Linux

We haven't found solution yet.

Does anybody have tip, what is wrong. I thing - the problem is somewhere in pulseaudio or alsa.
Posts: 27
Joined: Mon Nov 12, 2012 2:17 am
by brombomb » Tue Jan 15, 2013 7:30 am
I was stuck without audio for a bit. I tried removing pulse audio with

$ apt-get remove --purge pulseaudio

and then reinstalling it, which didn't work for me.

Then I did some quick research on the alsamixer interface and I found this page:
http://slopjong.de/2011/08/20/unmute-th ... lsa-utils/

Which showed that a muted channel has a "MM" in the box below the volume levels, and a "00" means unmuted. On my device my Master was unmuted by my headphones and speakers were muted. I quickly tried unmuting them using 'M' to toggle mute with the right arrow '->' key to move to the correct output. Viola! Worked perfect!

Thanks for much for your tutorial and finding all these pieces. I have been looking for this for a long time now.
Posts: 1
Joined: Tue Jan 15, 2013 7:25 am
by meltwater » Tue Jan 15, 2013 10:32 am
Thanks for this thread. I've had the same issue. I hope to run some more tests on it, since others have found reinstalling pulse audio fixes it for them.

My system I have the IP address read out to me using flite (I think that uses alsa directly). That still works ok, so seems like it is a driver issue. Unfortunately, I am still new to linux so limited a little.

I guess the other option is to look at why using ALSA directly is poor quality with this application, when I guess XBMC works ok with it.

As a work around for now, I've put openelec on a card and directed the audio to the analogue output. It gives similar headless functionality, although would be nice to have it as part of the normal system without the overhead.

Anyway, big thanks to the OP, without which I wouldn't have had a go in the first place!

UPDATE: Will give the "unmute" a go! I seem to recall the alsamixer was responding oddly to my keys anyway - but probably down to the way I was connecting to the Rpi remotely.

UPDATE2:
I only have Master shown for playback, even pressing F5 (all), I get Master and Capture.
______________
http://www.themagpi.com/
A Magazine for Raspberry Pi Users
Read Online or Download for Free.

My new book: goo.gl/dmVtsc

Meltwater's Pi Hardware - pihardware.com

Like the MagPi? @TheMagP1 @TheMagPiTeam
User avatar
Posts: 981
Joined: Tue Oct 18, 2011 11:38 am
by meltwater » Tue Jan 15, 2013 11:10 am
UPDATE3:
I reinstalled as suggested above, no new mixers shown in alsamixer, however the playback test (suggested in the blog comments) works (unfortnately I didn't have the foresight to test using sudo before uninstalling pulse audio).

Code: Select all
aplay /usr/share/scratch/Media/Sounds/Human/Laugh-female.wav
- only works with sudo (is that normal?).

My username is not pi, so I did adjust the script "pi:audio" - and that bit seems to be working anyway. I also added “sudo adduser pi pulse-access” with my username too.

Unfortunately, I can't retest the DLNA side until I am back on my home network (tonight).
______________
http://www.themagpi.com/
A Magazine for Raspberry Pi Users
Read Online or Download for Free.

My new book: goo.gl/dmVtsc

Meltwater's Pi Hardware - pihardware.com

Like the MagPi? @TheMagP1 @TheMagPiTeam
User avatar
Posts: 981
Joined: Tue Oct 18, 2011 11:38 am
by badfortrains » Sat Jan 19, 2013 6:26 pm
You might want to try:

Code: Select all
gpasswd -a [user] audio


to add your username to the audio group.

Also just wanted to say thanks scphillips, a upnp renderer setup on my pi is exactly what I wanted for a while but I kept getting stuck on the bad audio quality from gstreamer. I think the piece I was missing was starting pulse in system mode, but in any case following your instructions cleared everything up.
Posts: 2
Joined: Sat Jan 19, 2013 6:18 pm
by meltwater » Sun Jan 20, 2013 11:03 am
badfortrains wrote:You might want to try:

Code: Select all
gpasswd -a [user] audio


to add your username to the audio group.

Also just wanted to say thanks scphillips, a upnp renderer setup on my pi is exactly what I wanted for a while but I kept getting stuck on the bad audio quality from gstreamer. I think the piece I was missing was starting pulse in system mode, but in any case following your instructions cleared everything up.


That sounds like the problem, I'll try that when I get chance.

So far very impressed with how well the RPi does streaming, I think I will get another one just to do this.

Thanks!
______________
http://www.themagpi.com/
A Magazine for Raspberry Pi Users
Read Online or Download for Free.

My new book: goo.gl/dmVtsc

Meltwater's Pi Hardware - pihardware.com

Like the MagPi? @TheMagP1 @TheMagPiTeam
User avatar
Posts: 981
Joined: Tue Oct 18, 2011 11:38 am
by scphillips » Sun Jan 20, 2013 11:26 am
I'm glad some of you have had success with my tutorial. I've not had much time for this project in the last week but I've put together another post detailing all the ALSA tests and configuration I've been trying:

http://blog.scphillips.com/2013/01/sound-configuration-on-raspberry-pi-with-alsa/

It might help some of you.

Stephen.
Posts: 10
Joined: Thu Jan 10, 2013 5:08 pm
by KenT » Wed Jan 23, 2013 5:18 pm
I think I have made some progress with getting sound to work on 16/12/2012 debian wheezy.

There appears to be two problems:

1. pulseaudio has been added to this image but it would appear not configured properly

I sorted this out by following the post from ergosys here http://raspberrypi.stackexchange.com/questions/639/how-to-get-pulseaudio-running

The only different for me was that I created .asoundrc in /home/pi instead of editing /etc/asound.conf

It worked beautifully, thanks ergosys, no pops at the end of tracks.

2. amixer cset numid=3 x will not change the output between anlogue and hdmi

It worked initially by doing sudo cset ..... instead of cset.... then I rebooted, mistake it has never worked again.

Also if you do issue the amixer cset command, even if it does not work, the volume goes to zero and you have to run alsamixer to increase it.

I've tried all sorts of fixes to no avail. However I have noticed one thing which could be the cause, or just my lack of understanding of ALSA

Type amixer controls - numid=3 is master playback volume, 1 is capture volume

Look at /var/lib/alsa/asound.state which is the saved state of the controls - control 1 is the PCM playback volume, 3 is the PCM playback route!
Pi Presents - A display package for museums, visitor centres, and more
Download from http://pipresents.wordpress.com
Posts: 534
Joined: Tue Jan 24, 2012 9:30 am
Location: Hertfordshire, UK
by KenT » Wed Jan 23, 2013 7:30 pm
Just fired up the October Raspbian Wheezy in which amixer cset numid=3 worked,

The alsa saved state is the same but amixer controls gives 3 = playback route, 1= playback volume which is different to the December image.

Now just need to find where this is set up.
Pi Presents - A display package for museums, visitor centres, and more
Download from http://pipresents.wordpress.com
Posts: 534
Joined: Tue Jan 24, 2012 9:30 am
Location: Hertfordshire, UK
by KenT » Thu Jan 24, 2013 12:14 pm
KenT wrote:I think I have made some progress with getting sound to work on 16/12/2012 debian wheezy.

There appears to be two problems:

1. pulseaudio has been added to this image but it would appear not configured properly

I sorted this out by following the post from ergosys here http://raspberrypi.stackexchange.com/questions/639/how-to-get-pulseaudio-running

The only different for me was that I created .asoundrc in /home/pi instead of editing /etc/asound.conf

It worked beautifully, thanks ergosys, no pops at the end of tracks.

2. amixer cset numid=3 x will not change the output between anlogue and hdmi

It worked initially by doing sudo cset ..... instead of cset.... then I rebooted, mistake it has never worked again.

Also if you do issue the amixer cset command, even if it does not work, the volume goes to zero and you have to run alsamixer to increase it.

I've tried all sorts of fixes to no avail. However I have noticed one thing which could be the cause, or just my lack of understanding of ALSA

Type amixer controls - numid=3 is master playback volume, 1 is capture volume

Look at /var/lib/alsa/asound.state which is the saved state of the controls - control 1 is the PCM playback volume, 3 is the PCM playback route!


Have a feeling 1 is not actually problem. 2. was making me very confused; now reported on github raspberrypi/firmware
Pi Presents - A display package for museums, visitor centres, and more
Download from http://pipresents.wordpress.com
Posts: 534
Joined: Tue Jan 24, 2012 9:30 am
Location: Hertfordshire, UK
by PatrickLuimême » Wed Feb 20, 2013 5:58 pm
Hi,

I discovered the tutorial to operate the PI as a DLNA renderer.
I followed the instructions & I managed , although some commands were dark, to operate the feature.
so thanks a lot

I try to avoid the wifi at home, but I enabled it during sometimes for launching some music from a DLNA server to that new renderer. I had connected before a small speaker self-amplified.
I managed to listen the music but I was not able to set the volume ( previously set at the maximum as indicated inside the tutorial ). so, with a ssh connection from may win-xp laptop, I decreased the volume by alsamixer. but I needed the ssh connection. and how to stop the listening ????
For me, it is a limitation to the feature of dlna-rendering by the pi.
i have another DLNA player ( Philips NP1100 ) & i can stop the music sent by another DLNA controller, or set the volume by a remote control.
does such remote control exist ?
Posts: 11
Joined: Wed Feb 06, 2013 11:58 am
Location: Chartres, FRANCE
by perplu » Sun Feb 24, 2013 4:35 am
Have put all the test information below only as additional context. TEST 3 below is a working solution for synchronised music play-back to multiple audio devices running Squeezelite.

The only issue noted is that the volume is much quieter in TEST 3 than in TEST 2. Don't quite know why this was. Will need to investigate. But - the solution seems to be use Squeezelite, Raspberry PI stuck on the back of powered speakers in each room of the house. The ony down-side is the Squeeze Server interface could do with a refresh - its a bit tired. Useful also is that there are two android apps that are OK for use as a remote control.

SETUP:
DS 109+
All music FLAC.

AIRPLAY TEST:
Three airplay receivers setup:
- Android 2.3 with AirBubble
- Shairport on Raspberry PI - http://jordanburgess.com/post/389864343 ... pi-airplay
- Windows 7 Laptop with Shairport4W

TEST 1:
Played to all from DS Audio.
No music played; Raspberry crashes.

TEST 2:
Played simultaneously to all from MusicBee with Remote Speakers Out add-in installed and all three airplay receivers selected.
Music played OK, but not in sync.

SQUEEZE-SERVER TEST:
Two squeeze receivers setup:
Squeezelite on Windows 7 Laptop.
Squeezelite on Raspberry PI viewtopic.php?f=38&t=25778 . Audio was out via Raspberry HDMI port to Onkyo receiver.

TEST 3:
Played same track simultaneously from DS NAS Squeeze and all in sync to both Squeeze receivers. Could also play to multiple audio devices the same track synchronised using either of two android apps on my smartphone running android 2.3.
Posts: 11
Joined: Sun Feb 24, 2013 4:30 am
by deefunkt » Mon Mar 25, 2013 5:25 am
Hi, firstly, thanks for the awesome tutorial Stephen! Everything is working well when I followed your instructions...but the one place where u didn't give instructions was on installing the bubbleupnp software on the Pi! The pi is my first time using any linux/unix system, and following the instructions on bubbleupnp's homepage confused me a lot...wondering if you (or anyone else) could walk me through installation?

I've extracted the .rar file onto my windows pc, and I assumed the instructions on the webpage meant that I had to transfer the extracted contents onto the Pi's harddrive (the sd card)...when I open my sd card on windows however, there are no directories, only the Pi's system files - i'm assuming the Pi's directories can only be accessed on the Pi itself. SO my question is, can I download and install bubbleupnp through the pi itself?

like a sudo apt-get install bubbleupnp or something like that command?
Posts: 9
Joined: Fri Mar 15, 2013 11:19 pm
by scphillips » Mon Mar 25, 2013 12:37 pm
I'm not at my Pi at the moment and haven't much time, but here's some thoughts:

* Log in to the RPi
* Download BubbleUPnP Server using this command:
wget 'http://www.bubblesoftapps.com/bubbleupnpserver/0.6.4/BubbleUPnPServer-0.6.4.zip'
* unzip it using:
unzip BubbleUPnPServer-0.6.4.zip
* find the launch.sh script in the files you've just unpacked and make it executable using:
chmod +x launch.sh
* run the script using:
./launch.sh

* You will need to have some sort of Java version installed, try:
sudo apt-get install openjdk-7-jre-headless

I realise that's a bit brief, but I hope it helps.
Posts: 10
Joined: Thu Jan 10, 2013 5:08 pm
by scphillips » Wed Jul 24, 2013 8:25 am
I've published an update to this tutorial:
http://blog.scphillips.com/2013/07/play ... revisited/

It's much simpler now and does not need pulse audio, thanks to all the software and firmware updates.

Stephen.
Posts: 10
Joined: Thu Jan 10, 2013 5:08 pm
by mecaz » Thu Jul 25, 2013 6:32 am
Hello,

i am trying to install gmrender-resurrect but i got following errors when i execute "make" and "make install" commands. i hope somebody could help me with that.

Error:,

pi@raspinas ~/gmrender-resurrect $ make
make all-recursive
make[1]:`/home/pi/gmrender-resurrect' dizinine giriliyor
Making all in src
make[2]:`/home/pi/gmrender-resurrect/src' dizinine giriliyor
(echo "#define GM_COMPILE_VERSION \"2013-07-24_77758bf\"" > git-version.h-new; \
cmp -s git-version.h git-version.h-new || cp git-version.h-new git-version.h; \
rm git-version.h-new)
gcc -std=gnu99 -DHAVE_CONFIG_H -I. -I.. -pthread -I/usr/include/glib-2.0 -I/usr/lib/arm-linux-gnueabihf/glib-2.0/include -pthread -I/usr/include/gstreamer-0.10 -I/usr/include/glib-2.0 -I/usr/lib/arm-linux-gnueabihf/glib-2.0/include -I/usr/include/libxml2 -pthread -I/usr/include/upnp -DPKG_DATADIR=\"/usr/local/share/gmediarender\" -Wall -Wpointer-arith -Wmissing-prototypes -Wmissing-declarations -Wwrite-strings -MT main.o -MD -MP -MF .deps/main.Tpo -c -o main.o main.c
In file included from main.c:48:0:
/usr/include/glib-2.0/glib/gversion.h:28:2: error: #error "Only <glib.h> can be included directly."
make[2]: *** [main.o] Hata 1
make[2]: `/home/pi/gmrender-resurrect/src' dizininden çıkılıyor
make[1]: *** [all-recursive] Hata 1
make[1]: `/home/pi/gmrender-resurrect' dizininden çıkılıyor
make: *** [all] Hata 2

pi@raspinas ~/gmrender-resurrect $ make install
Making install in src
make[1]:`/home/pi/gmrender-resurrect/src' dizinine giriliyor
(echo "#define GM_COMPILE_VERSION \"2013-07-24_77758bf\"" > git-version.h-new; \
cmp -s git-version.h git-version.h-new || cp git-version.h-new git-version.h; \
rm git-version.h-new)
gcc -std=gnu99 -DHAVE_CONFIG_H -I. -I.. -pthread -I/usr/include/glib-2.0 -I/usr/lib/arm-linux-gnueabihf/glib-2.0/include -pthread -I/usr/include/gstreamer-0.10 -I/usr/include/glib-2.0 -I/usr/lib/arm-linux-gnueabihf/glib-2.0/include -I/usr/include/libxml2 -pthread -I/usr/include/upnp -DPKG_DATADIR=\"/usr/local/share/gmediarender\" -Wall -Wpointer-arith -Wmissing-prototypes -Wmissing-declarations -Wwrite-strings -MT main.o -MD -MP -MF .deps/main.Tpo -c -o main.o main.c
In file included from main.c:48:0:
/usr/include/glib-2.0/glib/gversion.h:28:2: error: #error "Only <glib.h> can be included directly."
make[1]: *** [main.o] Hata 1
make[1]: `/home/pi/gmrender-resurrect/src' dizininden çıkılıyor
make: *** [install-recursive] Hata 1</glib.h></glib.h>
Posts: 6
Joined: Thu Jul 25, 2013 5:45 am
by scphillips » Thu Jul 25, 2013 12:20 pm
There is a problem with the latest gmrender-resurrect code (which has updated since i published that blog post).
If you use a slightly earlier version you will find it works fine. From the gmrender-resurrect directory, just do:

git checkout be5eb1e6156182f410cee612767bf5cdc08220de

then do "make" again, "sudo make install", etc..

I've filed a bug on this: https://github.com/hzeller/gmrender-resurrect/issues/30

Stephen.

mecaz wrote:Hello,

i am trying to install gmrender-resurrect but i got following errors when i execute "make" and "make install" commands. i hope somebody could help me with that.

Error:,

pi@raspinas ~/gmrender-resurrect $ make
make all-recursive
make[1]:`/home/pi/gmrender-resurrect' dizinine giriliyor
Making all in src
make[2]:`/home/pi/gmrender-resurrect/src' dizinine giriliyor
(echo "#define GM_COMPILE_VERSION \"2013-07-24_77758bf\"" > git-version.h-new; \
cmp -s git-version.h git-version.h-new || cp git-version.h-new git-version.h; \
rm git-version.h-new)
gcc -std=gnu99 -DHAVE_CONFIG_H -I. -I.. -pthread -I/usr/include/glib-2.0 -I/usr/lib/arm-linux-gnueabihf/glib-2.0/include -pthread -I/usr/include/gstreamer-0.10 -I/usr/include/glib-2.0 -I/usr/lib/arm-linux-gnueabihf/glib-2.0/include -I/usr/include/libxml2 -pthread -I/usr/include/upnp -DPKG_DATADIR=\"/usr/local/share/gmediarender\" -Wall -Wpointer-arith -Wmissing-prototypes -Wmissing-declarations -Wwrite-strings -MT main.o -MD -MP -MF .deps/main.Tpo -c -o main.o main.c
In file included from main.c:48:0:
/usr/include/glib-2.0/glib/gversion.h:28:2: error: #error "Only <glib.h> can be included directly."
make[2]: *** [main.o] Hata 1
make[2]: `/home/pi/gmrender-resurrect/src' dizininden çıkılıyor
make[1]: *** [all-recursive] Hata 1
make[1]: `/home/pi/gmrender-resurrect' dizininden çıkılıyor
make: *** [all] Hata 2

pi@raspinas ~/gmrender-resurrect $ make install
Making install in src
make[1]:`/home/pi/gmrender-resurrect/src' dizinine giriliyor
(echo "#define GM_COMPILE_VERSION \"2013-07-24_77758bf\"" > git-version.h-new; \
cmp -s git-version.h git-version.h-new || cp git-version.h-new git-version.h; \
rm git-version.h-new)
gcc -std=gnu99 -DHAVE_CONFIG_H -I. -I.. -pthread -I/usr/include/glib-2.0 -I/usr/lib/arm-linux-gnueabihf/glib-2.0/include -pthread -I/usr/include/gstreamer-0.10 -I/usr/include/glib-2.0 -I/usr/lib/arm-linux-gnueabihf/glib-2.0/include -I/usr/include/libxml2 -pthread -I/usr/include/upnp -DPKG_DATADIR=\"/usr/local/share/gmediarender\" -Wall -Wpointer-arith -Wmissing-prototypes -Wmissing-declarations -Wwrite-strings -MT main.o -MD -MP -MF .deps/main.Tpo -c -o main.o main.c
In file included from main.c:48:0:
/usr/include/glib-2.0/glib/gversion.h:28:2: error: #error "Only <glib.h> can be included directly."
make[1]: *** [main.o] Hata 1
make[1]: `/home/pi/gmrender-resurrect/src' dizininden çıkılıyor
make: *** [install-recursive] Hata 1</glib.h></glib.h>
Posts: 10
Joined: Thu Jan 10, 2013 5:08 pm
by Justabloke » Sun Dec 22, 2013 12:46 am
Hi
Just wanted to say thanks for the great blog post.
As a complete noob to not just the Rpi but all things linux, I found your blog a great help.
I've been happily steaming music from my HTPC to my main hi fi all day long!

I'm gonna see about adding an LCD to present track info too.

Thanks again.

JaB
Posts: 2
Joined: Thu Dec 19, 2013 9:25 pm