目前存在三種藍牙音頻系統:
- A2DP (advanced audio distribution) 提供了音樂級立體聲輸出(sink),通常不支持輸入(source)。
- A2DP 可以使用很多中編碼格式。標準的 SBC 質量和壓縮比的處理不是很好,而更好的開源替代(LDAC, AptX)被廣泛使用。
- AVRCP 在 A2DP 上層提供播放控制。
- HFP/HSP (hands-free/headset) 體用了語音級單聲道輸入和輸出。HFP 是基於 HSP 的,在上層工作。
- LE Audio 是低功耗音頻標準,於2020 年發布。標準編碼格式是 LC3。
內核、BlueZ 5 和 PipeWire 支持上述三種配置。PulseAudio 和 ALSA等老的聲音伺服器僅支持 A2DP 和 HFP/HSP。儘管藍牙的不穩定已經臭名昭著[1], 最近藍牙軟體棧已經有了很大提升,所以使用常見硬體,比如 Intel 藍牙晶片的時候,痛苦大大減輕了。
通過 Pipewire 連接耳機
PipeWire 提供簡單易用的藍牙耳機配置方式,可以無縫替換 PulseAudio。PipeWire 內置了對 A2DP 的支持,可以使用 SBC/SBC-XQ、AptX、LDA 及 AAC 藍牙音頻編碼,同時也支持 HFP/HSP 藍牙音頻協議。
安裝軟體包 pipewire-pulse包 (將會替代 pulseaudio包 和 pulseaudio-bluetooth包)。
守護程序將會自動啟動用戶服務。請使用 pavucontrol包 或桌面環境提供的「設置」應用程式設置 PipeWire。更多信息請查看 PipeWire#Bluetooth devices。
Troubleshooting
由於耳機和PipeWire之間的同步,音頻音量高
Since version 0.3.26, PipeWire uses "hardware volume" to link the volume of the headphones with the system, making it impossible to change one without the other. On some devices, this may result in the lowest possible volume being uncomfortably loud, and volume controls becoming too coarse. Hardware volume can be disabled using either WirePlumber or Pipewire Media Session.
Using WirePlumber
If it doesn't exist, create the directory /etc/wireplumber/bluetooth.lua.d/
to disable hardware volume system-wide, or ~/.config/wireplumber/bluetooth.lua.d
to disable it only for your user. Then, copy /usr/share/wireplumber/bluetooth.lua.d/50-bluez-config.lua
to the directory you created. Edit the file, and change the line
--["bluez5.enable-hw-volume"] = true
to
["bluez5.enable-hw-volume"] = false
Restart the system or the PipeWire services for the changes to take effect.
Using Pipewire Media Session
If it doesn't exist, create the directory /etc/pipewire/media-session.d/
to disable hardware volume system-wide, or ~/.config/pipewire/media-session.d/
to disable it only for your user. Then, copy /usr/share/pipewire/media-session.d/bluez-monitor.conf
to the directory you created. Edit the file, and add the line
bluez5.enable-hw-volume = false
Restart the system or the PipeWire services for the changes to take effect.
通過 Bluez5/PulseAudio 連接藍牙耳機
安裝軟體包 pulseaudio-alsa包、pulseaudio-bluetooth包、bluez-utils包。其中 bluez-utils包 提供了 bluetoothctl
工具。
通過命令行進行設置
啟動 bluetooth.service
。
現在我們可以使用 bluetoothctl 命令行工具來配對、連接藍牙。關於 bluetoothctl 的更多詳細信息請查看藍牙。
運行以下命令進入 bluetooth 命令環境:
$ bluetoothctl
然後輸入:
[bluetooth]# power on [bluetooth]# agent on [bluetooth]# default-agent [bluetooth]# scan on
現在讓你的藍牙耳機進入配對模式,它應該很快就能被發現。如:
[NEW] Device 00:1D:43:6D:03:26 Lasmex LBT10
這裡發現了一個名字是"Lasmex LBT10",對應 MAC 地址是00:1D:43:6D:03:26的設備。接下來我們使用這個MAC地址來配對:
# pair 00:1D:43:6D:03:26
配對成功後,你需要顯式地連接設備。
(如果不起效,請嘗試在連接藍牙設備之前先使用 trust
命令)
# [bluetooth]# connect 00:1D:43:6D:03:26
如果出現連接錯誤 org.bluez.Error.Failed
,先停止現存的 PulseAudio daemon 再重試:
$ pulseaudio -k [bluetooth]# connect 00:1D:43:6D:03:26
最後,如果希望將來自動連接此設備:
[bluetooth]# trust 00:1D:43:6D:03:26
如果一切正常,可以在PulseAudio中看到一個獨立的輸出設備。
現在可以通過pavucontrol包的"Playback"和"Pecording"標籤頁重定向音頻的輸入、輸出了。
現在可以禁用藍牙發現新設備並退出此程序:
[bluetooth]# scan off [bluetooth]# exit
設置自動連接
若要自動連接藍牙耳機,需要啟用 PulseAudio 的 switch-on-connect 模塊。請添加以下幾行到 /etc/pulse/default.pa
:
/etc/pulse/default.pa
### Automatically switch to newly-connected devices load-module module-switch-on-connect
通過 GNOME Bluetooth 進行設置
可以使用 GNOME Bluetooth 作為一個圖形化前端來簡單地配置你的藍牙耳機。
首先,確保 bluetooth.service
systemd 單元正在運行。
打開 GNOME Bluetooth,開啟藍牙、掃描設備、在設備列表中選擇藍牙設備進行連接。可以在設備配置菜單中直接進入聲音控制面板中。當設備已連接後,聲音控制面板中將會出現一個新的播放設備。
LDAC/aptX 編碼
PulseAudio 15.0 已經支持 LDAC/aptX 藍牙音頻編碼,通過下列代碼進行檢查:
$ pactl list | grep a2dp_codec
常見問題及解決方案
音質差/底噪/聲音渾濁
如果音質很差,很可能是因為你的耳機沒有被正確配置。 查看 #在 HSP/HFP 和 A2DP 配置間切換來解決這個問題。
If you suspect the bad sound quality is due to a poor bluetooth connection, you might compensate for it by switching to a lower bit-rate and lower audio quality codec such as SBC or aptX using pactl
:
$ pactl send-message /card/bluez_card.XX_XX_XX_XX_XX_XX/bluez switch-codec '"sbc"'
where a list of available codecs can be obtained by:
$ pactl send-message /card/bluez_card.XX_XX_XX_XX_XX_XX/bluez list-codecs
已經選擇音頻配置,但耳機沒有激活,不能重定向音頻
音頻配置的菜單項在設備還沒有成功連接的時候就已經存在了,但它並不能起作用。這個菜單項似乎是在設備被發現的時候就馬上創建了。
確認一下 bluetoothctl
是以 root 權限運行;然後手動連接設備。有配置選項可以避免每次都需要手動連接,但是配對和信任並不會導致自動連接。
授權失敗導致配對失敗
如果配對失敗,可以嘗試禁用 SSPMode:
# btmgmt ssp off
或
# btmgmt ssp on
運行這個命令時,可能需要關閉藍牙。
配對成功, 但連接失敗
可能在 bluetoothctl 裡面看到下面的錯誤:
[bluetooth]# connect 00:1D:43:6D:03:26 Attempting to connect to 00:1D:43:6D:03:26 Failed to connect: org.bluez.Error.Failed
你可以查看 bluetooth.service
的單元狀態或通過以下命令查看日誌以進一步定位問題:
# journalctl -n 20
你可能會在日誌裡看到下面類似的信息:
bluetoothd[5556]: a2dp-sink profile connect failed for 00:1D:43:6D:03:26: Protocol not available
這是因為沒有安裝pulseaudio-bluetooth包 包導致的。 如果確實沒有安裝,安裝一下這個包,然後重啟一下PulseAudio。
問題也可能由權限問題引發。如果 root 用戶可以連接藍牙設備而普通用戶不可,請將你的用戶添加到 lp 用戶組,再重啟 pulseaudio。
參考:/etc/dbus-1/system.d/bluetooth.conf
。
如果不是因為缺失包導致的, 很可能是PulseAudio沒收到消息,一般重啟一下PulseAudio就可以解決問題。 注意bluetoothctl和PulseAudio不需要在相同的用戶下運行,bluetooth在root環境下運行,而PulseAudio在用戶環境下運行也可以很好的工作。 重啟PulseAudio後,不需要重新配對,直接重連即可。
如果重啟PulseAudio後,仍然不能正常工作,你需要重新加載 module-bluetooth-discover 模塊。
# pactl load-module module-bluetooth-discover
你可以把同樣的加載命令添加到 /etc/pulse/default.pa
,讓PulseAudio啟動時自動加載。
如果仍然不能正常工作,或者你使用的是系統級別的PulseAudio,下面的模塊也需要加載一下(同樣可以把他們加到 default.pa
或 system.pa
裡面):
module-bluetooth-policy module-bluez5-device module-bluez5-discover
也可能是因為 /var/lib/bluetooth/
缺少寫權限。可以通過移除再重新配對設備來使其工作,但重啟後問題會再次出現。恢復寫權限會修復問題:
# chmod -R u+w /var/lib/bluetooth
連接成功,但聲音播放總有小雜音
如果藍牙與 WiFi 設備為同一個硬體,這非常有可能發生。因為它們共享了同一個天線甚至是頻段(2.4GHz)。儘管在 Windows 上它們可以共同工作,但在 Linux上不行。
一個可能的解決方案是讓 WiFi 工作在 5 GHz,從而使得它們不會互相干擾。如果網卡/路由器不支持 5GHz WiFi,可以升級 WiFi 固件或驅動。這個方法對 Realtek 8723BE 配合最新版 rtl 驅動(AUR)有效。
如果難以使用以上方法,一個不那麼有效的方法是在 PulseAudio 輸出端優化信號元包大小與延遲時長來試圖補償信號干擾問題。需要選擇合適的參數值大小,因為這有可能使得音畫不同步。若要設置更改藍牙耳機的延時(以更改到125000微秒為例):
$ pactl set-port-latency-offset <bluez_card> headset-output 125000
其中藍牙驅動器的ID號可以通過如下命令獲得:
$ pacmd list-sinks | egrep -o 'bluez_card[^>]*'
元包大小可以在配置文件 /etc/pulse/daemon.conf
中設定,重啟 PulseAudio 生效。更多信息請參考 PulseAudio/Troubleshooting#Setting the default fragment number and buffer size in PulseAudio
對於某些特定的藍牙適配器,添加 options ath9k btcoex_enable=1
到 /etc/modprobe.d/ath9k.conf
中可能會有幫助
/etc/modprobe.d/ath9k.conf
# possibly fix for sound glitches options ath9k btcoex_enable=1
之後重啟 PulseAudio 服務。
連接成功,但無法播放聲音
確定你在系統日誌裡面可以看到如下信息:
bluetoothd[5556]: Endpoint registered: sender=:1.83 path=/MediaEndpoint/A2DPSource bluetoothd[5556]: Endpoint registered: sender=:1.83 path=/MediaEndpoint/A2DPSink
如果你可以看到類似的信息,說明藍牙沒有問題,你可以去檢查PulseAudio的配置問題了。否則的話,退回來再次確認藍牙是否已經連接成功。
如果使用的是GDM, PulseAudio 的另外一個實例可能已經啟動,並且「捕獲」了你的藍牙連接。這種情況可以通過屏蔽GDM用戶的pulseaudio socket來解決:
# mkdir -p /var/lib/gdm/.config/systemd/user # ln -s /dev/null /var/lib/gdm/.config/systemd/user/pulseaudio.sockett
重啟電腦後,PulseAudio的第二個實例將不再啟動。
bluez 可能會錯誤地認為某個藍牙耳機不兼容 A2DP。這種情況下,首先確定藍牙設備的標號:
$ pacmd ls
在輸出中應當會有一段關於藍牙耳機的內容,類似於:
$ pacmd ls
index: 2 name: <bluez_card.XX_XX_XX_XX_XX_XX> driver: <module-bluez5-device.c> owner module: 27 properties: device.description = "SONY MDR-100ABN" device.string = "XX:XX:XX:XX:XX:XX" device.api = "bluez" device.class = "sound" ...
若要手動更改配置文件,運行以下命令:
$ pacmd set-card-profile 2 a2dp_sink
其中 2 是通過 pacmd ls
得到的設備標號。
連接成功,聲音播放正常,但播放暫停後再繼續就會播放卡頓
如果原先聲音播放正常,但藍牙連接空閒後再恢復播放就會出現卡頓/高延遲/無聲,可以嘗試禁用 PulseAudio 的音源/音響空閒自動掛起功能。這是由 module-suspend-on-idle
模塊控制的。
若要禁用 module-suspend-on-idle
,將配置文件中的以下行注釋掉:
~/.config/pulse/default.pa
### Automatically suspend sinks/sources that become idle for too long #load-module module-suspend-on-idle
之後,重啟 PulseAudio。
UUIDs has unsupported type
在配對的時候,你可能會在bluetoothctl看到如下信息:
[CHG] Device 00:1D:43:6D:03:26 UUIDs has unsupported type
這種情況很常見,沒有影響,可以被忽略。
PC 上顯示設備已經配對,但外設端無法識別 PC
這也許是因為設備不支持 Bluetooth LE 配對。
嘗試在 /etc/bluetooth/main.conf
中設置 ControllerMode = bredr
。
更多信息查看此連結[3](關於 Bose QC 35)
設備連接成功,但隨即斷連
如果你的設備藍牙連接失敗或很快斷連,並且在日誌 (systemd/Journal) 中看到了如下內容:
bluetoothd: Unable to get connect data for Headset Voice gateway: getpeername: Transport endpoint is not connected (107) bluetoothd: connect error: Connection refused (111)
這有可能是因為你已經在本電腦的藍牙適配器上用其他作業系統配對了此藍牙設備。有些設備不能處理來自同一 MAC 地址(例如:同一藍牙適配器)的多次配對。你可以通過重新配對來修復問題:
$ bluetoothctl [bluetooth]# devices Device XX:XX:XX:XX:XX:XX My Device [bluetooth]# remove XX:XX:XX:XX:XX:XX
之後,重啟 bluetooth.service
,開啟藍牙適配器並處於可被發現模式,重新掃描、重新配對。對於某些藍牙管理程序,你可能需要重啟電腦來從頭進行設備掃描。
Apple Airpods 聲音小
創建一個 bluetooth.service
的 drop-in file,添加以下內容:
/etc/systemd/system/bluetooth.service.d/noplugin-avrc.conf
[Service] ExecStart= ExecStart=/usr/lib/bluetooth/bluetoothd --noplugin=avrcp
之後,重啟 bluetooth.service
,重新載入(reload)其配置文件,重新連接耳機。
另外,對於 Airpods Pro,請禁用空間音頻功能,開啟單聲道模式(使用iPhone進行設置)。
Apple AirPods Pro 無法在 HSP/HFP 配置模式下工作,可以在 A2DP 配置模式下工作
如果 Airpods Pro 可以與 PluseAudio 正常工作,但無法兼容 HSP/HFP 配置模式(在 pavucontrol 的 Configurations 標籤也下,通常被表明「不可用」),請嘗試換用 pipewire-pulse包。
請注意,換用 pipewire-pulse(並重啟電腦或某些 systemd service)後,HSP/HFP 應當可以使用了。但這也可能導致 A2DP 不可用(當選擇為 A2DP sink 時,立即被取消選擇,並選擇到"OFF"模式)。遇到這個問題,請嘗試刪除/重命名 /var/lib/bluetooth
文件夾:
# mv /var/lib/bluetooth /var/lib/bluetooth.bak
重新配對你的藍牙設備後,所有的配置模式理論上都應當可用了。你可以使用pavucontrol 或 pacmd 進行選擇。
HSP 問題:藍牙音頻源與播放設備都正常,但聲音信號沒有被在兩者間正確傳輸
可能缺少某些固件或 SCO (audio protocol of HSP and HFP) 路由配置錯誤。
請查看[4]。
BCM20702 所需固件:bcm20702a1-firmwareAUR or bcm20702b0-firmwareAUR.
Error: Failed to start discovery org.bluez.Error.InProgress
如果你的耳機可被發現,但由於 "Failed to start discovery org.bluez.Error.InProgress" 錯誤無法連接,請安裝軟體包 bluez-hciconfigAUR 並運行如下命令:
$ hciconfig hciX up $ hciconfig hciX reset
其中 X 是你電腦的藍牙適配器的標號(通常為 0)
之後應當就可以進行設備連接了。參考以下步驟:#通過命令行進行設置.
High audio volume due to synchronization between headphones and PulseAudio
As of PulseAudio 15, "Absolute Volume" interlocks the audio volume of your headphones with PulseAudio, making it impossible to change one without the other. On some headphones, e.g. on the Hoco W25, this may result in irritating loudness. To disable "Absolute Volume", edit /etc/pulse/default.pa
and change the line
load-module module-bluetooth-discover
to
load-module module-bluetooth-discover avrcp_absolute_volume=false
在 HSP/HFP 和 A2DP 配置間切換
通過下面命令可以很容易的在兩者間做切換:
$ pacmd set-card-profile card_number a2dp_sink
其中 card_number
可以通過 pacmd list-cards
命令獲得。
For enabling automatic profile switching from A2DP to HSP when a recording stream appears without any role set, you can append auto_switch=2
to load-module module-bluetooth-policy
in /etc/pulse/default.pa
.
更多關於 PulseAudio 配置的說明請參考 PulseAudio 文檔。
PulseAudio 下 A2DP 不能工作
Socket Interface problem
對於 bluez 4.1+, PulseAudio 3.0+,若 PulseAudio 無更改到 A2DP 配置模式,你可以嘗試禁用 Socket interface from /etc/bluetooth/audio.conf
。在此文件中將行 Enable=Socket
改為 Disable=Socket
。
A2DP sink profile 不可用
當 A2DP 播放設備配置(A2DP sink profile) 不可用時,你無法將 PluseAudio 切換到 A2DP 輸出,甚至 A2DP 播放設備不會被列出。可以通過 pactl
來確定是否是這種情況:
$ pactl list | grep -C2 A2DP Profiles: headset_head_unit: Headset Head Unit (HSP/HFP) (sinks: 1, sources: 1, priority: 30, available: yes) a2dp_sink: High Fidelity Playback (A2DP Sink) (sinks: 1, sources: 0, priority: 40, available: no) off: Off (sinks: 0, sources: 0, priority: 0, available: yes) Active Profile: headset_head_unit
無法通過 pacmd
手動設置音效卡配置
$ pacmd set-card-profile bluez_card.C4_45_67_09_12_00 a2dp_sink Failed to set card profile to 'a2dp_sink'.
對於 10.0 版本的 PulseAudio,當你通過 Bluedevil 或其他 BlueZ 前端連接藍牙耳機時,這個問題可能會出現。
在第一次通過某些藍牙控制器(例如0a12:0001, Cambridge Silicon Radio
)與耳機配對時,這個問題同樣可能出現。這些藍牙控制器默認使用 Handsfree
或 Headset - HS
service,並且不允許切換到需要使用 AudioSink
service 的 A2DP PulseAudio 音頻播放設備。
可能的解決方案:
- 對於某些耳機,連接成功後在藍牙耳機段調整音量或播放/暫停音樂可能會觸發 A2DP 配置,使其可用
- 使用 bluez-utils包 軟體包中的
bluetoothctl
連接藍牙耳機可能會使 A2DP 播放配置可用。fix-bt-a2dpAUR 可以在藍牙設備連接後自動完成這一過程。詳細使用方法請看[5]。
[bluetooth]# connect headset_MAC_address
- 手動切換到藍牙的
AudioSink
service 可能會使 A2DP 配置文件與 A2DP PulseAudio 播放設備可用。blueman包 軟體包中的 blueman-manager 可以幫你完成這一過程。你也可以使用bluetoothctl
中註冊 AudioSink service 的 UUID:
$ bluetoothctl [bluetooth]# menu gatt [bluetooth]# register-service 0000110b-0000-1000-8000-00805f9b34fb [bluetooth]# quit
- 禁用藍牙耳機的配置文件
/etc/bluetooth/main.conf
[General] Disable=Headset
- 啟用多配置文件模式。這可以使得藍牙耳機同時支持 A2DP 以及 HSP/HFP
/etc/bluetooth/main.conf
[General] MultiProfile=multiple
- 有時以上方法都無效。你可能已經嘗試過重啟電腦、開關藍牙。此時可以嘗試重啟
bluetooth.service
。
$ sudo systemctl restart bluetooth.service
- 你也可以嘗試將 pulseaudio-bluetooth包 替換為 pulseaudio-modules-btAUR[損壞的連結:package not found] 或 pulseaudio-modules-bt-gitAUR[損壞的連結:package not found]。後兩者提供了更多的藍牙編碼,這可能有助於解決問題。
Gnome with GDM
The instructions below were tested on Gnome 3.24.2 and PulseAudio 10.0 however they may still be applicable and useful for other versions.
If PulseAudio fails when changing the profile to A2DP while using GNOME with GDM, you need to prevent GDM from starting its own instance of PulseAudio:
- Prevent Pulseaudio clients from automatically starting a server if one is not running by adding the following:
/var/lib/gdm/.config/pulse/client.conf
autospawn = no daemon-binary = /bin/true
- Prevent systemd from starting Pulseaudio anyway with socket activation:
$ sudo -ugdm mkdir -p /var/lib/gdm/.config/systemd/user $ sudo -ugdm ln -s /dev/null /var/lib/gdm/.config/systemd/user/pulseaudio.socket
- Restart, and check that there is no PulseAudio process for the
gdm
user using:
$ pgrep -u gdm pulseaudio
Further discussion about this problem and alternative fixes can be found at [6] and [7]. Alternatively, one may try and install fix-bt-a2dpAUR.
HFP not working with PulseAudio
HFP-only bluetooth headsets may not be usable in the standard configuration of PulseAudio. The respective profiles occur, but they are not available:
-
bluetoothctl info
output shows:
UUID: Audio Sink (0000110b-0000-1000-8000-00805f9b34fb) UUID: A/V Remote Control Target (0000110c-0000-1000-8000-00805f9b34fb) UUID: A/V Remote Control (0000110e-0000-1000-8000-00805f9b34fb) UUID: Handsfree (0000111e-0000-1000-8000-00805f9b34fb)
-
pactl list
of respective device shows:
... Profiles: ... headset_head_unit: Headset Head Unit (HSP/HFP) (sinks: 1, sources: 1, priority: 30, available: no)
To solve the respective issue, update to pulseaudio (>=13) and potentially pulseaudio-modules-bt-gitAUR[損壞的連結:package not found] and bluez (>=5.5) to latest versions. Then install ofonoAUR (start and enable using systemctl) and phonesimAUR and create / activate a fake modem as described here [8]:
- Create
/etc/ofono/phonesim.conf
with:
[phonesim] Address=127.0.0.1 Driver=phonesim Port=12345
- Start as user:
$ phonesim -p 12345 /usr/share/phonesim/default.xml &
$ dbus-send --print-reply --system --dest=org.ofono /phonesim org.ofono.Modem.SetProperty string:"Powered" variant:boolean:true
- Activate modem:
$ dbus-send --print-reply --system --dest=org.ofono /phonesim org.ofono.Modem.SetProperty string:"Online" variant:boolean:true
- If you want to check the results of this, download ofono git sources ([9]) and call
list-modems
from theofono/test
directory. The output of the respective modem section should read like this:
... [ /phonesim ] Online = 1 Powered = 1 Lockdown = 0 Emergency = 0 Manufacturer = MeeGo ...
- Finally, restart pulseaudio and reconnect headset. Now, HFP should be available:
headset_head_unit: Headset Head Unit (HSP/HFP) (sinks: 1, sources: 1, priority: 30, available: yes)
Disable auto switching headset to HSP/HFP
When using a bluetooth headset that supports multiple profiles, some applications switch to HSP/HFP profile automatically. If this behaviour is undesired you can disable this by appending the auto_switch=false parameter to the bluetooth-policy module:
/etc/pulse/default.pa
load-module module-bluetooth-policy auto_switch=false
Disable PipeWire HSP/HFP profile
Unlike PulseAudio, PipeWire does not automatically switch between A2DP and HSP/HFP in response to input events. However, rather than to enable automatically switching to the (lower audio quality) HSP/HFP profile if A2DP fails, you may prefer to disable the former altogether. To do so, create or edit a bluez configuration as shown below.
/etc/wireplumber/wireplumber.conf.d/50-bluez.conf (or ~/.config/wireplumber/wireplumber.conf.d/50-bluez.conf)
monitor.bluez.rules = [ { matches = [ { ## This matches all bluetooth devices. device.name = "~bluez_card.*" } ] actions = { update-props = { bluez5.auto-connect = [ a2dp_sink ] bluez5.hw-volume = [ a2dp_sink ] } } } ] monitor.bluez.properties = { bluez5.roles = [ a2dp_sink ] bluez5.hfphsp-backend = "none" }
Alternative: A2DP duplex channel
FastStream, AptX LL, and "Opus 05 Pro" (a pipewire invention) have a "duplex" channel that allows for sending microphone audio back without needing to go into HSP/HFP and tolerate the sound quality degradation. PipeWire, but not PulseAudio, has support for this feature. Support is automatic upon feature detection. Interaction with existing profile switcher (WirePlumber) is unknown.
Tips and tricks
獲取藍牙耳機的電池電量
若要獲取藍牙耳機的剩餘電量並將其提供給 upower包,需要啟動守護程序 bluetoothd 的試驗性功能,方法如下:
建立一個 bluetooth.service
的替換單元文件(replacement unit file),在 ExecStart
行後添加 -E
。這之後重新啟動 bluetooth.service
。
媒體播放控制
媒體控制信號需要被轉發給 MPRIS,並被支持 MPRIS 的媒體播放器所獲取,來實現外部播放控制。詳細信息請查看 MPRIS#Bluetooth。
AVRCP Media controls
This may be desired for bluetooth headsets with overly sensitive touch controls, and AVRCP playback controls can be disabled through the inhibited
sysfs file corresponding to the virtual AVRCP input device, for example /sys/devices/virtual/input/input877/inhibited
. The correct virtual input can be identified via the name
attribute, /sys/devices/virtual/input/input877/name
, which may for example be "Soundcore Life P3 (AVRCP)". Echoing 1
to this file inhibits/disables AVRCP, and echoing 0
re-enables it. This can be changed dynamically at runtime without restarting bluetoothd or disconnecting your device.
This will be reset on device disconnect and reconnect, so it is likely desired to automatically set it via a udev rule such as:
SUBSYSTEM=="input" ATTR{name}=="Soundcore Life P3 (AVRCP)" ATTR{inhibited}="1"
If you want to be able to change this attribute as a regular user, see udev#Allowing regular users to use devices
See also
Using the same device on Windows and Linux without pairing the device over and over again