You are not logged in.

#1 2023-11-18 11:45:46

spasoff
Member
From: Berlin
Registered: 2023-09-12
Posts: 10

aptX, aptX-HD support on Pipewire/Wireplumber not working

Hello guys,

I have been trying to debug a problem for the past two days and I need your help. Even though I have aptX/aptX-HD compatible devices (Sony WH-900n, EDIFIER R1700bt) and a Bluetooth 5.0 adapter (Mpow BH456A that uses the rtl8761b chip) I am unable to connect with any of them using those codecs via Pipewire/Wireplumber. The only options are SBC and SBC-XQ.

I have libfreeaptx installed:

❯ pacman -Fx aptx 
extra/gst-plugins-bad 1.22.7-1
    usr/lib/gstreamer-1.0/libgstopenaptx.so
extra/gstreamer-docs 1.22.7-1
    usr/share/devhelp/books/GStreamer/libav/avdec_aptx.html
    usr/share/devhelp/books/GStreamer/libav/avdec_aptx_hd.html
    usr/share/devhelp/books/GStreamer/libav/avenc_aptx.html
    usr/share/devhelp/books/GStreamer/libav/avenc_aptx_hd.html
extra/libfreeaptx 0.1.1-1 [installed]
    usr/bin/freeaptxdec
    usr/bin/freeaptxenc
    usr/include/freeaptx.h
    usr/lib/libfreeaptx.so
    usr/lib/libfreeaptx.so.0
    usr/lib/libfreeaptx.so.0.1.1
    usr/lib/pkgconfig/libfreeaptx.pc
extra/pipewire-audio 1:0.3.85-1 [installed: 1:0.3.84-1]
    usr/lib/spa-0.2/bluez5/libspa-codec-bluez5-aptx.so

From what I understand they seem to be loading:

 ❯ journalctl -b | grep -i bluetoothd
Nov 18 10:56:10 matix bluetoothd[655]: Bluetooth daemon 5.70
Nov 18 10:56:10 matix bluetoothd[655]: Starting SDP server
Nov 18 10:56:10 matix bluetoothd[655]: src/plugin.c:plugin_init() System does not support csip plugin
Nov 18 10:56:10 matix bluetoothd[655]: profiles/audio/micp.c:micp_init() D-Bus experimental not enabled
Nov 18 10:56:10 matix bluetoothd[655]: src/plugin.c:plugin_init() System does not support micp plugin
Nov 18 10:56:10 matix bluetoothd[655]: src/plugin.c:plugin_init() System does not support vcp plugin
Nov 18 10:56:10 matix bluetoothd[655]: src/plugin.c:plugin_init() System does not support mcp plugin
Nov 18 10:56:10 matix bluetoothd[655]: src/plugin.c:plugin_init() System does not support bass plugin
Nov 18 10:56:10 matix bluetoothd[655]: src/plugin.c:plugin_init() System does not support bap plugin
Nov 18 10:56:10 matix bluetoothd[655]: Bluetooth management interface 1.22 initialized
Nov 18 10:56:10 matix dbus-daemon[656]: [system] Activating via systemd: service name='org.freedesktop.hostname1' unit='dbus-org.freedesktop.hostname1.service' requested by ':1.5' (uid=0 pid=655 comm="/usr/lib/bluetooth/bluetoothd")
Nov 18 10:56:11 matix bluetoothd[655]: src/device.c:device_set_wake_support() Unable to set wake_support without RPA resolution
Nov 18 10:56:11 matix bluetoothd[655]: src/device.c:device_set_wake_support() Unable to set wake_support without RPA resolution
Nov 18 10:56:11 matix bluetoothd[655]: src/device.c:set_wake_allowed_complete() Set device flags return status: Invalid Parameters
Nov 18 10:56:11 matix bluetoothd[655]: src/device.c:set_wake_allowed_complete() Set device flags return status: Invalid Parameters
Nov 18 10:56:23 matix bluetoothd[655]: Endpoint registered: sender=:1.45 path=/MediaEndpoint/A2DPSource/ldac
Nov 18 10:56:23 matix bluetoothd[655]: Endpoint registered: sender=:1.45 path=/MediaEndpoint/A2DPSink/aptx_hd
Nov 18 10:56:23 matix bluetoothd[655]: Endpoint registered: sender=:1.45 path=/MediaEndpoint/A2DPSource/aptx_hd
Nov 18 10:56:23 matix bluetoothd[655]: Endpoint registered: sender=:1.45 path=/MediaEndpoint/A2DPSink/aptx
Nov 18 10:56:23 matix bluetoothd[655]: Endpoint registered: sender=:1.45 path=/MediaEndpoint/A2DPSource/aptx
Nov 18 10:56:23 matix bluetoothd[655]: Endpoint registered: sender=:1.45 path=/MediaEndpoint/A2DPSink/aac
Nov 18 10:56:23 matix bluetoothd[655]: Endpoint registered: sender=:1.45 path=/MediaEndpoint/A2DPSource/aac
Nov 18 10:56:23 matix bluetoothd[655]: Endpoint registered: sender=:1.45 path=/MediaEndpoint/A2DPSink/sbc
Nov 18 10:56:23 matix bluetoothd[655]: Endpoint registered: sender=:1.45 path=/MediaEndpoint/A2DPSource/sbc
Nov 18 10:56:23 matix bluetoothd[655]: Endpoint registered: sender=:1.45 path=/MediaEndpoint/A2DPSink/sbc_xq
Nov 18 10:56:23 matix bluetoothd[655]: Endpoint registered: sender=:1.45 path=/MediaEndpoint/A2DPSource/sbc_xq
Nov 18 10:56:23 matix bluetoothd[655]: Endpoint registered: sender=:1.45 path=/MediaEndpoint/A2DPSource/aptx_ll_1
Nov 18 10:56:23 matix bluetoothd[655]: Endpoint registered: sender=:1.45 path=/MediaEndpoint/A2DPSource/aptx_ll_0
Nov 18 10:56:23 matix bluetoothd[655]: Endpoint registered: sender=:1.45 path=/MediaEndpoint/A2DPSource/aptx_ll_duplex_1
Nov 18 10:56:23 matix bluetoothd[655]: Endpoint registered: sender=:1.45 path=/MediaEndpoint/A2DPSource/aptx_ll_duplex_0
Nov 18 10:56:23 matix bluetoothd[655]: Endpoint registered: sender=:1.45 path=/MediaEndpoint/A2DPSource/faststream
Nov 18 10:56:23 matix bluetoothd[655]: Endpoint registered: sender=:1.45 path=/MediaEndpoint/A2DPSource/faststream_duplex
Nov 18 10:57:02 matix bluetoothd[655]: /org/bluez/hci0/dev_60_F4_3A_BC_21_99/sep1/fd0: fd(39) ready

And this is my 50-bluez-config.lua:

 ❯ cat /etc/wireplumber/bluetooth.lua.d/50-bluez-config.lua 
bluez_monitor.enabled = true

bluez_monitor.properties = {
  -- Enabled roles (default: [ a2dp_sink a2dp_source bap_sink bap_source hfp_hf hfp_ag ])
  --
  -- Currently some headsets (Sony WH-1000XM3) are not working with
  -- both hsp_ag and hfp_ag enabled, so by default we enable only HFP.
  --
  -- Supported roles: hsp_hs (HSP Headset),
  --                  hsp_ag (HSP Audio Gateway),
  --                  hfp_hf (HFP Hands-Free),
  --                  hfp_ag (HFP Audio Gateway)
  --                  a2dp_sink (A2DP Audio Sink)
  --                  a2dp_source (A2DP Audio Source)
  --                  bap_sink (LE Audio Basic Audio Profile Sink)
  --                  bap_source (LE Audio Basic Audio Profile Source)
  ["bluez5.roles"] = "[ a2dp_sink a2dp_source bap_sink bap_source hfp_hf hfp_ag ]",

  -- Enabled A2DP codecs (default: all).
  ["bluez5.codecs"] = "[ sbc sbc_xq aac ldac aptx aptx_hd aptx_ll aptx_ll_duplex faststream faststream_duplex ]",

  -- HFP/HSP backend (default: native).
  -- Available values: any, none, hsphfpd, ofono, native
  --["bluez5.hfphsp-backend"] = "native",

  -- HFP/HSP native backend modem (default: none).
  -- Available values: none, any or the modem device string as found in
  --   'Device' property of org.freedesktop.ModemManager1.Modem interface
  --["bluez5.hfphsp-backend-native-modem"] = "none",

  -- HFP/HSP hardware offload SCO support (default: false).
  --["bluez5.hw-offload-sco"] = false,

  -- Properties for the A2DP codec configuration
  --["bluez5.default.rate"] = 48000,
  --["bluez5.default.channels"] = 2,

  -- Register dummy AVRCP player, required for AVRCP volume function.
  -- Disable if you are running mpris-proxy or equivalent.
  --["bluez5.dummy-avrcp-player"] = true,

  -- Opus Pro Audio mode settings
  --["bluez5.a2dp.opus.pro.channels"] = 3,  -- no. channels
  --["bluez5.a2dp.opus.pro.coupled-streams"] = 1,  -- no. joint stereo pairs, see RFC 7845 Sec. 5.1.1
  --["bluez5.a2dp.opus.pro.locations"] = "FL,FR,LFE",  -- audio locations
  --["bluez5.a2dp.opus.pro.max-bitrate"] = 600000,
  --["bluez5.a2dp.opus.pro.frame-dms"] = 50,  -- frame duration in 1/10 ms: 25, 50, 100, 200, 400
  --["bluez5.a2dp.opus.pro.bidi.channels"] = 1,  -- same settings for the return direction
  --["bluez5.a2dp.opus.pro.bidi.coupled-streams"] = 0,
  --["bluez5.a2dp.opus.pro.bidi.locations"] = "FC",
  --["bluez5.a2dp.opus.pro.bidi.max-bitrate"] = 160000,
  --["bluez5.a2dp.opus.pro.bidi.frame-dms"] = 400,

  -- Enable the logind module, which arbitrates which user will be allowed
  -- to have bluetooth audio enabled at any given time (particularly useful
  -- if you are using GDM as a display manager, as the gdm user also launches
  -- pipewire and wireplumber).
  -- This requires access to the D-Bus user session; disable if you are running
  -- a system-wide instance of wireplumber.
  ["with-logind"] = true,

  -- The settings below can be used to override feature enabled status. By default
  -- all of them are enabled. They may also be disabled via the hardware quirk
  -- database, see bluez-hardware.conf
  ["bluez5.enable-sbc-xq"] = true,
  ["bluez5.enable-msbc"] = true,
  ["bluez5.enable-hw-volume"] = true,
}

bluez_monitor.rules = {
  -- An array of matches/actions to evaluate.
  {
    -- Rules for matching a device or node. It is an array of
    -- properties that all need to match the regexp. If any of the
    -- matches work, the actions are executed for the object.
    matches = {
      {
        -- This matches all cards.
        { "device.name", "matches", "bluez_card.*" },
      },
    },
    -- Apply properties on the matched object.
    apply_properties = {
      -- Auto-connect device profiles on start up or when only partial
      -- profiles have connected. Disabled by default if the property
      -- is not specified.
      ["bluez5.auto-connect"] = "[ hfp_hf hsp_hs a2dp_sink hfp_ag hsp_ag a2dp_source ]",

      -- Hardware volume control (default: [ hfp_ag hsp_ag a2dp_source ])
      --["bluez5.hw-volume"] = "[ hfp_hf hsp_hs a2dp_sink hfp_ag hsp_ag a2dp_source ]",

      -- LDAC encoding quality
      -- Available values: auto (Adaptive Bitrate, default)
      --                   hq   (High Quality, 990/909kbps)
      --                   sq   (Standard Quality, 660/606kbps)
      --                   mq   (Mobile use Quality, 330/303kbps)
      ["bluez5.a2dp.ldac.quality"] = "auto",

      -- AAC variable bitrate mode
      -- Available values: 0 (cbr, default), 1-5 (quality level)
      --["bluez5.a2dp.aac.bitratemode"] = 0,

      -- Profile connected first
      -- Available values: a2dp-sink (default), headset-head-unit
      --["device.profile"] = "a2dp-sink",

      -- Opus Pro Audio encoding mode: audio, voip, lowdelay
      --["bluez5.a2dp.opus.pro.application"] = "audio",
      --["bluez5.a2dp.opus.pro.bidi.application"] = "audio",
    },
  },
  {
    matches = {
      {
        -- Matches all sources.
        { "node.name", "matches", "bluez_input.*" },
      },
      {
        -- Matches all sinks.
        { "node.name", "matches", "bluez_output.*" },
      },
    },
    apply_properties = {
      --["node.nick"] = "My Node",
      --["priority.driver"] = 100,
      --["priority.session"] = 100,
      --["node.pause-on-idle"] = false,
      --["resample.quality"] = 4,
      --["channelmix.normalize"] = false,
      --["channelmix.mix-lfe"] = false,
      --["session.suspend-timeout-seconds"] = 5,  -- 0 disables suspend
      --["monitor.channel-volumes"] = false,

      -- Media source role, "input" or "playback"
      -- Defaults to "playback", playing stream to speakers
      -- Set to "input" to use as an input for apps
      --["bluez5.media-source-role"] = "input",
    },
  },
}

Is there any manual step that needs to be made to enable those features? My headphones are even supposed to support LDAC since they are Sony and it's a Sony codec.
Any help would be appreciated!

Offline

#2 2024-05-16 15:08:44

Fluora
Member
Registered: 2024-03-07
Posts: 6

Re: aptX, aptX-HD support on Pipewire/Wireplumber not working

Have there been any updates on this? I'm apparently having exactly the same issue across all of my computers. One of my pairs of earbuds shows AAC as an option, but otherwise I can only select SBC, SBC-XQ, CVSD, or mSBC (the latter two being headset profiles). Both devices I have are supposed to support at least regular aptX, though I don't know which extra variants (-HD, -LL, etc) they support, if any.

Wireplumber has changed config file formats and no longer accepts lua, so the above examples from spasoff are no longer current, but it shouldn't be necessary to change anything from it anyway; the docs say that all supported codecs are enabled by default. (And in any case, enabling them manually did nothing in my tests.)

I also tried building the pipewire-git AUR package, which changed nothing.
Going back to pulseaudio didn't work either (using `pactl send-message` to list codecs showed only the same as before).

I'm basically stuck, since I can't find anything relevant to this particular issue via Google besides this thread and haven't managed to get any of the relevant programs to emit useful error messages either. Anyone have any ideas?

Offline

Board footer

Powered by FluxBB