[alsa-devel] [PoC] ahwmon: alsa "hw" what-you-hear recorder

Sergey sergemp at mail.ru
Tue Jan 12 03:21:16 CET 2016


Hello.

I needed a tool to test if anything loud is playing right now. So I wrote
"ahwmon" - alsa hw monitoring tool. It's based on dmix idea: it gets "hw"
shared playback buffer, but reads from the buffer instead of writing.

Code is mostly copied from alsa-lib, but it uses kernel /dev/snd/pcm*
files directly and doesn't depend on alsa-lib or dmix. May work for
other apps playing to "hw", including pulseaudio and jackd.

What do you think about it? Can something like this get into alsa-lib or
alsa-utils or alsa-plugins? It could be a capture side of "dmix" plugin,
which has no capture now. Maybe someone with strong dmix knowledge
can port it to dmix?

Build:
  gcc -o ahwmon ahwmon.c

Usage:
  ./ahwmon [-v] [-v] <card_index> <device_index> [<subdevice_index>]
subdevice 0 is used by default
it outputs .wav stream to stdout

Use cases:
* Card VUmeter:
  ./ahwmon 0 0 | aplay -V stereo -D null
* Dump what you hear:
  ./ahwmon 0 0 > audiodump.wav
* Duplicate output of one card to another:
  ./ahwmon 0 0 | aplay -D plughw:1,0
* Stream what you hear to another pc:
  ./ahwmon 0 0 | nc 192.168.1.10 12345

Known limitations:
* supports S16_LE and S32_LE only.
* breaks clients attempting to close and reopen "hw"

Any ideas are welcome!
-- 
  Sergey
-------------- next part --------------
A non-text attachment was scrubbed...
Name: ahwmon.c
Type: application/octet-stream
Size: 5896 bytes
Desc: not available
URL: <http://mailman.alsa-project.org/pipermail/alsa-devel/attachments/20160112/8471f72b/attachment.obj>


More information about the Alsa-devel mailing list