如何使用 PulseAudio 将蓝牙输入连接到 Hifiberry

如何使用 PulseAudio 将蓝牙输入连接到 Hifiberry

我使用 HiFiBerry AMP2 将 2 个传统扬声器连接到 Raspberry Pi 3。这在 Volumio 上工作得很好。现在我想更进一步:我不想使用 Volumio,而是想使用 Raspberry PI 作为我的 Echo Dot 的扬声器,这样我就可以使用语音控制在该设置上播放 TuneIn 广播。

我选择使用 Raspberry OS 32 位 Bullseye + PulseAudio v34,并使用了几个博客和教程才到达现在的位置,但我卡在了最后一步。

有效的方法:

  • HiFiBerry AMP2 运行良好 - 已通过 Volumio 测试
  • 我可以用 mplayer 播放一首歌曲
  • 我的手机可以连接到 Pi 并显示它可以用于音频但是:当手机通过蓝牙连接并且我播放 Spotify 时,我在扬声器上听不到它的声音,只是一片寂静。

以下是有关我的设置的一些信息:

当电话接通时,我看到 2 个来源,均已暂停:

pactl list cards
Card #0
    Name: alsa_card.platform-soc_sound
    Driver: module-alsa-card.c
    Owner Module: 7
    Properties:
            alsa.card = "1"
            alsa.card_name = "snd_rpi_hifiberry_dacplus"
            alsa.long_card_name = "snd_rpi_hifiberry_dacplus"
            alsa.driver_name = "snd_soc_hifiberry_dacplus"
            device.bus_path = "platform-soc:sound"
            sysfs.path = "/devices/platform/soc/soc:sound/sound/card1"
            device.form_factor = "internal"
            device.string = "1"
            device.description = "Built-in Audio"
            module-udev-detect.discovered = "1"
            device.icon_name = "audio-card"
    Profiles:
            output:stereo-fallback: Stereo Output (sinks: 1, sources: 0, priority: 5100, available: yes)
            output:multichannel-output: Multichannel Output (sinks: 1, sources: 0, priority: 100, available: yes)
            off: Off (sinks: 0, sources: 0, priority: 0, available: yes)
    Active Profile: output:stereo-fallback
    Ports:
            analog-output: Analog Output (type: Analog, priority: 9900, latency offset: 0 usec, availability unknown)
                    Part of profile(s): output:stereo-fallback

Card #3
    Name: bluez_card.F4_12_B9_FA_D2_E1
    Driver: module-bluez5-device.c
    Owner Module: 30
    Properties:
            device.description = "MyPhone"
            device.string = "A4:75:B9:64:A0:B7"
            device.api = "bluez"
            device.class = "sound"
            device.bus = "bluetooth"
            device.form_factor = "phone"
            bluez.path = "/org/bluez/hci0/dev_F4_12_B9_FA_D2_E1"
            bluez.class = "0x5a020c"
            bluez.alias = "MyPhone"
            device.icon_name = "audio-card-bluetooth"
    Profiles:
            a2dp_source: High Fidelity Capture (A2DP Source) (sinks: 0, sources: 1, priority: 20, available: yes)
            headset_audio_gateway: Headset Audio Gateway (HSP/HFP) (sinks: 1, sources: 1, priority: 10, available: yes)
            off: Off (sinks: 0, sources: 0, priority: 0, available: yes)
    Active Profile: a2dp_source
    Ports:
            phone-output: Phone (type: Phone, priority: 0, latency offset: 0 usec, availability unknown)
                    Part of profile(s): headset_audio_gateway
            phone-input: Phone (type: Phone, priority: 0, latency offset: 0 usec, availability unknown)
                    Part of profile(s): a2dp_source, headset_audio_gateway

pactl list sources
Source #0
    State: SUSPENDED
    Name: alsa_output.platform-soc_sound.stereo-fallback.monitor
    Description: Monitor of Built-in Audio Stereo
    Driver: module-alsa-card.c
    Sample Specification: s16le 2ch 44100Hz
    Channel Map: front-left,front-right
    Owner Module: 7
    Mute: no
    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
    Monitor of Sink: alsa_output.platform-soc_sound.stereo-fallback
    Latency: 0 usec, configured 0 usec
    Flags: DECIBEL_VOLUME LATENCY
    Properties:
            device.description = "Monitor of Built-in Audio Stereo"
            device.class = "monitor"
            alsa.card = "1"
            alsa.card_name = "snd_rpi_hifiberry_dacplus"
            alsa.long_card_name = "snd_rpi_hifiberry_dacplus"
            alsa.driver_name = "snd_soc_hifiberry_dacplus"
            device.bus_path = "platform-soc:sound"
            sysfs.path = "/devices/platform/soc/soc:sound/sound/card1"
            device.form_factor = "internal"
            device.string = "1"
            module-udev-detect.discovered = "1"
            device.icon_name = "audio-card"
    Formats:
            pcm

Source #4
    State: SUSPENDED
    Name: bluez_source.F4_12_B9_FA_D2_E1.a2dp_source
    Description: MyPhone
    Driver: module-bluez5-device.c
    Sample Specification: s16le 2ch 44100Hz
    Channel Map: front-left,front-right
    Owner Module: 30
    Mute: no
    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
    Monitor of Sink: n/a
    Latency: 0 usec, configured 0 usec
    Flags: HARDWARE DECIBEL_VOLUME LATENCY
    Properties:
            bluetooth.protocol = "a2dp_source"
            device.description = "MyPhone"
            device.string = "A4:75:B9:64:A0:B7"
            device.api = "bluez"
            device.class = "sound"
            device.bus = "bluetooth"
            device.form_factor = "phone"
            bluez.path = "/org/bluez/hci0/dev_F4_12_B9_FA_D2_E1"
            bluez.class = "0x5a020c"
            bluez.alias = "MyPhone"
            device.icon_name = "audio-card-bluetooth"
    Ports:
            phone-input: Phone (type: Phone, priority: 0, availability unknown)
    Active Port: phone-input
    Formats:
            pcm


pactl list sinks
Sink #0
    State: SUSPENDED
    Name: alsa_output.platform-soc_sound.stereo-fallback
    Description: Built-in Audio Stereo
    Driver: module-alsa-card.c
    Sample Specification: s16le 2ch 44100Hz
    Channel Map: front-left,front-right
    Owner Module: 7
    Mute: no
    Volume: front-left: 13107 /  20% / -41.94 dB,   front-right: 13107 /  20% / -41.94 dB
            balance 0.00
    Base Volume: 65536 / 100% / 0.00 dB
    Monitor Source: alsa_output.platform-soc_sound.stereo-fallback.monitor
    Latency: 0 usec, configured 0 usec
    Flags: HARDWARE DECIBEL_VOLUME LATENCY
    Properties:
            alsa.resolution_bits = "16"
            device.api = "alsa"
            device.class = "sound"
            alsa.class = "generic"
            alsa.subclass = "generic-mix"
            alsa.name = "HiFiBerry DAC+ HiFi pcm512x-hifi-0"
            alsa.id = "HiFiBerry DAC+ HiFi pcm512x-hifi-0"
            alsa.subdevice = "0"
            alsa.subdevice_name = "subdevice #0"
            alsa.device = "0"
            alsa.card = "1"
            alsa.card_name = "snd_rpi_hifiberry_dacplus"
            alsa.long_card_name = "snd_rpi_hifiberry_dacplus"
            alsa.driver_name = "snd_soc_hifiberry_dacplus"
            device.bus_path = "platform-soc:sound"
            sysfs.path = "/devices/platform/soc/soc:sound/sound/card1"
            device.form_factor = "internal"
            device.string = "hw:1"
            device.buffering.buffer_size = "10576"
            device.buffering.fragment_size = "2644"
            device.access_mode = "mmap"
            device.profile.name = "stereo-fallback"
            device.profile.description = "Stereo"
            device.description = "Built-in Audio Stereo"
            module-udev-detect.discovered = "1"
            device.icon_name = "audio-card"
    Ports:
            analog-output: Analog Output (type: Analog, priority: 9900, availability unknown)
    Active Port: analog-output
    Formats:
            pcm


aplay -l
**** List of PLAYBACK Hardware Devices ****
card 0: vc4hdmi [vc4-hdmi], device 0: MAI PCM i2s-hifi-0 [MAI PCM i2s-hifi-0]
  Subdevices: 1/1
  Subdevice #0: subdevice #0
card 1: sndrpihifiberry [snd_rpi_hifiberry_dacplus], device 0: HiFiBerry DAC+ HiFi
pcm512x-hifi-0 [HiFiBerry DAC+ HiFi pcm512x-hifi-0]
  Subdevices: 1/1
  Subdevice #0: subdevice #0

我注意到:

  • 我很惊讶地看到来源也提到了 HiFiBerry
  • 许多博客都提到了 a2dp 配置文件,但我只看到 a2dp_source 配置文件
  • 为什么是源 #4?我尝试连接/断开连接几次。我应该做一些清理吗?

我尝试过但没有效果的方法:

  • 我尝试将源直接连接到接收器:pactl load-module module-loopback source=bluez_source.F4_12_B9_FA_D2_E1.a2dp_source sink=alsa_output.platform-soc_sound.stereo-fallback
  • 我在 /etc/pulse/default.pa 文件中设置了默认源和接收器

关于我能做什么,还有其他建议吗?感觉我快到了,但还没有……

谢谢!

相关内容