ubuntu升级到20.04后没有声音

ubuntu升级到20.04后没有声音

sudo alsa force-reload在我只看到虚拟输出之前,我必须让我的系统检测到我的声卡。但每次我重新启动时,我都必须再次执行此操作。我已经尝试重新安装 alsa-base 。

编辑: sudo systemctl status alsa-restore.service 返回:

● alsa-restore.service - Save/Restore Sound Card State
 Loaded: loaded (/lib/systemd/system/alsa-restore.service; static; vendor preset: enabled)
 Active: active (exited) since Wed 2020-10-07 17:23:42 CEST; 1min 19s ago
   Docs: man:alsactl(1)
Process: 1285 ExecStartPre=/bin/mkdir -p /run/alsa (code=exited, status=0/SUCCESS)
Process: 1319 ExecStart=/usr/sbin/alsactl -E HOME=/run/alsa -E XDG_RUNTIME_DIR=/run/alsa/runtime restore (code=exited, status=99)
Main PID: 1319 (code=exited, status=99)

Okt 07 17:23:42 PhilippN-Vostro-5490 alsactl[1319]: Found hardware: "sof-hda-dsp" "Realtek ALC3204" "HDA:8086280b,80860101,00100000 HDA:10ec0236,10280959,00100002 cfg-dmics:2" "" ""
Okt 07 17:23:42 PhilippN-Vostro-5490 alsactl[1319]: Hardware is initialized using a generic method
Okt 07 17:23:42 PhilippN-Vostro-5490 systemd[1]: Starting Save/Restore Sound Card State...
Okt 07 17:23:42 PhilippN-Vostro-5490 systemd[1]: Finished Save/Restore Sound Card State.

编辑2: journalctl -b | grep alsa返回:

Nov 05 16:44:28 Vostro-5490 systemd-udevd[586]: controlC0: Process '/usr/sbin/alsactl -E HOME=/run/alsa -E XDG_RUNTIME_DIR=/run/alsa/runtime restore 0' failed with exit code 99.
Nov 05 16:44:29 Vostro-5490 alsactl[1353]: alsa-lib parser.c:2157:(load_toplevel_config) Unable to find the top-level configuration file '/usr/share/alsa/ucm2/ucm.conf'.
Nov 05 16:44:29 Vostro-5490 alsactl[1353]: alsa-lib main.c:997:(snd_use_case_mgr_open) error: failed to import hw:0 use case configuration -2
Nov 05 16:44:29 Vostro-5490 alsactl[1353]: Found hardware: "sof-hda-dsp" "Realtek ALC3204" "HDA:8086280b,80860101,00100000 HDA:10ec0236,10280959,00100002 cfg-dmics:2" "" ""
Nov 05 16:44:29 Vostro-5490 alsactl[1353]: Hardware is initialized using a generic method

答案1

选项1

在使用下面的自定义服务之前,alsa 重新加载配置的方式是通过在启动时运行的 systemd(以重新加载配置)和关机时运行的systemd 检查是否/var/lib/alsa/asound.state存在以及其中包含什么(声音设备列表) 。alsa-restore.service以保留您最后的配置)

必须首先检查该特定服务是否存在

sudo systemctl status alsa-restore.service

并且状态应该报告

alsa-restore.service - Save/Restore Sound Card State
     Loaded: loaded (/lib/systemd/system/alsa-restore.service; static; vendor preset: enabled)
     Active: active (exited) since Sun 2020-09-27 11:43:13 EDT; 5h 43min ago
       Docs: man:alsactl(1)
   Main PID: 755 (code=exited, status=0/SUCCESS)
      Tasks: 0 (limit: 11833)
     Memory: 0B
     CGroup: /system.slice/alsa-restore.service

Sep 27 11:43:13 FOOT systemd[1]: Starting Save/Restore Sound Card State...
Sep 27 11:43:13 FOOT systemd[1]: Finished Save/Restore Sound Card State.

位于的 alsa-restore.service/lib/systemd/system/alsa-restore.service应该如下所示:


#
# Note that two different ALSA card state management schemes exist and they
# can be switched using a file exist check - /etc/alsa/state-daemon.conf .
#

[Unit]
Description=Save/Restore Sound Card State
Documentation=man:alsactl(1)
ConditionPathExists=!/etc/alsa/state-daemon.conf
ConditionPathExistsGlob=/dev/snd/control*
After=alsa-state.service

[Service]
Type=oneshot
RemainAfterExit=true
ExecStart=-/usr/sbin/alsactl -E HOME=/run/alsa -E XDG_RUNTIME_DIR=/run/alsa/runtime restore
ExecStop=-/usr/sbin/alsactl -E HOME=/run/alsa -E XDG_RUNTIME_DIR=/run/alsa/runtime store

如果此服务存在,但被禁用,您可以启用并启动它

sudo systemctl enable alsa-restore.service
sudo systemctl start alsa-restore.service

如果sudo systemctl status alsa-restore.service在其状态中报告一些导致其失败的其他错误,则可能需要首先解决。



选项2

After double-checkingalsa force-reload不是一次性命令包装器,alsactl而是负责重新启动相应的 alsa 服务,这分两步进行,首先停止,然后再次启动。

总结一下,sudo alsa force-reload如下

  1. 检查是否可以找到该命令alsactl,如果没有则立即退出
  2. 运行位于该处的脚本/usr/share/alsa/utils.sh,除其他外还提供一些索引功能。
  3. 检查是否 /var/lib/alsa/asound.state存在
  4. 运行alsactl -E HOME="$ALSACTLHOME" -E XDG_RUNTIME_DIR="${ALSACTLRUNTIME}" restore $CARD >/dev/null 2>&1以恢复在中找到的每张卡的卷状态asound.state

步骤 #4 正是alsa-restore.service在正确操作下启动和关闭时执行的操作,因此所有问题都表明它被禁用或根本不存在。

我们已经知道它alsactl存在于您的系统上,因为alsa force-reload它有效,但是下次重新启动并且音频不会自动重新加载时,alsa force-reload请尝试从终端运行,而不是使用 :

sudo /usr/sbin/alsactl -E HOME=/run/alsa -E XDG_RUNTIME_DIR=/run/alsa/runtime restore

如果此命令恢复您的音频,那么这就是您希望在启动时作为服务运行的内容(及其相应的版本也在关闭时运行)。

因此,如果alsa-restore.service您的系统上不存在,您应该并且只能myaudio.service像这样创建自己的:

sudo nano /etc/systemd/system/myaudio.service

将以下内容复制到其中:

[Unit]
Description=Start Audio
ConditionPathExists=!/etc/alsa/state-daemon.conf


[Service]
Type=oneshot
ExecStart=-/usr/sbin/alsactl -E HOME=/run/alsa -E XDG_RUNTIME_DIR=/run/alsa/runtime restore
ExecStop=-/usr/sbin/alsactl -E HOME=/run/alsa -E XDG_RUNTIME_DIR=/run/alsa/runtime store
RemainAfterExit=true


[Install]
WantedBy=sound.target

保存它,然后:

sudo systemct enable myaudio.service 
sudo systemctl start myaudio.service 
sudo systemctl status myaudio.service

这将启用、启动并报告新服务的状态。如果 3 个命令完成且没有错误,则可以重新启动并测试它。

答案2

此消息“code=exited,status=99”可能是由于不是音频组的成员。

sudo usermod -a -G 音频用户名

然后重新启动并检查:

日志ctl -b | grep 阿尔萨

相关内容