38

I want to stream my audio output over the network (Wi-Fi) to my Android devices. I'm not looking for a music/video streaming solution, but I would stream any audio output of my GNU/Linux desktop to my Android work like a bluetooth headphone.

My GNU/Linux desktop is Debian Wheezy and the sound is provided by pulseaudio.

I've tried Pulseaudio's raop module (and enabled it on paprefs) + Android's AirBuddle app, but the audio is not streamed (pulseaudio seens connect to AirBuddle, but the sound is not reproduced, there is a connection failure in some softwares, in some other softwares the sound is stucked).

26

There is a very simple solution because PulseAudio already has all the necessary tools.

  1. Get your source device name with command pactl list | grep Name
  2. Create the following script named pashare:

    #!/bin/sh
    case "$1" in
      start)
        $0 stop 
        pactl load-module module-simple-protocol-tcp rate=48000 format=s16le channels=2 source=<source_name_here> record=true port=8000
        ;;
      stop)
        pactl unload-module `pactl list | grep tcp -B1 | grep M | sed 's/[^0-9]//g'`
        ;;
      *)
        echo "Usage: $0 start|stop" >&2
        ;;
    esac
    
  3. Make some checks and preparations (to allow script execution and check if the port successfully opened):

    chmod 755 pashare
    ./pashare start
    netstat -nlt | grep 8000 
    telnet 127.0.0.1 8000
    
  4. Download and install PulseDroid.apk

  5. Launch app on your phone; set the IP address to your computer and the port to 8000.

P.S. You can also check this Wiki page for general information on Pulseaudio network streaming, and this Wiki page about RTP streaming. Don't expect too much from streaming raw audio over WiFi; it takes enormous gobs of bandwidth. Even with a high-end wireless router/AP with a powerful signal I haven't been able to get more than stuttering audio out of it. Your best bet is probably to setup a proper media server (like Rygel, which works well with Pulseaudio) to transcode the raw audio to something like MP3 and stream that instead.

  • 7
    This also works perfectly with this Android App: Simple Protocol Player play.google.com/store/apps/… Note that this defaults to rate=44100 however, so you might want to use that. – Jannes Apr 20 '15 at 0:42
  • 1
    Just to clarify: the output of pactl list sources short is better to find the number of the source parameter. – wolfmanx Nov 12 '17 at 21:38
  • 4
    using pactl list | grep "Monitor Source" shows more relevant sources for me. – markroxor Apr 10 '18 at 7:39
17

You can use VLC to serve a MP3 stream of pulseaudio's output via HTTP.
The main advantage is that you don't need to install any special software on your remote device, a web browser (or music player) is all you need to play the stream. The downside is that it's audio only, a few seconds lag make it useless for videos

  1. Find pulseaudio's output name with:

    pactl list | grep "Monitor Source" 
    
  2. Start the VLC http server, replacing XXXX by your output name:

    cvlc -vvv pulse://XXXX --sout '#transcode{acodec=mp3,ab=128,channels=2}:standard{access=http,dst=0.0.0.0:8888/pc.mp3}'
    
  3. If needed, find your local IP address with ifconfig

  4. On your remote device, point the browser (or audio streaming app) to:

    http://your.local.ip.address:8888/pc.mp3
    

Note: The stream isn't affected by the volume set on the server, unless you totally mute it. If needed, you can keep the level just a tiny bit above 0 to only hear the remote device.


The first two steps combined into one by polynomial_donut:

cvlc -vvv pulse://$(pactl list | grep "Monitor Source" | awk '{print $3}') --sout '#transcode{acodec=mp3,ab=128,channels=2}:standard{access=http,dst=0.0.0.0:8888/pc.mp3}'
  • 1
    awesome! There's a 3 second lag but I'm happy with this little hack till I find that damn cable. I'll probably have to buy another one... – Slabo Aug 5 '18 at 18:43
  • @Slabo good point, for some reason i'd wrongly assumed the OP only wanted to stream music. Edited my answer – wilks Aug 12 '18 at 7:50
  • 2
    A one-liner instead of the first two lines: cvlc -vvv pulse://$(pactl list | grep "Monitor Source" | awk '{print $3}') --sout '#transcode{acodec=mp3,ab=128,channels=2}:standard{access=http,dst=0.0.0.0:8888/pc.mp3}' – polynomial_donut Nov 4 '18 at 17:10
  • The stream IS directly affected by the volume setting for me. I just plug in my earphones to stop the sound from coming from the laptop. – Rolf Mar 7 at 22:37
  • By the way, how do I stop the lag from lasting like 1/2 hour? – Rolf Mar 7 at 22:46
9
+50

To stream audio output over wifi to your android phone you need to install server software, that sends audio, on PC and client software on Android device. Available options are

WiFi Audio Wireless Speaker

Run WiFi Audio Android App and Press start, you will see IP address of mobile device in the bottom after that run Windows/Linux application and put mobile device's IP address in the IP address field and then press start on PC application. Now all audio coming out from PC will be send to mobile device and you will hear audio on mobile device.
Download

SoundWire

Wirelessly transmit any music or audio from your PC to your Android phone, tablet, or other PCs
Home page Also see

Other useful links
XBMC android SE

  • SoundWire lags by 1-2 sec – Gaurav Gupta Jul 6 '16 at 19:29
  • @gauravgupta No lags if you choice smaller buffer size. Also try to use compression. This worked for me very well. – raacer Sep 18 '16 at 12:22
  • can you put PC application download link of WiFi Audio here? – seyed Jan 10 '17 at 19:01
  • WiFi Audio Wireless Speaker was removed from github and the compiled version in the forums is reported by the users to be a malware. Be careful! Soundwire also looks fishy, from the way it is distributed. – Genom Nov 25 '17 at 0:15
0

For those of you using Soundwire and sending out wifi from your laptop or PCs, using ifconfig MAKE SURE YOU USE THE CORRECT IP ADDRESS. This still works to this day but most Linux distros need a second wifi adapter to send out the wifi and you have to use the one that your Android is connected TO. not the one recieving internet. The one sending it OUT.

i.e. -> If you are using "A" wifi adapter to connect to the internet and "B" to send out wifi from "A", then connect SoundWire on Android to "B" NOT "A".

SoundWire will NOT connect or stream if you connect to the adapter not sending out the wifi so input your IP address into your Andoroid app(s) accordingly, using the terminal command ifconfig accordingly.

Yes there is lag but this app, SoundWire, is the most simple "multi-connect to ip and forget" system out there. No crazy menus to go through. And yes, it does accept more than one connect. I used 2 the other day. It appends the number of devices connected to it in the main window on the device sending out the transmission.

Using this personally as a multi-room/short distance wifi-radio system at my place to this day.

Enjoy.

-4

Wow this is old...

Anyway, use VLC. Pretty GUIs all the way.

  • Fire up VLC on your desktop.
  • Hit Stream, select the file (add how ever many files you want), hit stream.
  • 'Next' if it's all correct.
  • For New Destination select "http" (or whatever you want to use). Select Display locally if you want to play it on the machine you're streaming from too. The next few dialogues are all self-explanatory.

Fire up VLC on your Android device. Hit the icon next to the search button (the arrow pointing to the dot). type in http://<IP ADDRESS O OF THE MACHINE RUNNING VLC>:8080/ for me this was http://xxx.ca:8080/

Tested and working. Now, could one do this in the ancient time of Jun 9'13? Maybe, but I'm too lazy to check VLC's commmit logs ;)

  • 3
    He's not looking for a music/video streaming solution. – Cristian Ciupitu Apr 24 '14 at 18:43

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.