如何从 Ubuntu 到 AirPlay 2 扬声器播放音频?

如何从 Ubuntu 到 AirPlay 2 扬声器播放音频?

我有一个 Ubuntu 20.10 和一对凯夫LSX我想使用 Apple AirPlay 2 连接。我设法使用 Windows 10 上的 iTunes 和我的 iPhone 8 来完成此操作,两者都与我的 Ubuntu 位于同一 LAN 中。对于Ubuntu我用过PulseAudio 首选项帕普夫斯) 启用使可发现的 Apple AirTunes 声音设备在本地可用(通过创建链接解决了相关错误sudo ln -sv '/usr/lib/pulse-15.0+dfsg1' /usr/lib/pulse-15.0)。 Ubuntu 可以很好地检测到扬声器,但是在播放任何内容时我没有声音,并且日志中出现以下错误:

Unexpected/Unhandled response: RTSP/1.0 403 Forbidden
Unexpected/Unhandled response: Content-Length: 0
Unexpected/Unhandled response: Server: AirTunes/366.0
Unexpected/Unhandled response: CSeq: 3

为什么会发生这种情况以及我应该采取什么措施来解决它?

$pacmd list sinks

2 sink(s) available.
    index: 1
    name: <alsa_output.pci-0000_00_1f.3.analog-stereo>
    driver: <module-alsa-card.c>
    flags: HARDWARE HW_MUTE_CTRL HW_VOLUME_CTRL DECIBEL_VOLUME LATENCY DYNAMIC_LATENCY
    state: IDLE
    suspend cause: (none)
    priority: 9039
    volume: front-left: 45080 /  69% / -9.75 dB,   front-right: 45080 /  69% / -9.75 dB
            balance 0.00
    base volume: 65536 / 100% / 0.00 dB
    volume steps: 65537
    muted: no
    current latency: 1999.62 ms
    max request: 344 KiB
    max rewind: 344 KiB
    monitor source: 1
    sample spec: s16le 2ch 44100Hz
    channel map: front-left,front-right
                 Stereo
    used by: 0
    linked by: 0
    configured latency: 2000.00 ms; range is 0.50 .. 2000.00 ms
    card: 0 <alsa_card.pci-0000_00_1f.3>
    module: 5
    properties:
        alsa.resolution_bits = "16"
        device.api = "alsa"
        device.class = "sound"
        alsa.class = "generic"
        alsa.subclass = "generic-mix"
        alsa.name = "ALC1220 Analog"
        alsa.id = "ALC1220 Analog"
        alsa.subdevice = "0"
        alsa.subdevice_name = "subdevice #0"
        alsa.device = "0"
        alsa.card = "0"
        alsa.card_name = "HDA Intel PCH"
        alsa.long_card_name = "HDA Intel PCH at 0x6001110000 irq 140"
        alsa.driver_name = "snd_hda_intel"
        device.bus_path = "pci-0000:00:1f.3"
        sysfs.path = "/devices/pci0000:00/0000:00:1f.3/sound/card0"
        device.bus = "pci"
        device.vendor.id = "8086"
        device.vendor.name = "Intel Corporation"
        device.product.id = "a348"
        device.product.name = "Cannon Lake PCH cAVS"
        device.form_factor = "internal"
        device.string = "front:0"
        device.buffering.buffer_size = "352800"
        device.buffering.fragment_size = "176400"
        device.access_mode = "mmap+timer"
        device.profile.name = "analog-stereo"
        device.profile.description = "Analog Stereo"
        device.description = "Built-in Audio Analog Stereo"
        module-udev-detect.discovered = "1"
        device.icon_name = "audio-card-pci"
    ports:
        analog-output-lineout: Line Out (priority 9000, latency offset 0 usec, available: yes)
            properties:
                
        analog-output-headphones: Headphones (priority 9900, latency offset 0 usec, available: no)
            properties:
                device.icon_name = "audio-headphones"
    active port: <analog-output-lineout>
  * index: 2
    name: <raop_output.LSX-02869F.local>
    driver: <module-raop-sink.c>
    flags: NETWORK HW_MUTE_CTRL HW_VOLUME_CTRL LATENCY 
    state: IDLE
    suspend cause: (none)
    priority: 0
    volume: front-left: 65536 / 100%,   front-right: 65536 / 100%
            balance 0.00
    base volume: 65536 / 100%
    volume steps: 65537
    muted: no
    current latency: 0.00 ms
    max request: 1 KiB
    max rewind: 0 KiB
    monitor source: 2
    sample spec: s16le 2ch 44100Hz
    channel map: front-left,front-right
                 Stereo
    used by: 0
    linked by: 0
    fixed latency: 250.00 ms
    card: 1 <raop_client._192.168.1.252__7000>
    module: 10
    properties:
        device.string = "[192.168.1.252]:7000"
        device.description = "LSX 02869F"
        device.model = "LSX"
        device.icon_name = "audio-card"
    ports:
        network-output: [192.168.1.252]:7000 (priority 0, latency offset 0 usec, available: unknown)
            properties:
                
    active port: <network-output>

答案1

对我来说,在 Raspberry Pi 4 Model B Rev 1.4 上,https://github.com/juhovh/shairplay作品。

克隆,构建项目,然后复制服务文件:

sudo cp -v /home/gigi/compile/shairplay/shairplay.service /etc/systemd/system/ && sudo chown root: /etc/systemd/system/shairplay.service && sudo chmod 664 /etc/systemd/system/shairplay.service && sudo systemctl daemon-reload

确保将 airport.key 复制到根目录:

sudo cp -v /home/gigi/compile/shairplay/airport.key /

启动服务:

sudo systemctl start shairplay

我注意到启动/重新启动我的 Raspberry Pi 后该服务根本无法工作;发出命令sudo systemctl restart shairplay可以解决问题。

相关内容