1. Are you ready for the Galaxy S20? Here is everything we know so far!

[How to] Getting audio working inside a chroot

Discussion in 'Android Rooting' started by ShapeShifter499, Jun 23, 2015.

  1. ShapeShifter499

    ShapeShifter499 Android Enthusiast
    Thread Starter

    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 (Text):
    1. .ifexists module-console-kit.so
    2. load-module module-console-kit
    3. .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 (Text):
    1. .ifexists module-console-kit.so
    2. load-module module-console-kit
    3. .endif
    Then add
    Code (Text):
    1. 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
     


    #1 ShapeShifter499, Jun 23, 2015
    Last edited: Jun 26, 2015
    SavageRobot and EarlyMon like this.
  2. ShapeShifter499

    ShapeShifter499 Android Enthusiast
    Thread Starter

    If anyone has a better solution please share it
     
  3. EarlyMon

    EarlyMon The PearlyMon
    VIP Member

    This is an outstanding tip for those of who have or want to run Linux with Android, so I've moved it here to our main rooting forum where hopefully others will be encouraged to take the plunge.

    Nicely done. :)
     
    funkylogik likes this.
  4. ShapeShifter499

    ShapeShifter499 Android Enthusiast
    Thread Starter

    Wow, this is cool! I'm glad I can help out people make more use of their Android devices.
     
    funkylogik and EarlyMon like this.
  5. EarlyMon

    EarlyMon The PearlyMon
    VIP Member

    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. :)
     
    funkylogik likes this.
  6. ShapeShifter499

    ShapeShifter499 Android Enthusiast
    Thread Starter

    OP Updated with a extra newly found method of getting audio working
     
    funkylogik and EarlyMon like this.
  7. funkylogik

    funkylogik share the love peeps ;)

    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
     
  8. EarlyMon

    EarlyMon The PearlyMon
    VIP Member

    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/
     
  9. funkylogik

    funkylogik share the love peeps ;)

    Subbed Emon cheers. And how much do these disks or dongles cost (ballpark dollars is fine) ?
    So I just but a cheap as shit used laptop, doesnt matter what version of Windows it's running, ram etc?
     
  10. EarlyMon

    EarlyMon The PearlyMon
    VIP Member

    Linux is free, you download whatever you want and run however you want, the rest you want to ask the gang in the other thread to get a good range of answers.
     
    funkylogik likes this.
  11. funkylogik

    funkylogik share the love peeps ;)

    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 :(
     
    EarlyMon likes this.
  12. EarlyMon

    EarlyMon The PearlyMon
    VIP Member

    Drop me a line if you want - I'll be cleaning some of this in a bit so others can be clear on their Linux needs as well. ;)
     
    funkylogik likes this.
  13. 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
     
    #13 bigbrotheriswatchingyou, Jul 13, 2016
    Last edited: Jul 18, 2016
    scary alien likes this.
Loading...

Share This Page

Loading...