Linuxサウンド周り(関係するビデオ含む)

ALSAとPulseAudio周り
ALSA: Advanced Linux Sound Architecture
- コンシューマ向けサウンドカードから、プロ向けまで対応
- モジュール型のサウンドドライバ
- 古いOSS(Open Sound System)との互換性
- POSIX OS向けサウンドサーバシステム
- サウンドを使うアプリケーションとハードウェアをつなぐ、他の端末への転送、フォーマット変更、ミキシングなどもできる
本来、サウンドアプリケーションは、PulseAudio経由でALSAへつながるのが通常の経路。しかし、ALSAはアプリケーションから呼べるAPIを提供してしまっているため、行儀が悪いアプリが、直接ALSAへアクセスしてしまいPulseAudioと競合してしまうことがある。そのため、PulseAudioはALSAのフリをして、ALSAのAPIを直接叩いているアプリケーションのサウンドリソースを横取りすることができる。

関連コマンド
(arecord, aplay)[http://manpages.ubuntu.com/manpages/bionic/man1/aplay.1.html]
基本的には一緒で、ALSAサウンドカードドライバを使って音声録音再生を行う。aplayは再生に限定。
arecord is a command-line soundfile recorder for the ALSA soundcard driver. It supports
several file formats and multiple soundcards with multiple devices. If recording with
interleaved mode samples the file is automatically split before the 2GB filesize.
aplay is much the same, only it plays instead of recording. For supported soundfile
formats, the sampling rate, bit depth, and so forth can be automatically determined from
the soundfile header.

その他
modprobe
カーネルモジュールのロード、アンロード
Module-aloop
ループバックデバイスドライバ。ALSAでアクセス。
- オープンソースなオーディオI/Fライブラリ。C,C++で書かれていてマルチプラットフォーム対応で、Unix系はOSS/ALSAに対応。これを使う場合はpuseaudio経由ではなさそう
参考

-
V4L2について
ご存じのとおり、Linuxで扱われるデバイスにはデバイスファイル(デバイスノード)と呼ばれる特殊なファイルを通じてアクセスできます。ビデオキャプチャーデバイスは /dev/videoX (XはOSから割り当てられる数字)という名前のファイルになります。ユーザー空間からデバイスファイルを制御するには、open / close / ioctl / mmap などのシステムコールを使っておこないます。これらシステムコールをベースに、デバイスのオープン/クローズ、ビデオ形式の選択、明度の設定、画像入出力方法の選択、実際のデータ入出力ループなどのインターフェースを定義したものが、Video for Linux API version 2(V4L2 API)です。
デバイスファイルを追加してもgetMediaDevicesで取得するDevicesに変化はない。

Chromeで認識されない問題の原因かも
-
This will enable 'exclusive_caps' mode that only reports CAPTURE/OUTPUT capabilities exclusively. The newly created device will announce OUTPUT capabilities only (so ordinary webcam applications (including Chrome) won't see it). As soon as you have attached a producer to the device, it will start announcing CAPTURE capabilities only (so applications that refuse to open devices that have other capabilities apart from capturing can open it too.)
-
v4l2loopback install
sudo apt -y install v4l2loopback-dkms v4l2loopback-utils linux-modules-extra-$(uname -r)