Grabbing a screenshot from an Android device via adb

This blog entry has a very neat way of grabbing screenshots from Android mobile devices. It boils down to a one liner (reproduced here just in case that blog vanishes for some reason and so it’s easy to find):

adb shell screencap -p | sed 's/\r$//' > screen.png

on Linux and

adb shell screencap -p | perl -pe 's/x0Dx0A/x0A/g' > screen.png

on the Mac.

Works perfectly. Thanks!

Finding PCM audio devices in C/C++ on the BeagleBone Black (and other embedded Linux systems)

Finding PCM audio devices using the ALSA interface from software isn’t always completely trivial. On some builds for the BeagleBone Black, PCM audio devices appear as /dev/audio, /dev/audio1 etc. But this doesn’t seem to be generally true. Plus, this doesn’t definitively identify which device is which. A good way to find out is to open the pseudo file /proc/asound/pcm as it lists all the PCM devices in the system. To see what’s currently active, just cat the pseudo file:

UbuntuDev$ cat /proc/asound/pcm
 00-00: ALC889 Analog : ALC889 Analog : playback 1 : capture 1
 00-01: ALC889 Digital : ALC889 Digital : playback 1
 00-02: ALC889 Analog : ALC889 Analog : capture 2
 00-03: HDMI 0 : HDMI 0 : playback 1
 01-00: USB Audio : USB Audio : capture 1
 02-03: HDMI 0 : HDMI 0 : playback 1
 02-07: HDMI 0 : HDMI 0 : playback 1
 02-08: HDMI 0 : HDMI 0 : playback 1
 02-09: HDMI 0 : HDMI 0 : playback 1

The first two numbers are the plughw card and device numbers. So, if you wanted to connect to the USB audio source for example, you could do:

snd_pcm_open (&m_handle, "plughw:1,0", SND_PCM_STREAM_CAPTURE, 0);