Pulseaudio/blueman 连接耳机但重启蓝牙后才有声音

Pulseaudio/blueman 连接耳机但重启蓝牙后才有声音

我的蓝牙表现很奇怪。重新启动后,我可以轻松连接耳机,blueman-manager但它们不会出现在声音设置中/pavucontrol并且声音来自扬声器。但是,通过sudo systemctl restart bluetooth耳机重新启动蓝牙后,连接并会以正确的配置文件(A2P 或 HFP)出现在设置中,并且在下次重新启动之前可以正常工作。我花了几个小时搜索整个互联网,并尝试了我以有限的 Linux 知识可以理解的所有可能的解决方案,例如清除和重新安装仅与蓝牙相关的所有内容、删除~/.config/pulsevar/lib/bluetooth一遍又一遍地杀死 pulsaudio、加载和卸载模块等,但没有成功。下面你可能会发现我试图“研究”这种行为的“实验”结果。显然我遇到了很多错误,service bluetooth status但奇怪的是,尽管有这些错误,手机仍能正常工作。

有人知道我的系统可能出了什么问题吗?

重启后加载的模块:

~$ pactl list modules short
0   module-device-restore       
1   module-stream-restore       
2   module-card-restore     
3   module-augment-properties       
4   module-switch-on-port-available     
5   module-switch-on-connect        
6   module-udev-detect      
7   module-alsa-card    device_id="0" name="pci-0000_06_00.1" card_name="alsa_card.pci-0000_06_00.1" namereg_fail=false tsched=yes fixed_latency_range=no ignore_dB=no deferred_volume=yes use_ucm=yes avoid_resampling=no card_properties="module-udev-detect.discovered=1"    
8   module-alsa-card    device_id="2" name="usb-OmniVision_Technologies__Inc._USB_Camera-B4.09.24.1-01" card_name="alsa_card.usb-OmniVision_Technologies__Inc._USB_Camera-B4.09.24.1-01" namereg_fail=false tsched=yes fixed_latency_range=no ignore_dB=no deferred_volume=yes use_ucm=yes avoid_resampling=no card_properties="module-udev-detect.discovered=1"    
9   module-alsa-card    device_id="1" name="pci-0000_08_00.3" card_name="alsa_card.pci-0000_08_00.3" namereg_fail=false tsched=yes fixed_latency_range=no ignore_dB=no deferred_volume=yes use_ucm=yes avoid_resampling=no card_properties="module-udev-detect.discovered=1"    
10  module-bluetooth-policy     
11  module-bluetooth-discover       
12  module-bluez5-discover      
13  module-native-protocol-unix     
14  module-default-device-restore       
15  module-always-sink      
16  module-intended-roles       
17  module-suspend-on-idle      
18  module-systemd-login        
19  module-position-event-sounds        
20  module-role-cork        
21  module-snap-policy      
22  module-filter-heuristics        
23  module-filter-apply 

实验开始

1.耳机(hp)未连接:

~$ sudo systemctl | grep blue*
  sys-devices-pci0000:00-0000:00:01.3-0000:01:00.0-usb1-1\x2d8-1\x2d8:1.0-bluetooth-hci0.device         loaded active plugged   /sys/devices/pci0000:00/0000:00:01.3/0000:01:00.0/usb1/1-8/1-8:1.0/bluetooth/hci0
  sys-subsystem-bluetooth-devices-hci0.device                                                           loaded active plugged   /sys/subsystem/bluetooth/devices/hci0
  bluetooth.service                                                                                     loaded active running   Bluetooth service
  bluez-alsa.service                                                                                    loaded active running   Bluealsa daemon
  bluetooth.target                                                                                      loaded active active    Bluetooth Support

2. 重启蓝牙前连接hp,hp不出现pavucontrol

~$ sudo systemctl | grep blue*
  sys-devices-pci0000:00-0000:00:01.3-0000:01:00.0-usb1-1\x2d8-1\x2d8:1.0-bluetooth-hci0-hci0:1.device  loaded active plugged   /sys/devices/pci0000:00/0000:00:01.3/0000:01:00.0/usb1/1-8/1-8:1.0/bluetooth/hci0/hci0:1
  sys-devices-pci0000:00-0000:00:01.3-0000:01:00.0-usb1-1\x2d8-1\x2d8:1.0-bluetooth-hci0.device         loaded active plugged   /sys/devices/pci0000:00/0000:00:01.3/0000:01:00.0/usb1/1-8/1-8:1.0/bluetooth/hci0
  sys-subsystem-bluetooth-devices-hci0.device                                                           loaded active plugged   /sys/subsystem/bluetooth/devices/hci0
  sys-subsystem-bluetooth-devices-hci0:1.device                                                         loaded active plugged   /sys/subsystem/bluetooth/devices/hci0:1
...

3. hp 断开(由我)

4.hp连接运行后sudo systemctl restart bluetooth,hp首先连接到另一个设备。 HFP 配置文件出现在pavucontrol, 声音作品中

~$ sudo systemctl | grep blue*
  sys-devices-pci0000:00-0000:00:01.3-0000:01:00.0-usb1-1\x2d8-1\x2d8:1.0-bluetooth-hci0-hci0:1.device  loaded active plugged   /sys/devices/pci0000:00/0000:00:01.3/0000:01:00.0/usb1/1-8/1-8:1.0/bluetooth/hci0/hci0:1
  sys-devices-pci0000:00-0000:00:01.3-0000:01:00.0-usb1-1\x2d8-1\x2d8:1.0-bluetooth-hci0-hci0:3.device  loaded active plugged   /sys/devices/pci0000:00/0000:00:01.3/0000:01:00.0/usb1/1-8/1-8:1.0/bluetooth/hci0/hci0:3
  sys-devices-pci0000:00-0000:00:01.3-0000:01:00.0-usb1-1\x2d8-1\x2d8:1.0-bluetooth-hci0.device         loaded active plugged   /sys/devices/pci0000:00/0000:00:01.3/0000:01:00.0/usb1/1-8/1-8:1.0/bluetooth/hci0
  sys-subsystem-bluetooth-devices-hci0.device                                                           loaded active plugged   /sys/subsystem/bluetooth/devices/hci0
  sys-subsystem-bluetooth-devices-hci0:1.device                                                         loaded active plugged   /sys/subsystem/bluetooth/devices/hci0:1
  sys-subsystem-bluetooth-devices-hci0:3.device                                                         loaded active plugged   /sys/subsystem/bluetooth/devices/hci0:3
...

5. hp 断开(由我)

6. hp 在与其他设备断开连接后连接。 A2P配置文件出现在pavucontrol,声音有效。

  sys-devices-pci0000:00-0000:00:01.3-0000:01:00.0-usb1-1\x2d8-1\x2d8:1.0-bluetooth-hci0-hci0:7.device  loaded active plugged   /sys/devices/pci0000:00/0000:00:01.3/0000:01:00.0/usb1/1-8/1-8:1.0/bluetooth/hci0/hci0:4
  sys-devices-pci0000:00-0000:00:01.3-0000:01:00.0-usb1-1\x2d8-1\x2d8:1.0-bluetooth-hci0.device         loaded active plugged   /sys/devices/pci0000:00/0000:00:01.3/0000:01:00.0/usb1/1-8/1-8:1.0/bluetooth/hci0
  sys-subsystem-bluetooth-devices-hci0.device                                                           loaded active plugged   /sys/subsystem/bluetooth/devices/hci0
  sys-subsystem-bluetooth-devices-hci0:4.device                                                         loaded active plugged   /sys/subsystem/bluetooth/devices/hci0:4
...

service bluetooth status实验后对应输出:

~$ service bluetooth status
● bluetooth.service - Bluetooth service
     Loaded: loaded (/lib/systemd/system/bluetooth.service; enabled; vendor preset: enabled)
     Active: active (running) since Fri 2023-01-06 00:11:57 CET; 6min ago
       Docs: man:bluetoothd(8)
   Main PID: 5453 (bluetoothd)
     Status: "Running"
      Tasks: 1 (limit: 38218)
     Memory: 1016.0K
        CPU: 74ms
     CGroup: /system.slice/bluetooth.service
             └─5453 /usr/lib/bluetooth/bluetoothd

Jan 06 00:11:58 Sphex bluetoothd[5453]: Endpoint registered: sender=:1.187 path=/MediaEndpoint/A2DPSource/sbc_xq_552
Jan 06 00:11:58 Sphex bluetoothd[5453]: Endpoint registered: sender=:1.212 path=/org/bluez/hci0/A2DP/LDAC/Source/1
Jan 06 00:11:58 Sphex bluetoothd[5453]: Endpoint registered: sender=:1.212 path=/org/bluez/hci0/A2DP/LDAC/Source/2
Jan 06 00:11:58 Sphex bluetoothd[5453]: Endpoint registered: sender=:1.212 path=/org/bluez/hci0/A2DP/SBC/Source/1
Jan 06 00:11:58 Sphex bluetoothd[5453]: Endpoint registered: sender=:1.212 path=/org/bluez/hci0/A2DP/SBC/Source/2
Jan 06 00:11:58 Sphex bluetoothd[5453]: src/profile.c:ext_start_servers() RFCOMM server failed for Hands-Free Voice gateway: rfcomm_bind: Address already in use (98)
Jan 06 00:11:58 Sphex bluetoothd[5453]: src/adv_monitor.c:btd_adv_monitor_power_down() Unexpected NULL btd_adv_monitor_manager object upon power down
Jan 06 00:12:23 Sphex bluetoothd[5453]: profiles/audio/avdtp.c:avdtp_connect_cb() connect to 1C:6E:4C:83:6D:F2: Connection refused (111)
Jan 06 00:16:56 Sphex bluetoothd[5453]: src/profile.c:ext_io_disconnected() Unable to get io data for Hands-Free Voice gateway: getpeername: Transport endpoint is not connected (107)
Jan 06 00:17:22 Sphex bluetoothd[5453]: /org/bluez/hci0/dev_1C_6E_4C_83_6D_F2/sep1/fd0: fd(41) ready  

pacmd信息

pacmd list-cards
...
    index: 4
    name: <bluez_card.1C_6E_4C_83_6D_F2>
    driver: <module-bluez5-device.c>
    owner module: 25
    properties:
        device.description = "MAJOR IV"
        device.string = "1C:6E:4C:83:6D:F2"
        device.api = "bluez"
        device.class = "sound"
        device.bus = "bluetooth"
        device.form_factor = "headphone"
        bluez.path = "/org/bluez/hci0/dev_1C_6E_4C_83_6D_F2"
        bluez.class = "0x240418"
        bluez.alias = "MAJOR IV"
        device.icon_name = "audio-headphones-bluetooth"
        bluetooth.codec = "sbc"
    profiles:
        a2dp_sink: High Fidelity Playback (A2DP Sink) (priority 40, available: unknown)
        handsfree_head_unit: Handsfree Head Unit (HFP) (priority 30, available: no)
        off: Off (priority 0, available: yes)
    active profile: <a2dp_sink>
    sinks:
        bluez_sink.1C_6E_4C_83_6D_F2.a2dp_sink/#2: MAJOR IV
    sources:
        bluez_sink.1C_6E_4C_83_6D_F2.a2dp_sink.monitor/#4: Monitor of MAJOR IV
    ports:
        headphone-output: Headphone (priority 0, latency offset 0 usec, available: unknown)
            properties:
                
        headphone-input: Bluetooth Input (priority 0, latency offset 0 usec, available: no)
            properties:
pacmd list-sinks
...
 * index: 2
    name: <bluez_sink.1C_6E_4C_83_6D_F2.a2dp_sink>
    driver: <module-bluez5-device.c>
    flags: HARDWARE HW_VOLUME_CTRL LATENCY 
    state: SUSPENDED
    suspend cause: IDLE
    priority: 9950
    volume: front-left: 25802 /  39%,   front-right: 25802 /  39%
            balance 0.00
    base volume: 65536 / 100%
    volume steps: 128
    muted: no
    current latency: 0.00 ms
    max request: 3 KiB
    max rewind: 0 KiB
    monitor source: 4
    sample spec: s16le 2ch 44100Hz
    channel map: front-left,front-right
                 Stereo
    used by: 0
    linked by: 0
    fixed latency: 45.32 ms
    card: 4 <bluez_card.1C_6E_4C_83_6D_F2>
    module: 25
    properties:
        bluetooth.protocol = "a2dp_sink"
        bluetooth.codec = "sbc"
        device.description = "MAJOR IV"
        device.string = "1C:6E:4C:83:6D:F2"
        device.api = "bluez"
        device.class = "sound"
        device.bus = "bluetooth"
        device.form_factor = "headphone"
        bluez.path = "/org/bluez/hci0/dev_1C_6E_4C_83_6D_F2"
        bluez.class = "0x240418"
        bluez.alias = "MAJOR IV"
        device.icon_name = "audio-headphones-bluetooth"
    ports:
        headphone-output: Headphone (priority 0, latency offset 0 usec, available: unknown)
            properties:
                
    active port: <headphone-output>
pacmd list-sources 
...
    index: 4
    name: <bluez_sink.1C_6E_4C_83_6D_F2.a2dp_sink.monitor>
    driver: <module-bluez5-device.c>
    flags: DECIBEL_VOLUME LATENCY 
    state: SUSPENDED
    suspend cause: IDLE
    priority: 1950
    volume: front-left: 65536 / 100% / 0.00 dB,   front-right: 65536 / 100% / 0.00 dB
            balance 0.00
    base volume: 65536 / 100% / 0.00 dB
    volume steps: 65537
    muted: no
    current latency: 0.00 ms
    max rewind: 0 KiB
    sample spec: s16le 2ch 44100Hz
    channel map: front-left,front-right
                 Stereo
    used by: 0
    linked by: 0
    fixed latency: 45.32 ms
    monitor_of: 2
    card: 4 <bluez_card.1C_6E_4C_83_6D_F2>
    module: 25
    properties:
        device.description = "Monitor of MAJOR IV"
        device.class = "monitor"
        device.string = "1C:6E:4C:83:6D:F2"
        device.api = "bluez"
        device.bus = "bluetooth"
        device.form_factor = "headphone"
        bluez.path = "/org/bluez/hci0/dev_1C_6E_4C_83_6D_F2"
        bluez.class = "0x240418"
        bluez.alias = "MAJOR IV"
        device.icon_name = "audio-headphones-bluetooth"

我的系统:

inxi -Fxxxrz
System:
  Kernel: 5.15.0-56-generic x86_64 bits: 64 compiler: gcc v: 11.3.0
    Desktop: Cinnamon 5.6.5 tk: GTK 3.24.33 wm: muffin vt: 7 dm: LightDM 1.30.0
    Distro: Linux Mint 21.1 Vera base: Ubuntu 22.04 jammy
Machine:
  Type: Desktop Mobo: ASUSTeK model: ROG STRIX B450-I GAMING v: Rev 1.xx
    serial: <superuser required> BIOS: American Megatrends v: 4901
    date: 07/25/2022
CPU:
  Info: 8-core model: AMD Ryzen 7 2700X bits: 64 type: MT MCP smt: enabled
    arch: Zen+ rev: 2 cache: L1: 768 KiB L2: 4 MiB L3: 16 MiB
  Speed (MHz): avg: 2142 high: 2849 min/max: 2200/3700 boost: enabled
    cores: 1: 1947 2: 2738 3: 1813 4: 2391 5: 2197 6: 2070 7: 2193 8: 1885
    9: 1747 10: 2849 11: 1810 12: 2174 13: 2196 14: 2187 15: 2194 16: 1887
    bogomips: 118178
  Flags: avx avx2 ht lm nx pae sse sse2 sse3 sse4_1 sse4_2 sse4a ssse3 svm
Graphics:
  Device-1: NVIDIA GP106 [GeForce GTX 1060 3GB] vendor: ZOTAC driver: nvidia
    v: 515.86.01 pcie: speed: 2.5 GT/s lanes: 16 ports: active: none
    off: HDMI-A-1 empty: DP-1, DP-2, DP-3, DVI-D-1 bus-ID: 06:00.0
    chip-ID: 10de:1c02 class-ID: 0300
  Display: x11 server: X.Org v: 1.21.1.3 driver: X: loaded: nvidia
    unloaded: modesetting alternate: fbdev,nouveau,vesa gpu: nvidia
    display-ID: :0 screens: 1
  Screen-1: 0 s-res: 1920x1080 s-dpi: 90 s-size: 542x301mm (21.3x11.9")
    s-diag: 620mm (24.4")
  Monitor-1: HDMI-0 res: 1920x1080 hz: 60 dpi: 90
    size: 544x303mm (21.4x11.9") diag: 623mm (24.5")
  OpenGL: renderer: NVIDIA GeForce GTX 1060 3GB/PCIe/SSE2
    v: 4.6.0 NVIDIA 515.86.01 direct render: Yes
Audio:
  Device-1: NVIDIA GP106 High Definition Audio vendor: ZOTAC
    driver: snd_hda_intel v: kernel pcie: speed: 8 GT/s lanes: 16
    bus-ID: 06:00.1 chip-ID: 10de:10f1 class-ID: 0403
  Device-2: AMD Family 17h HD Audio vendor: ASUSTeK driver: snd_hda_intel
    v: kernel pcie: speed: 8 GT/s lanes: 16 bus-ID: 08:00.3 chip-ID: 1022:1457
    class-ID: 0403
  Device-3: Nam Tai E&E Products or OmniVision Sony Playstation Eye
    type: USB driver: ov534,snd-usb-audio bus-ID: 3-3:4 chip-ID: 1415:2000
    class-ID: 0102
  Sound Server-1: ALSA v: k5.15.0-56-generic running: yes
  Sound Server-2: PulseAudio v: 15.99.1 running: yes
  Sound Server-3: PipeWire v: 0.3.63 running: yes
Network:
  Device-1: Intel I211 Gigabit Network vendor: ASUSTeK driver: igb v: kernel
    pcie: speed: 2.5 GT/s lanes: 1 port: d000 bus-ID: 03:00.0
    chip-ID: 8086:1539 class-ID: 0200
  IF: enp3s0 state: down mac: <filter>
  Device-2: Realtek RTL8822BE 802.11a/b/g/n/ac WiFi adapter vendor: ASUSTeK
    driver: rtw_8822be v: kernel pcie: speed: 2.5 GT/s lanes: 1 port: c000
    bus-ID: 04:00.0 chip-ID: 10ec:b822 class-ID: 0280
  IF: wlp4s0 state: up mac: <filter>
  IF-ID-1: lxcbr0 state: down mac: <filter>
Bluetooth:
  Device-1: ASUSTek Bluetooth Radio type: USB driver: btusb v: 0.8
    bus-ID: 1-8:5 chip-ID: 0b05:185c class-ID: e001 serial: <filter>
  Report: hciconfig ID: hci0 rfk-id: 0 state: up address: <filter>
    bt-v: 2.1 lmp-v: 4.2 sub-v: 705c hci-v: 4.2 rev: ab6b
RAID:
  Device-1: default type: zfs status: ONLINE level: linear raw:
    size: 18.5 GiB free: 18.5 GiB allocated: 1.4 MiB zfs-fs: size: 17.92 GiB
    free: 17.92 GiB
  Components: Online: 1:
Drives:
  Local Storage: total: 1.82 TiB used: 1.23 TiB (67.8%)
  ID-1: /dev/sda vendor: Western Digital model: WD10EZEX-22MFCA0
    size: 931.51 GiB speed: 6.0 Gb/s type: HDD rpm: 7200 serial: <filter>
    rev: 1A01 scheme: MBR
  ID-2: /dev/sdb vendor: Western Digital model: WD10EZEX-00BBHA0
    size: 931.51 GiB speed: 6.0 Gb/s type: HDD rpm: 7200 serial: <filter>
    rev: 1A01
Partition:
  ID-1: / size: 915.82 GiB used: 780.18 GiB (85.2%) fs: ext4 dev: /dev/sda1
Swap:
  ID-1: swap-1 type: file size: 2 GiB used: 0 KiB (0.0%) priority: -2
    file: /swapfile
Sensors:
  System Temperatures: cpu: 36.4 C mobo: N/A gpu: nvidia temp: 34 C
  Fan Speeds (RPM): N/A gpu: nvidia fan: 40%
Repos:
  Packages: 3758 apt: 3688 flatpak: 54 snap: 16
  Active apt repos in: /etc/apt/sources.list.d/additional-repositories.list
    1: deb https://cloud.r-project.org/bin/linux/ubuntu jammy-cran40/
    2: deb http://ftp.halifax.rwth-aachen.de/ubuntu/ focal-backports main restricted universe
  Active apt repos in: /etc/apt/sources.list.d/c2d4u_team-c2d4u4_0_-focal.list
    1: deb http://ppa.launchpad.net/c2d4u.team/c2d4u4.0+/ubuntu jammy main
  Active apt repos in: /etc/apt/sources.list.d/cybermax-dexter-sdl2-backport-focal.list
    1: deb http://ppa.launchpad.net/cybermax-dexter/sdl2-backport/ubuntu jammy main
  Active apt repos in: /etc/apt/sources.list.d/google-earth-pro.list
    1: deb [arch=amd64] http://dl.google.com/linux/earth/deb/ stable main
  No active apt repos in: /etc/apt/sources.list.d/graphics-drivers-ppa-focal.list
  No active apt repos in: /etc/apt/sources.list.d/lutris-team-lutris-focal.list
  Active apt repos in: /etc/apt/sources.list.d/official-package-repositories.list
    1: deb http://packages.linuxmint.com vera main upstream import backport
    2: deb http://archive.ubuntu.com/ubuntu jammy main restricted universe multiverse
    3: deb http://archive.ubuntu.com/ubuntu jammy-updates main restricted universe multiverse
    4: deb http://archive.ubuntu.com/ubuntu jammy-backports main restricted universe multiverse
    5: deb http://security.ubuntu.com/ubuntu/ jammy-security main restricted universe multiverse
  Active apt repos in: /etc/apt/sources.list.d/pipewire-debian-pipewire-upstream-focal.list
    1: deb http://ppa.launchpad.net/pipewire-debian/pipewire-upstream/ubuntu jammy main
  Active apt repos in: /etc/apt/sources.list.d/savoury1-xscreensaver-jammy.list
    1: deb http://ppa.launchpad.net/savoury1/xscreensaver/ubuntu jammy main
  Active apt repos in: /etc/apt/sources.list.d/skype-stable.list
    1: deb [arch=amd64] https://repo.skype.com/deb stable main
  Active apt repos in: /etc/apt/sources.list.d/unit193-encryption-focal.list
    1: deb http://ppa.launchpad.net/unit193/encryption/ubuntu jammy main
    2: deb-src http://ppa.launchpad.net/unit193/encryption/ubuntu jammy main
  Active apt repos in: /etc/apt/sources.list.d/yannubuntu-boot-repair-focal.list
    1: deb http://ppa.launchpad.net/yannubuntu/boot-repair/ubuntu jammy main
  Active apt repos in: /etc/apt/sources.list.d/winehq-focal.sources
    1: deb [arch=amd64 i386] https://dl.winehq.org/wine-builds/ubuntu focal main
  Active apt repos in: /etc/apt/sources.list.d/winehq-jammy.sources
    1: deb [arch=amd64 i386] https://dl.winehq.org/wine-builds/ubuntu jammy main
Info:
  Processes: 452 Uptime: 29m wakeups: 0 Memory: 31.27 GiB
  used: 3.11 GiB (10.0%) Init: systemd v: 249 runlevel: 5 Compilers:
  gcc: 11.3.0 alt: 10/11/9 Shell: Bash v: 5.1.16 running-in: gnome-terminal
  inxi: 3.3.13

答案1

我通过删除 解决了我的蓝牙问题bluez-alsa-utils。不知何故,这个包干扰了pulseaudio。现在我遇到了 PipeWire 错误

“无法连接到 PipeWire:未发现节点工厂”

但只要这不影响声音(它似乎没有影响)我就同意了。

相关内容