This applies to Kubuntu 13.10, other distros should be similar.
A while ago I had the laptop on in the kitchen whilst I did chores. The only issue I had was that I was making so much noise I couldn’t hear the movie. I knew I could play audio mobile -> PC over Bluetooth; but was it possible to do it the other way? i.e. could my phone become a poor-man’s Bluetooth headset? (I could keep the phone in my pocket and use headphones).
The short answer for Bluetooth is “No, not going to happen”. I don’t quite understand why, but that seems to be the case. Luckily GNU/Linux scoffs in the face of such limitations and there are two ways to achieve the desired result, although not using Bluetooth.
Whichever one you go with, there will be a short audio delay. This is fine if you are out of the room or not looking at the screen, but if you are watching a video you will need to play with the video delay to adjust the perceived audio back into sync. The delay is around 2-4 seconds depending on hardware etc.
Option 1 – VLC
Install VLC and then list your PulseAudio sinks:
pacmd list-sinks
You are looking for whatever PulseAudio is currently throwing the audio to, mine looked like this:
* index: 0 name: <alsa_output.pci-0000_00_1b.0.analog-stereo> driver: <module-alsa-card.c> flags: HARDWARE HW_MUTE_CTRL HW_VOLUME_CTRL DECIBEL_VOLUME LATENCY DYNAMIC_LATENCY
Take that name without chevrons and get VLC to stream it over HTTP as a file (the example below uses freedom-hating MP3).
cvlc -vvv pulse://alsa_output.pci-0000_00_1b.0.analog-stereo.monitor --sout \
'#transcode{acodec=mpga,ab=128,channels=2}:standard{access=http,dst=0.0.0.0:8080/pc.mp3}
Then just point your media player to the URL https://you.pc.ip.addy:8080/pc.mp3 and enjoy.
More details: https://sandalov.org/blog/1441/
Option 2 – Rygel
The next involves using a full DLNA server, getting PulseAdio to pass the sound to that and then streaming to a client. This is a slightly longer process than the above, but gives you more features (you can stream other content too). Rather than re-invent the wheel, read the notes below and then follow the steps here: https://wiki.gnome.org/Projects/Rygel/Pulseaudio
Notes:
- You must install gstream1.0-pulseaudio or it won’t work. I don’t know why they missed that out.
- You will probably need to to the whole “GstLaunch” thing, I did.
- Once GstLaunch is installed, you don’t actually need to select “Create separate audio device for DLNA/UPnP media streaming” in paprefs (although it is handy for directing audio to DLNA-only); simply modify the rygel.conf file to use the sink name detailed in the VLC section.
- If you do go for a separate DLNA audio device, remember to open pavucontrol and direct the desired stream to it otherwise your client will only play silence.
Leave a Reply
You must be logged in to post a comment.