There's big file with ext2 with ARM Debian where I can chroot to.

There's functional mplayer (I can -ao pcm or -vo yuv4mpegpipe) there.

How to record/play sound (or video) from this Debian? Is there things that emulate ALSA/OSS/Whatever to use usual linux programs and android ones side by side? May be there's pulseaudio server for android?


I managed to make it sound by writing to /dev/msm_pcm_out:

mplayer something.mp3 -ao pcm:file=/dev/msm_pcm_out

Sound is choppy and it looks hacky in general.

Video output is something like -vo fbdev:/dev/graphics/fb0.


Not all Androids may have a PCM output device in /dev, as Vi0's answer requires.

A more general solution is to setup Pulse to stream system audio to a TCP port on your device. Then you can use Simple Protocol Player or PulseDroid in your Android environment to play the stream.

To eliminate chop/lag in VLC, MPlayer, and Audacity, it was necessary for me to choose ALSA as the output device and Pulse as the mixer (in these programs' options).

Steps I used on my Amazon Fire 7" 2015 / CM12 / Debian Wheezy chroot:

  1. Install pulseaudio in the chroot: sudo apt-get install pulseaudio.
  2. As suggested by a comment on meefik's github, I removed the line load-module module-console-kit from the file /etc/pulse/default.pa.
  3. Run pactl list | grep 'Name\|Description' and identify a module that monitors system audio. I successfully used 'Dummy Output Monitor' named auto_null.monitor.
  4. Write a corresponding shell script pashare as follows (credit to AlexAndersan on SuperUser):
case "$1" in
        $0 stop
        pulseaudio --start
        pactl load-module module-simple-protocol-tcp rate=44100 format=s16le channels=2 source=auto_null.monitor record=true port=8000
        killall pulseaudio
        pactl unload-module `pactl list | grep tcp -B1 | grep M | sed 's/[^0-9]//g'`
        echo "Usage: $0 start|stop" >&2

Make sure the rate and port arguments match your settings in Simple Protocol Player (on the Android side). PulseDroid demands rate=48000, which means higher throughput, and could possibly introduce chop/lag.

I added the pulseaudio --start and killall lines because pulse would not start automatically in my chroot.

  1. Make the script executable and run it:
chmod 755 pashare
sudo mv pashare /usr/local/bin/
pashare start
  1. Configure your chroot media players to output to ALSA, with Pulse mixer. I had to set this manually, to eliminate choppy audio:

    • VLC: In Tools->Preferences->Audio, set Output module: ALSA audio output, and Device: Playback/recording through the PulseAudio sound server.

    • GNOME MPlayer: In Edit->Preferences->Player, set Audio Output: ALSA.

  2. In Android, start Simple Protocol Player or PulseDroid on IP address (loopback) and set the other option(s) to match your pashare script.

Note that Android treats the app like a music player, and will kill it if another app tries to play music, or if it decides to free up the CPU. There are probably workarounds for this.

  • Is it only about playing or also about recording?
    – Vi0
    Jul 26 '16 at 10:34
  • @Vi0, this also worked for [limited] recording within the chroot... just select ALSA in Audacity's input pop-up. It'll record whatever's playing through alsa.
    – user140691
    Jul 26 '16 at 11:46
  • I had trouble with e.g. Freeciv using this answer, because it uses SDL for audio which seems to auto-select the pulse driver (not alsa), and there's no way to configure that w/o recompiling.....
    – user140691
    Jul 26 '16 at 11:50

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.