• After 15+ years, we've made a big change: Android Forums is now Early Bird Club. Learn more here.

[How to] Getting audio working inside a chroot

ShapeShifter499

Android Enthusiast
Apr 3, 2015
376
262
Ok so this took me a while to find, because of that I'd like to share how you can get audio working inside a Chroot that's running on your LG Volt. I will not cover how to set up a Linux Chroot but that should be easy if you use "Linux Deploy" from the app store, here.

So some of you might know how a Linux Chroot can headbutt with Android when audio plays but there is a way around it!

Method 1


Pulseaudio allows for internet streaming so you can just stream it locally and because it's local, latency is very low to none. Inside a Chroot you will want to install Pulseaudio and the Alsa-Pulseaudio plugin so apps that need Alsa will still get sound. Next you will want to comment out the following in "/etc/pulse/default.pa"
Code:
.ifexists module-console-kit.so
load-module module-console-kit
.endif
It's not needed and it caused Pulseaudio to quit on my setup. When you have Pulseaudio going you should have a "dummy output" and a "monitor of dummy output", if so run ""pactl load-module module-simple-protocol-tcp rate=48000 format=s16le channels=2 source=auto_null.monitor record=true port=8000 listen=127.0.0.1" to start a new stream, you can change the port to your liking. On the Android side you will want to grab a app that works with Pulseaudio streams, I used "Simple Protocol Player", here. Configure the Android app to point to 127.0.0.1 (loopback IP), change the sample rate to 48000, and use the port you used in the previous command and press the play button. Go back to your Chroot and try to play something, audio should now be working! Theoretically this should work for any Android device that you can run a Chroot on but I just happen to be using a LG Volt. If you want all devices on the same LAN to get the same audio you can remove the "listen" variable from the command above.

Original solution, not by me, found at http://superuser.com/a/750324

Method 2

I found out that "XServer XSDL" from the play store, found here, supports audio output from Pulseaudio. XServer XSDL is basically a port of X11 to your android device in order to display X11 apps from any source locally (like a Chroot) or remote. Pulseaudio in addition to method 1 can pipe audio to a file which XServer XSDL can read and play. To make use of this you will need to create a "tmp" directory under /data/data/x.org.server/files/img/ (or if you are using Link2SD like I am /data/sdext2/data/x.org.server/files/img/). Then symlink or "mount -o bind" the newly created directory to somewhere inside your Chroot directory, in my case I linked it under /mnt/tmp under my Chroot. Inside your Chroot you will want to install Pulseaudio and Alsa-Pulseaudio plugin for any apps that need Alsa.
Next you will want to comment out the following in "/etc/pulse/default.pa"
Code:
.ifexists module-console-kit.so
load-module module-console-kit
.endif
Then add
Code:
load-module module-pipe-sink rate=44100 format=s16le channels=2 file=/path/to/tmp/audio-out
to the bottom of "/etc/pulse/default.pa" replacing "/path/to/tmp/" with wherever you linked the "tmp" folder inside your Chroot and reload the XServer app and your Display Manager (or just restart your Chroot) With any luck audio will play! However unlike method 1 I found you could not multitask otherwise audio stopped playing.

Found out at https://github.com/pelya/xserver-xsdl/issues/25
 
Last edited:
Wow, this is cool! I'm glad I can help out people make more use of their Android devices.
Definitely! :)

For those unfamiliar with running Linux alongside Android and what the possibilities are, here are some of my screen shots and setups from 2011 -

http://androidforums.com/threads/cdma-ubuntu-linux-on-the-3vo.387978/

I used it back when we had fewer alternatives, so I used Open Office and GIMP - but above all, I used it because it was there and I could. :D

If you want to post any inspirational screen shots I'm sure that others would enjoy them - I know I would.

And your post has me looking over my time and space to give this a go again. :)
 
  • Like
Reactions: funkylogik
Upvote 0
Guys, slightly off topic sorry but I think my next purchase is gonna be a mega cheap laptop and I'd like to keep windows on it but use a Linux disk or dongle or whatever.
What are the minimum specs I'm looking at?
I only really plan to use it to mess with my phone lol (unless I catch the bug).
Cheers
The message here is that Linux will even run in a phone.

Your better question is, if I have laptop with XYZ, what's my best Linux option?

The gang over here uses all sorts of distributions and will be glad to help -

http://androidforums.com/threads/the-linux-questions-and-other-stuff-thread.677807/
 
Upvote 0
Nice one thank you compadre.
Ive got a funeral next week and had an expensive night out lastnight (still not slept lol) Anyway the point of all that shit talk is that I won't have cash til next money day so I'll start scoping around the pawn shops tomorrow and start my research tonight.

Need this phone rooted, kingroot rooted it fine and an excellent app removed all the Chinese crap and replaced it with SuperSU but my latest firmware update has broken kingroot :((
(sorry that was way more info than was needed but I'm feeling chatty and new girl is gone :(
So you geeks are my friends. Can't face Facebook with all the talk of death :(
 
  • Like
Reactions: EarlyMon
Upvote 0
Hello, I found another solution for having sound in an Ubuntu Chroot. But I use Complete Linux Installer (linuxonandroid.org), Ubuntu 13.10.LARGE.ext2.v1 Image and MultiVNC-App. I install the Apps and place the Ubuntu-Image in /mnt/extSdCard/Ubuntu. Then I open the Complete Linux Installer App and setup the Image-Path and Resolution and I want to have a Swap-File and an SSH-Server too. Now create a Script like this on your Android:

#!/system/bin/sh

mount -o bind /mnt/extSdCard /data/local/mnt/external_sd
umount /data/local/mnt/proc
mount -t proc proc /data/local/mnt/proc
mount -o bind /dev /data/local/mnt/dev
mount -t devpts devpts /data/local/mnt/dev/pts
umount /data/local/mnt/sys
mount -o bind /sys /data/local/mnt/sys
mount -o bind /sys/fs /data/local/mnt/sys/fs

and save it as "ubuntu.sh". Then when you start or boot Linux open a new window in your Terminal-Emulator and type:

app_114@android:/ $ cd /path/to/your/ubuntu.sh
app_114@android:/ $ su ### i don't know if this is necessary
app_114@android:/ $ sh ubuntu.sh ### WAIT!!!! for this until you see:

root@localhost:/#

in the Linux boot process. When the GUI has started in your VNC-Viewer go to System-Settings->Media->SoundSettings or something like that and you should now see your soundcards and can set their priority and play a testsound.

I think you have to be fast with executing the script; when Linux (GUI) has booted/launched completely, it may not work.

When you shutdown/exit Ubuntu you'll have to restart your phone or try:

app_114@android:/ $ su
app_114@android:/ $ umount /data/local/mnt/*

...or something like that, to unmount Linux filesystem.

I hope this works for you too. Bye! :D
 
Last edited:
  • Like
Reactions: scary alien
Upvote 0

BEST TECH IN 2023

We've been tracking upcoming products and ranking the best tech since 2007. Thanks for trusting our opinion: we get rewarded through affiliate links that earn us a commission and we invite you to learn more about us.

Smartphones