ALSA 常用command

aplay/arecord:

playback:

aplay -D default xxx.wav

list cards & devices:

aplay -l

record:

aplay -C -D defaut -d 10 -f S16_LE -r 48000 -c 2 -t wav xxx.wav

arecord -D defaut -d 10 -f S16_LE -r 48000 -c 2 -t wav xxx.wav

amixer:

show all controls for given card:

amixer -c 0 controls

amixer -Dhw:2 controls

get control contents for one control:

amixer -c 2 cget numid=1

set control contents for one control:

amixer -c 0 cset numid=1,iface=MIXER,name="Master Volume" 50

amixer -c 0 cset name="Master Volume" 50 

/proc

list cards:

cat /proc/asound/cards

list devices:

cat /proc/asound/devices

ls -l /dev/snd

list pcm:

cat /proc/asound/pcm

list  all devices for given card:

ls -l /proc/asound/card0

list information for given card & pcm & substream

cat /proc/asound/card0/pcm0p/sub0/info

card*/pcm*/info

The general information of this PCM device: card #, device #, substreams, etc.
card*/pcm*/xrun_debug

This file appears when CONFIG_SND_DEBUG=y and CONFIG_PCM_XRUN_DEBUG=y. This shows the status of xrun (= buffer overrun/xrun) and invalid PCM position debug/check of ALSA PCM middle layer. It takes an integer value, can be changed by writing to this file, such as:

# echo 5 > /proc/asound/card0/pcm0p/xrun_debug

The value consists of the following bit flags:

  • bit 0 = Enable XRUN/jiffies debug messages
  • bit 1 = Show stack trace at XRUN / jiffies check
  • bit 2 = Enable additional jiffies check

When the bit 0 is set, the driver will show the messages to kernel log when an xrun is detected. The debug message is shown also when the invalid H/W pointer is detected at the update of periods (usually called from the interrupt handler).

When the bit 1 is set, the driver will show the stack trace additionally. This may help the debugging.

Since 2.6.30, this option can enable the hwptr check using jiffies. This detects spontaneous invalid pointer callback values, but can be lead to too much corrections for a (mostly buggy) hardware that doesn’t give smooth pointer updates. This feature is enabled via the bit 2.

card*/pcm*/sub*/info
The general information of this PCM sub-stream.
card*/pcm*/sub*/status
The current status of this PCM sub-stream, elapsed time, H/W position, etc.
card*/pcm*/sub*/hw_params
The hardware parameters set for this sub-stream.
card*/pcm*/sub*/sw_params
The soft parameters set for this sub-stream.
card*/pcm*/sub*/prealloc
The buffer pre-allocation information.
card*/pcm*/sub*/xrun_injection
Triggers an XRUN to the running stream when any value is written to this proc file. Used for fault injection. This entry is write-only.
 
原文地址:https://www.cnblogs.com/fellow1988/p/12397629.html