Ubuntu音频输入输出控制

在使用程序调用音频设备的时候可能会出现无法播放音频,或者无法使用麦克风的问题。需要进行音频输入输出的检测,然后根据情况选中默认的音频设备。

1、查看输出、输出音频的控制

1. 查看音频设备
如果你的系统有 /proc/asound/cards 路径,说明 ALSA 驱动已经使用上,可查看 sound devices。
执行以下命令可看到当前的音频设备。

$ cat /proc/asound/cards
 0 [tegrahdaxnx    ]: tegra-hda-xnx - tegra-hda-xnx
                      tegra-hda-xnx at 0x3518000 irq 65
 1 [jetsonxaviernxa]: jetson-xaviernx - jetson-xaviernx-ape
                      jetson-xaviernx-ape
 2 [ArrayUAC10     ]: USB-Audio - ReSpeaker 4 Mic Array (UAC1.0)
                      SEEED ReSpeaker 4 Mic Array (UAC1.0) at usb-3610000.xhci-2.1, full speed

或者使用如下命令

cat /proc/asound/devices
$ ll /proc/asound/
total 0
dr-xr-xr-x   5 root root 0 1115 17:41 ./
dr-xr-xr-x 306 root root 0 11  1970 ../
lrwxrwxrwx   1 root root 5 1115 18:27 ArrayUAC10 -> card2/
dr-xr-xr-x   6 root root 0 1115 18:27 card0/
dr-xr-xr-x  42 root root 0 1115 18:27 card1/
dr-xr-xr-x   4 root root 0 1115 18:27 card2/
-r--r--r--   1 root root 0 1115 18:27 cards
-r--r--r--   1 root root 0 1115 18:27 devices
-r--r--r--   1 root root 0 1115 18:27 hwdep
lrwxrwxrwx   1 root root 5 1115 18:27 jetsonxaviernxa -> card1/
-r--r--r--   1 root root 0 1115 18:27 pcm
lrwxrwxrwx   1 root root 5 1115 18:27 tegrahdaxnx -> card0/
-r--r--r--   1 root root 0 1115 18:27 timers
-r--r--r--   1 root root 0 1115 18:27 version

2. 查看音频的输入输出

#查看所有的音频输入
arecord -l
#录制音频 ,10S
arecord -d 10 /tmp/t.wav
#查看所有的音频输出
aplay -l
#播放
aplay a.wav

2. 设置默认的音频设备

2、查看输入音频的控制

3、注意事项

1) 普通用户开通所有串口的方法

Linux下的设备使用都需要使用sudo或root用户才能打开,为了能让普通用户也能使用串口,
可以增加udev规则来实现,具体方法如下(配置完成后,重启服务器):

sudo vim /etc/udev/rules.d/70-ttyusb.rules
增加如下内容:
KERNEL=="ttyUSB[0-9]*",MODE="0666"
2) java无法调用音频流的问题

Put this text in the file /etc/systemd/system/pulseaudio.service:

[Unit]
Description=PulseAudio system server
# DO NOT ADD ConditionUser=!root

[Service]
Type=notify
Exec=pulseaudio --daemonize=no --system --realtime --log-target=journal
Restart=on-failure

[Install]
WantedBy=multi-user.target

This unit file is a straightforward method that starts PulseAudio and makes sure it is running.

Now enable and start this unit file by running the following commands:

systemctl --system enable --now pulseaudio.service

It should be running now. You can check the status of the service with the command:

systemctl --system status pulseaudio.service

解决ubuntu无法使用音频的问题

  • 0
    点赞
  • 5
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值