记录到脉冲音频流,并管理流之间的切换

时间:2018-12-21 12:15:17

标签: alsa pulseaudio

我正在尝试与Pulseaudio一起设置声卡配置,但是我不确定alsa的配置是如何完成的。

到目前为止,我可以使用一张卡,并按如下所示选择默认的源和接收器,直到需要将另一种流混合到我的输出中为止。

pacmd set-default-source alsa_input.platform-sound.analog-mono
pacmd set-default-sink alsa_output.platform-sound.analog-mono

现在,我将再使用一张声卡,所以播放-l给出:

**** List of PLAYBACK Hardware Devices ****
card 0: cs42888audio [cs42888-audio], device 0: HiFi cs42888-0 []
  Subdevices: 1/1
  Subdevice #0: subdevice #0
card 1: wm8960audio [wm8960-audio], device 0: HiFi wm8960-hifi-0 []
  Subdevices: 1/1
  Subdevice #0: subdevice #0
card 1: wm8960audio [wm8960-audio], device 1: HiFi-ASRC-FE (*) []
  Subdevices: 1/1
  Subdevice #0: subdevice #0
card 2: amixaudiosai [amix-audio-sai], device 0: HiFi-AMIX-FE (*) []
  Subdevices: 1/1
  Subdevice #0: subdevice #0
card 2: amixaudiosai [amix-audio-sai], device 1: HiFi-AMIX-FE (*) []
  Subdevices: 1/1
  Subdevice #0: subdevice #0

arecord -l给出:

**** List of CAPTURE Hardware Devices ****
card 0: cs42888audio [cs42888-audio], device 0: HiFi cs42888-0 []
  Subdevices: 1/1
  Subdevice #0: subdevice #0
card 1: wm8960audio [wm8960-audio], device 0: HiFi wm8960-hifi-0 []
  Subdevices: 1/1
  Subdevice #0: subdevice #0
card 1: wm8960audio [wm8960-audio], device 1: HiFi-ASRC-FE (*) []
  Subdevices: 1/1
  Subdevice #0: subdevice #0
card 2: amixaudiosai [amix-audio-sai], device 0: HiFi-AMIX-FE (*) []
  Subdevices: 1/1
  Subdevice #0: subdevice #0

pactl列出短接收器

0   alsa_output.platform-sound-amix-sai.analog-mono module-alsa-card.c  s16le 1ch 48000Hz   SUSPENDED
2   alsa_output.platform-sound.analog-mono  module-alsa-card.c  s16le 1ch 48000Hz   SUSPENDED
4   alsa_output.platform-sound-cs42888.analog-surround-51   module-alsa-card.c  s16le 6ch 48000Hz   SUSPENDED
5   my_stream   module-null-sink.c  s16le 2ch 48000Hz   SUSPENDED

pactl列出短来源

0   alsa_output.platform-sound-amix-sai.analog-mono.monitor module-alsa-card.c  s16le 1ch 48000Hz   SUSPENDED
1   alsa_input.platform-sound-amix-sai.analog-mono  module-alsa-card.c  s16le 1ch 48000Hz   SUSPENDED
3   alsa_input.platform-sound-cs42888.analog-mono   module-alsa-card.c  s16le 1ch 48000Hz   SUSPENDED
4   alsa_output.platform-sound.analog-mono.monitor  module-alsa-card.c  s16le 1ch 48000Hz   SUSPENDED
5   alsa_input.platform-sound.analog-mono   module-alsa-card.c  s16le 1ch 48000Hz   SUSPENDED
7   alsa_output.platform-sound-cs42888.analog-surround-51.monitor   module-alsa-card.c  s16le 6ch 48000Hz   SUSPENDED
8   my_stream.monitor   module-null-sink.c  s16le 2ch 48000Hz   SUSPENDED

我想使用CS42888设备并设置如下配置:

alsa_input.platform-sound-cs42888.analog-mono (Radio)
(Rate 48000, S16_LE)
|
>    alsa_input.platform-sound.analog-mono (Microphone)
|          |
|          >    alsa_input.a2dp_source (Bluetooth Audio, if available)
|          |         |
|          |         |   
|          |         |      System sounds
|          |         |            |
|          |         |            >
|          |         |            |
|          |         >            |
|          |         |            |
-----------switching stream--------
     |
     |
     >
     |
     |
alsa_output.platform-sound-cs42888.analog-mono
(Rate 48000, S16_LE)
(profile: output:analog-mono+input:analog-mono)

换句话说,我想获得Radio输入,并能够在必要时在系统声音的基础上进行流传输。另外,我想在pulseaudio中实现这一点,因为蓝牙音频和其他内容是使用pulseaudio(module-bluez5-device)进行管理的。

我可以成功录制并播放广播输入,如下所示:

arecord -Dplug:hw:cs42888audio -f S16_LE -r 48000 test.wav
aplay -Dplug:hw:cs42888audio -f S16_LE test.wav

如何使用Pulseaudio设置这种配置?我想记录到流,然后管理流之间的切换。预先感谢。

0 个答案:

没有答案