Giter Site home page Giter Site logo

ehfive / pulseaudio-modules-bt Goto Github PK

View Code? Open in Web Editor NEW
1.8K 60.0 88.0 385 KB

[Deprecated, see https://github.com/EHfive/pulseaudio-modules-bt/issues/154] Adds Sony LDAC, aptX, aptX HD, AAC codecs (A2DP Audio) support to PulseAudio on Linux

License: GNU General Public License v3.0

C 97.86% CMake 2.14%
bluetooth a2dp audio aptx linux aac

pulseaudio-modules-bt's Introduction

pulseaudio-modules-bt

this repo is a fork of pulseaudio bluetooth modules

and adds LDAC, APTX, APTX-HD, AAC support, extended configuration for SBC

Added Codecs

Codec Encoding(source role) Decoding(sink role) Sample format(s) Sample frequencies
AAC s16 8, 11.025, 12,16, 22.05, 24, 32, 44.1, 48, 64, 88.2, 96 khz
APTX s16 16, 32, 44.1, 48 khz
APTX HD s24
LDAC s16,s24,s32,f32 44.1, 48, 88.2, 96 khz

APTX/APTX_HD sample format fixed to s32 in PA. (ffmpeg do the sample format transformation)

Extended SBC configuration

Added support for manual (expert) configuration for SBC codec parameters:

  • Min and Max bitpool limits (2-250)
  • Sampling frequency
  • Audio channel mode
  • Quantization bit allocation mode
  • Frequency bands number
  • Audio blocks number

You can use this parameters to override and fine-tune default SBC codec config and manually setup configurations like SBC XQ, or Dual Channel HD mode. More info about SBC configuration options can be found at LineageOS documentation. Also there is interactive calculator and unofficial device compatibility list that may help you to select proper values.

Parameter-names for module-bluez5-discover and valid values provided at the table below.

NOTE: Use these parameters with caution at your own risk! Invalid or extreme "out-of-spec" configurations may sometimes even cause malfunction for some cheap BT-audio devices. Usually these malfunctions can be fixed by resetting audio-device or sometimes simply by reconnecting with valid configuration.

Usage

Pre-built binary packages

See the wiki/Packages to find pre-build binary packages for you distribution.

Please also check issue#3.

After installing your pre-built binary packages, see below to configure the module.

Build from source

Make Dependencies

  • pulseaudio>=11.59.1
  • bluez~=5.0
  • dbus
  • sbc
  • [Optional] ffmpeg(libavcodec>=58, libavutil>=56) >= 4.0
  • [Optional] fdk-aac(-free)>=0.1.5: pulseaudio-modules-bt use LC-AAC only
  • [Optional] ldacBT/libldac
  • cmake
  • pkg-config, libtool, ...

On Debian based distributions (like Ubuntu), you can install the make dependencies with:

sudo apt-get install -y libfdk-aac-dev libavcodec-dev libpulse-dev libdbus-1-dev libsbc-dev libldacbt-abr-dev libldacbt-enc-dev libltdl-dev libbluetooth-dev

Runtime Dependencies

  • pulseaudio ( force preopen disabled / built with --disable-force-preopen)
  • bluez
  • dbus
  • sbc
  • [ fdk-aac(-free) ]
  • [ libavcodec.so ]: APTX, APTX-HD support [Optional]
  • [ libldac ]: LDAC encoding support, LDAC ABR support [Optional]

Build

backup original pulseaudio bt modules

MODDIR=`pkg-config --variable=modlibexecdir libpulse`

sudo find $MODDIR -regex ".*\(bluez5\|bluetooth\).*\.so" -exec cp {} {}.bak \;

pull sources

Make sure to pull into a filesystem that supports colons (:) as valid characters in filename (see #144). Ext4 does, while NTFS does not.

git clone https://github.com/EHfive/pulseaudio-modules-bt.git
cd pulseaudio-modules-bt
git submodule update --init

install

A. build for PulseAudio releases (e.g., v12.0, v12.2, etc.)

git -C pa/ checkout v`pkg-config libpulse --modversion|sed 's/[^0-9.]*\([0-9.]*\).*/\1/'`

mkdir build && cd build
cmake ..
make
sudo make install

B. or build for PulseAudio git master

git -C pa/ checkout master
mkdir build && cd build
cmake -DFORCE_LARGEST_PA_VERSION=ON ..
make
sudo make install

Cmake A2DP codecs options: CODEC_APTX_FF, CODEC_APTX_HD_FF, CODEC_AAC_FDK, CODEC_LDAC

Load Modules

pulseaudio -k

# if pulseaudio not restart automatically, run
pulseaudio --start

if you got a warning like below, you need to rebuild pulseaudio with --disable-force-preopen flag

pulseaudio: symbol lookup error: pulseaudio: undefined symbol: pa_a2dp_codec_sbc

Connect device

Connect your bluetooth device and switch audio profile to 'A2DP Sink';

If there is only profile 'HSP/HFP' and 'off', disconnect and reconnect your device.

The issue has been fixed in bluez 5.51.

Module Arguments

module-bluez5-discover arg:a2dp_config

Encoders configurations

Key Value Desc Default
sbc_min_bp 2-250 minimum allowed bitpool auto
sbc_max_bp 2-250 maximum allowed bitpool, may not be < sbc_min_bp auto
sbc_freq 16k, 32k, 44k, 48k 16000/32000/44100/48000 Hz sample frequency auto
auto do not enforce sample frequency (default)
sbc_cmode mono mono channel-mode auto
dual dual channel-mode
stereo stereo channel-mode
joint_stereo joint stereo channel-mode
auto do not enforce channel-mode (default)
sbc_alloc snr use SNR bit-allocation algorithm auto
loudness use loudness bit-allocation algorithm
auto do not enforce bit-allocation algorithm (default)
sbc_sbands 4, 8 4 or 8 subbands auto
auto do not enforce subbands count (default)
sbc_blen 4, 8, 12, 16 4/8/12/16 audio blocks in one audio frame auto
auto do not enforce audio blocks count (default)
ldac_eqmid hq LDAC High Quality auto
sq LDAC Standard Quality
mq LDAC Mobile use Quality
auto /abr LDAC Adaptive Bit Rate
ldac_fmt s16 16-bit signed (little endian) auto
s24 24-bit signed
s32 32-bit signed
f32 32-bit float
auto Ref default-sample-format
ldac_abr_t1 <uint> safety threshold for LDACBT_EQMID_HQ and LDACBT_EQMID_SQ 2
ldac_abr_t2 <uint> threshold for dangerous trend of TxQueueDepth 4
ldac_abr_t3 <uint> threshold for critical TxQueueDepth status 6
aac_bitrate_mode [1, 5] Variable Bitrate (VBR) 0
0 Constant Bitrate (CBR)
aac_afterburner <on/off> Enable/Disable AAC encoder afterburner feature off
aac_fmt s16 16-bit signed (little endian) auto
s32 32-bit signed
auto Ref default-sample-format

Configure

edit /etc/pulse/default.pa

append arguments to 'load-module module-bluetooth-discover'

(module-bluetooth-discover pass all arguments to module-bluez5-discover)

# LDAC Standard Quality
load-module module-bluetooth-discover a2dp_config="ldac_eqmid=sq"

# LDAC High Quality; Force LDAC/PA PCM sample format as Float32LE
#load-module module-bluetooth-discover a2dp_config="ldac_eqmid=hq ldac_fmt=f32"

equivalent to commands below if you do not use 'module-bluetooth-discover'

load-module module-bluez5-discover a2dp_config="ldac_eqmid=sq"

#load-module module-bluez5-discover a2dp_config="ldac_eqmid=hq ldac_fmt=f32"

Others

see Wiki

TODO

add ldac abr (Adaptive Bit Rate) supprot

add APTX , APTX HD Codec support using ffmpeg

add AAC support using Fraunhofer FDK AAC codec library

add codec switching support using latest blueZ's experimental feature

Copyright

  pulseaudio-modules-bt

  Copyright (C) 2018-2019  Huang-Huang Bao

  This program is free software: you can redistribute it and/or modify
  it under the terms of the GNU General Public License as published by
  the Free Software Foundation, either version 3 of the License, or
  (at your option) any later version.

  This program is distributed in the hope that it will be useful,
  but WITHOUT ANY WARRANTY; without even the implied warranty of
  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  GNU General Public License for more details.

  You should have received a copy of the GNU General Public License
  along with this program. If not, see <http://www.gnu.org/licenses/>.

pulseaudio-modules-bt's People

Contributors

10b14224cc avatar asavah avatar conte91 avatar dabukalam avatar darkcaster avatar ehfive avatar hexchain avatar orphis avatar xq262144 avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

pulseaudio-modules-bt's Issues

building on raspberry pi. Possibly a lot of missed stuff, tell me!

# I don't know if you need to prepare headers, 
# I do it directly on fresh install and at new kernal
# use my script https://gist.github.com/orrpan/338fb6040e95630c7ee118370b02116f 
# better safe than sorry
wget https://gist.github.com/orrpan/338fb6040e95630c7ee118370b02116f/raw/daf85934a6e2e4d7868eecece854671a4eba0587/kernelprep.sh
chmod +x kernelprep.sh
sudo ./kernelprep.sh

sudo apt-get update


# might be better to build bluez, don't know
sudo apt-get install git make bluez cmake build-essential diffutils \
    gcc libfdk-aac-dev1 libass-dev libmp3lame-dev libopus-dev \
    libtheora-dev libvpx-dev libvorbis-dev libomxil-bellagio-dev \
    autoconf automake libtool checkinstall wget

# alot more most likely

# Remove old stuff
sudo apt-get remove libswresample-dev libswresample2 \
    libavcodec libswscale-dev libswscale4 libavutil55 \
    libavutil-dev ffmpeg pulseaudio

sudo apt-get autoremove -y

# Folder
mkdir ~/build
cd ~/build


# Install cmake
wget https://cmake.org/files/v3.13/cmake-3.13.3.tar.gz
tar xf cmake-3.13.3.tar.gz
cd cmake-3.13.3
./configure
make
# install not needed, since this is only used for this build

# bluez
wget www.kernel.org/pub/linux/bluetooth/bluez-5.50.tar.xz
tar xf bluez-5.50.tar.xz
cd bluez-5.50
./configure --prefix=/usr         \
            --sysconfdir=/etc     \
            --localstatedir=/var  \
            --enable-library      \
            --disable-systemd     &&
make -j4
sudo make install

sudo ln -svf ../libexec/bluetooth/bluetoothd /usr/sbin
sudo install -v -dm755 /etc/bluetooth
sudo install -v -m644 src/main.conf /etc/bluetooth/main.conf
sudo install -v -dm755 /usr/share/doc/bluez-5.50
sudo install -v -m644 doc/*.txt /usr/share/doc/bluez-5.50

sudo reboot 

## alot of codecs, all may not be needed
# sbc
cd ~/build
wget https://www.kernel.org/pub/linux/bluetooth/sbc-1.4.tar.xz
tar xf sbc-1.4.tar.xz
cd sbc-1.4
./configure
make -j4
sudo make install
sudo ldconfig


# soxr
cd ~/build
git clone git://git.code.sf.net/p/soxr/code soxr-code
cd soxr-code
./go
cd Release
sudo make install
sudo ldconfig


# faac
cd ~/build
git clone https://github.com/mstorsjo/fdk-aac.git
cd fdk-aac
./autogen.sh
./configure --enable-shared --enable-static
make -j4
sudo make install
sudo ldconfig

# alac 
cd ~/build
git clone https://github.com/mikebrady/alac.git
cd alac
autoreconf -fi
./configure
make -j4
sudo make install
sudo ldconfig

# ldacBT
cd ~/build
git clone https://github.com/EHfive/ldacBT.git
cd ldacBT
git submodule update --init
mkdir build && cd build
../../cmake-3.13.3/bin/./cmake \
    -DCMAKE_INSTALL_PREFIX=/usr \
    -DINSTALL_LIBDIR=/usr/lib \
    -DLDAC_SOFT_FLOAT=OFF \
    ../
make -j4
sudo make install
sudo ldconfig

# Install x264
cd ~/build
git clone git://git.videolan.org/x264
cd x264
./configure --enable-static --enable-pic --enable-shared
make -j4
sudo make install
sudo ldconfig

# ffmpeg, this takes forever...
cd ~/build
git clone git://source.ffmpeg.org/ffmpeg.git ffmpeg
cd ffmpeg
./configure --prefix=/usr --enable-gpl --enable-version3 --enable-nonfree \
    --disable-static --enable-shared --disable-debug --enable-avresample \
    --enable-libass --enable-libfdk-aac --enable-libfreetype --enable-libmp3lame \
    --enable-libopus --enable-libtheora --enable-libvorbis --enable-libvpx \
    --enable-libx264
make -j4
sudo make install
sudo ldconfig



# pulseaudio
cd ~/build
wget https://www.freedesktop.org/software/pulseaudio/releases/pulseaudio-12.2.tar.xz
tar xf pulseaudio-12.2.tar.xz
cd pulseaudio-12.2/
./configure --prefix=/usr        \
            --sysconfdir=/etc    \
            --localstatedir=/var \
            --disable-bluez4     \
            --disable-rpath
make -j4
sudo make install
sudo ldconfig
sudo rm -fv /etc/dbus-1/system.d/pulseaudio-system.conf
sudo sed -i '/load-module module-console-kit/s/^/#/' /etc/pulse/default.pa

# pulseaudio-modules-bt
cd ~/build
MODDIR=`pkg-config --variable=modlibexecdir libpulse`
sudo find $MODDIR -regex ".*\(bluez5\|bluetooth\).*\.so" -exec cp {} {}.bak \;

git clone https://github.com/EHfive/pulseaudio-modules-bt.git
cd pulseaudio-modules-bt
git submodule update --init

git -C pa/ checkout v`pkg-config libpulse --modversion|sed 's/[^0-9.]*\([0-9.]*\).*/\1/'`

mkdir build && cd build
# here we have our new cmake
../../cmake-3.13.3/bin/./cmake ..
make -j4
sudo make install
sudo ldconfig

I think thats about it, probally alot more. 

LDAC sample rate won't go up to 96000hz

pacmd list-sinks gives
sample spec: float32le 2ch 44100Hz

According to a previous closed issue, default sample rate was set to 96000hz in this case
; default-sample-format = s16le ; default-sample-rate = 96000 ; alternate-sample-rate = 44100

In addition, default.pa was modified for
load-module module-bluetooth-discover a2dp_config="ldac_eqmid=hq ldac_fmt=f32"

Clementine music player was used and output sample rate was also set to 96000hz.
Why? So confused!

Dropping connection

I lose connection spontaneously. I think the problem is coming from dbus

[system] Rejected send message, 3 matched rules; type="method_return", sender=":1.25" (uid=112 pid=1724 comm="/usr/bin/pulseaudio --system --disallow-exit --dis") interface="(unset)" member="(unset)" error name="(unset)" requested_reply="0" destination=":1.3" (uid=0 pid=384 comm="/usr/lib/bluetooth/bluetoothd ")

Running
dpkg -l dbus
Returns

dbus 1.10.26-0+deb9u1 armhf

Any thoughts?

Can't get aptx or aptx_hd sinks to be available

Hello.

I am under Fedora and I updated to the 1.1.3 rpm packages you provided (#20) which provides handy looking profiles.

The only sad part is that... I can't get my device (which is a Plantronics Backeat Pro 2) to get detected as a aptx enabled device as shown on the output below:

Card #3
	Name: bluez_card.E4_22_A5_BD_10_A9
	Driver: module-bluez5-device.c
	Owner Module: 25
	Properties:
		device.description = "PLT BB PRO 2"
		device.string = "E4:22:A5:BD:10:A9"
		device.api = "bluez"
		device.class = "sound"
		device.bus = "bluetooth"
		device.form_factor = "headset"
		bluez.path = "/org/bluez/hci0/dev_E4_22_A5_BD_10_A9"
		bluez.class = "0x240404"
		bluez.alias = "PLT BB PRO 2"
		device.icon_name = "audio-headset-bluetooth"
		device.intended_roles = "phone"
	Profiles:
		headset_head_unit: Headset Head Unit (HSP/HFP) (sinks: 1, sources: 1, priority: 30, available: yes)
		a2dp_sink_sbc: High Fidelity Playback (A2DP Sink: SBC) (sinks: 1, sources: 0, priority: 40, available: no)
		a2dp_sink_aac: High Fidelity Playback (A2DP Sink: AAC) (sinks: 1, sources: 0, priority: 40, available: yes)
		a2dp_sink_aptx: High Fidelity Playback (A2DP Sink: aptX) (sinks: 1, sources: 0, priority: 40, available: no)
		a2dp_sink_aptx_hd: High Fidelity Playback (A2DP Sink: aptX HD) (sinks: 1, sources: 0, priority: 40, available: no)
		a2dp_sink_ldac: High Fidelity Playback (A2DP Sink: LDAC) (sinks: 1, sources: 0, priority: 40, available: no)
		off: Off (sinks: 0, sources: 0, priority: 0, available: yes)
	Active Profile: a2dp_sink_aac
	Ports:
		headset-output: Headset (priority: 0, latency offset: 0 usec)
			Part of profile(s): headset_head_unit, a2dp_sink_sbc, a2dp_sink_aac, a2dp_sink_aptx, a2dp_sink_aptx_hd, a2dp_sink_ldac
		headset-input: Headset (priority: 0, latency offset: 0 usec)
			Part of profile(s): headset_head_unit

I am nonetheless sure that it worked at some point with the previous package under Aptx.

Some audio package updated afterwards, and I had huge audio artifacts, removed the older version and tried the new version install (which obviously worked with the sink separations.

I tried un-pairing, repairing, unconneting, reconneting and so on, couldn't get the availability to pop up.

Any hint or known issue?

Attempting to switch to an unsupported codec breaks all A2DP profiles until bluetooth device is reconnected

  1. Connect to a device

    $ bluetoothctl
    
    [bluetooth]# connect 30:C0:1B:8D:9C:F1
    Attempting to connect to 30:C0:1B:8D:9C:F1
    [CHG] Device 30:C0:1B:8D:9C:F1 ServicesResolved: yes
    Connection successful
    [JBL Clip 3]#
    
  2. Observe the card and sink

    $ pactl list cards
    <...>
    Card #4
           Name: bluez_card.30_C0_1B_8D_9C_F1
           Driver: module-bluez5-device.c
           Owner Module: 28
           Properties:
                   device.description = "JBL Clip 3"
                   device.string = "30:C0:1B:8D:9C:F1"
                   device.api = "bluez"
                   device.class = "sound"
                   device.bus = "bluetooth"
                   device.form_factor = "speaker"
                   bluez.path = "/org/bluez/hci0/dev_30_C0_1B_8D_9C_F1"
                   bluez.class = "0x200414"
                   bluez.alias = "JBL Clip 3"
                   device.icon_name = "audio-speakers-bluetooth"
           Profiles:
                   headset_head_unit: Headset Head Unit (HSP/HFP) (sinks: 1, sources: 1, priority: 30, available: yes)
                   a2dp_sink_sbc: High Fidelity Playback (A2DP Sink: SBC) (sinks: 1, sources: 0, priority: 40, available: yes)
                   a2dp_sink_aac: High Fidelity Playback (A2DP Sink: AAC) (sinks: 1, sources: 0, priority: 40, available: no)
                   a2dp_sink_aptx: High Fidelity Playback (A2DP Sink: aptX) (sinks: 1, sources: 0, priority: 40, available: no)
                   a2dp_sink_aptx_hd: High Fidelity Playback (A2DP Sink: aptX HD) (sinks: 1, sources: 0, priority: 40, available: no)
                   a2dp_sink_ldac: High Fidelity Playback (A2DP Sink: LDAC) (sinks: 1, sources: 0, priority: 40, available: no)
                   off: Off (sinks: 0, sources: 0, priority: 0, available: yes)
           Active Profile: a2dp_sink_sbc
           Ports:
                   speaker-output: Speaker (priority: 0, latency offset: 0 usec, available)
                           Part of profile(s): headset_head_unit, a2dp_sink_sbc, a2dp_sink_aac, a2dp_sink_aptx, a2dp_sink_aptx_hd, a2dp_sink_ldac
                   speaker-input: Bluetooth Input (priority: 0, latency offset: 0 usec)
                           Part of profile(s): headset_head_unit
    
    $ pactl list sinks
    <...>
    Sink #9
           State: IDLE
           Name: bluez_sink.30_C0_1B_8D_9C_F1.a2dp_sink
           Description: JBL Clip 3
           Driver: module-bluez5-device.c
           Sample Specification: s16le 2ch 44100Hz
           Channel Map: front-left,front-right
           Owner Module: 28
           Mute: no
           Volume: front-left: 30148 /  46% / -20,23 dB,   front-right: 30148 /  46% / -20,23 dB
                   balance 0,00
           Base Volume: 65536 / 100% / 0,00 dB
           Monitor Source: bluez_sink.30_C0_1B_8D_9C_F1.a2dp_sink.monitor
           Latency: 46258 usec, configured 39512 usec
           Flags: HARDWARE DECIBEL_VOLUME LATENCY
           Properties:
                   bluetooth.protocol = "a2dp_sink"
                   bluetooth.a2dp_codec = "SBC"
                   device.description = "JBL Clip 3"
                   device.string = "30:C0:1B:8D:9C:F1"
                   device.api = "bluez"
                   device.class = "sound"
                   device.bus = "bluetooth"
                   device.form_factor = "speaker"
                   bluez.path = "/org/bluez/hci0/dev_30_C0_1B_8D_9C_F1"
                   bluez.class = "0x200414"
                   bluez.alias = "JBL Clip 3"
                   device.icon_name = "audio-speakers-bluetooth"
           Ports:
                   speaker-output: Speaker (priority: 0, available)
           Active Port: speaker-output
           Formats:
                   pcm
    
  3. Try to switch to an unsupported codec (it looks like it worked)

    $ pactl set-card-profile bluez_card.30_C0_1B_8D_9C_F1 a2dp_sink_aac
    
  4. Observe the sink didn't change

    $ pactl list sinks
    Sink #12
            State: SUSPENDED
            Name: bluez_sink.30_C0_1B_8D_9C_F1.a2dp_sink
            Description: JBL Clip 3
            Driver: module-bluez5-device.c
            Sample Specification: s16le 2ch 44100Hz
            Channel Map: front-left,front-right
            Owner Module: 29
            Mute: no
            Volume: front-left: 30148 /  46% / -20,23 dB,   front-right: 30148 /  46% / -20,23 dB
                    balance 0,00
            Base Volume: 65536 / 100% / 0,00 dB
            Monitor Source: bluez_sink.30_C0_1B_8D_9C_F1.a2dp_sink.monitor
            Latency: 0 usec, configured 0 usec
            Flags: HARDWARE DECIBEL_VOLUME LATENCY
            Properties:
                    bluetooth.protocol = "a2dp_sink"
                    bluetooth.a2dp_codec = "SBC"
                    device.description = "JBL Clip 3"
                    device.string = "30:C0:1B:8D:9C:F1"
                    device.api = "bluez"
                    device.class = "sound"
                    device.bus = "bluetooth"
                    device.form_factor = "speaker"
                    bluez.path = "/org/bluez/hci0/dev_30_C0_1B_8D_9C_F1"
                    bluez.class = "0x200414"
                    bluez.alias = "JBL Clip 3"
                    device.icon_name = "audio-speakers-bluetooth"
            Ports:
                    speaker-output: Speaker (priority: 0, available)
            Active Port: speaker-output
            Formats:
                    pcm
    
  5. At this point, if I try to play something via this sink, it hangs.

  6. Try to switch the profile back (it fails)

    $ pactl set-card-profile bluez_card.30_C0_1B_8D_9C_F1 a2dp_sink_sbc
    Failure: Input/Output error
    
  7. This is where things go wrong. The sink disappears and does not reappear until the device is reconnected.

    $ pactl list sinks
    <...> (only irrelevant sinks here now)
    
  8. Try to switch to HFP/HSP profile (it actually works)

    $ pactl set-card-profile bluez_card.30_C0_1B_8D_9C_F1 headset_head_unit
    
  9. Observe the sink again

    Sink #13
            State: IDLE
            Name: bluez_sink.30_C0_1B_8D_9C_F1.headset_head_unit
            Description: JBL Clip 3
            Driver: module-bluez5-device.c
            Sample Specification: s16le 1ch 8000Hz
            Channel Map: mono
            Owner Module: 29
            Mute: no
            Volume: mono: 43691 /  67%
                    balance 0,00
            Base Volume: 65536 / 100%
            Monitor Source: bluez_sink.30_C0_1B_8D_9C_F1.headset_head_unit.monitor
            Latency: 29926 usec, configured 28000 usec
            Flags: HARDWARE HW_VOLUME_CTRL LATENCY
            Properties:
                    bluetooth.protocol = "headset_head_unit"
                    device.intended_roles = "phone"
                    device.description = "JBL Clip 3"
                    device.string = "30:C0:1B:8D:9C:F1"
                    device.api = "bluez"
                    device.class = "sound"
                    device.bus = "bluetooth"
                    device.form_factor = "speaker"
                    bluez.path = "/org/bluez/hci0/dev_30_C0_1B_8D_9C_F1"
                    bluez.class = "0x200414"
                    bluez.alias = "JBL Clip 3"
                    device.icon_name = "audio-speakers-bluetooth"
            Ports:
                    speaker-output: Speaker (priority: 0, available)
            Active Port: speaker-output
            Formats:
                    pcm
    

AAC encoding error

First of all, thank you for this project! I didn't think I'd ever be able to use bluetooth headphones on Linux before finding this.

Everything seems to be working correctly (with pactl showing the AAC codec in use), but after a certain amount of time (sometimes minutes, sometimes seconds), the pulseaudio output device automatically switches back to the default (line out) and journalctl shows the following error:

pulseaudio[22152]: E: [bluetooth] a2dp_aac.c: AAC encoding error, 0x60

I can then switch the output device back to the bluetooth headphones and it'll work again for a few more seconds or minutes until the error appears again. I tried manually switching the output away from the bluetooth headphones to see if the error was triggered in the other direction, but no error messages appear in that case. The bluetooth logs don't show any brief disconnects or anything either.

Let me know if there's any additional output or tests I can perform to help!

Xiaomi AirDots Pro: AAC codec not recognized

Good morning,
i've some problem to make these (english version) earbuds working with AAC audio codec.
According to their specs, AAC is supported: in fact i'm able to make them working with some devices (e.g. Nvidia shield / Oneplus 3... the funniest thing is that they are not working with Xiaomi phones but this is another story).
avinfo doesn't recognize any 2nd sink profile (no unknown profile is listed)
I've attached some logs
Any hints?
Thanks in advance
Anthony
bmon.log
bt.log

Express the codec being used with pulseaudio

I just wanted to:

  1. Report success with my Sennheiser HD1 + XPS 15:
        Name: bluez_sink.NO_NE_OF_YO_UR_BU.a2dp_sink
        Driver: module-bluez5-device.c
        Monitor Source: bluez_sink.NO_NE_OF_YO_UR_BU.a2dp_sink.monitor
                bluetooth.a2dp_codec = "APTX"
                device.api = "bluez"
                bluez.path = "/org/bluez/hci0/dev_NO_NE_OF_YO_UR_BU"
                bluez.class = "0x240404"
                bluez.alias = "HD1 M2 AEBT"
  1. Ask if there is a way to make the selected codec expressed somehow in the UI, specifically as the HD1 headphones, for example, in what I presume is not their singular problem, fails to show which codec is being used...:

image

Coredump with JACK Sink

I am using PulseAudios jack sink pulseaudio-jack 12.2-2 to route pulse audio to jack. This (sort of) works with the official pulseaudio-bluetooth 12.2-2 package on ArchLinux. But the aur/pulseaudio-modules-bt-git-r55.a228264-1 package fails with a coredump.

Failed to load the modules (Latest AUR)

image
Failed to load the modules

╰─ pulseaudio                                                                                                                                  3 ↵  8094  22:07:53 
E: [pulseaudio] module-bluez5-discover.c: failed to parse module arguments.
E: [pulseaudio] module.c: Failed to load module "module-bluez5-discover" (argument: "ldac_eqmid=hq"): initialization failed.
E: [pulseaudio] module.c: Failed to load module "module-bluetooth-discover" (argument: "ldac_eqmid=hq"): initialization failed.

segfault / assertion error in module-bluez5-discover

Ubuntu 18.10, pulseaudio 12.2, bluez 5.50. Trying to get a Sony WH-1000XM3 connected.

from pulseaudio log:
( 18.287| 0.815) D: [pulseaudio] bluez5-util.c: Properties changed in device /org/bluez/hci0/dev_CC_98_8B_93_C3_3E
( 18.471| 0.184) D: [alsa-sink-USB Audio] alsa-sink.c: Wakeup from ALSA!
( 19.082| 0.611) D: [pulseaudio] backend-native.c: dbus: path=/Profile/HSPAGProfile, interface=org.bluez.Profile1, member=NewConnection
( 19.082| 0.000) D: [pulseaudio] backend-native.c: dbus: NewConnection path=/org/bluez/hci0/dev_CC_98_8B_93_C3_3E, fd=27, profile headset_head_unit
( 19.082| 0.000) I: [pulseaudio] backend-native.c: doing listen
( 19.082| 0.000) D: [pulseaudio] bluez5-util.c: Transport /org/bluez/hci0/dev_CC_98_8B_93_C3_3E/fd27 state: disconnected -> idle
( 19.082| 0.000) D: [pulseaudio] backend-native.c: Transport /org/bluez/hci0/dev_CC_98_8B_93_C3_3E/fd27 available for profile headset_head_unit
( 19.471| 0.388) D: [alsa-sink-USB Audio] alsa-sink.c: Wakeup from ALSA!
( 20.471| 1.000) D: [alsa-sink-USB Audio] alsa-sink.c: Wakeup from ALSA!
( 21.471| 0.999) D: [alsa-sink-USB Audio] alsa-sink.c: Wakeup from ALSA!
( 22.083| 0.611) D: [pulseaudio] bluez5-util.c: Timeout expired, and device /org/bluez/hci0/dev_CC_98_8B_93_C3_3E still has disconnected profiles: a2dp_sink
( 22.083| 0.000) D: [pulseaudio] module-bluez5-discover.c: Loading module-bluez5-device path=/org/bluez/hci0/dev_CC_98_8B_93_C3_3E autodetect_mtu=0 a2dp_config="ldac_eqmid=hq ldac_fmt=f32"
Segmentation fault (core dumped)

Occasionally I get the following at the end of the PA log:
( 16.053| 0.000) E: [pulseaudio] module-bluez5-device.c: Assertion 'pa_a2dp_codec_index_is_source(codec_index)' failed at modules/bluetooth/module-bluez5-device.c:1867, function create_card_profile(). Aborting.
Aborted (core dumped)

...And sometimes the following as well:
( 16.132| 0.000) E: [pulseaudio] module-bluez5-device.c: Assertion 'profiles[i].profile_string' failed at modules/bluetooth/module-bluez5-device.c:2117, function add_card(). Aborting.
Aborted (core dumped)

Post your patches to Pulseaudio maillist

Hi, there's a patch on Pulseaudio maillist for the modular A2DP API: https://lists.freedesktop.org/archives/pulseaudio-discuss/2018-July/030344.html
Support for aptX: https://lists.freedesktop.org/archives/pulseaudio-discuss/2018-July/030344.html
And a discussion regarding using gstreamer or ffmpeg for additional codecs: https://lists.freedesktop.org/archives/pulseaudio-discuss/2018-July/030201.html

It would be great if you can negotiate the best method of LDAC integration with Pulseaudio developers and commit it directly to the main branch.

a2dp_config not being passed, stuck on s16le 2ch 44100Hz

pactl list short modules | grep blue
7	module-bluetooth-policy		
8	module-bluetooth-discover		
9	module-bluez5-discover		
23	module-bluez5-device	path=/org/bluez/hci0/dev_70_26_05_57_B1_60 autodetect_mtu=0 a2dp_config=""
pacmd list-sinks
    index: 2
	name: <bluez_sink.70_26_05_57_B1_60.a2dp_sink>
	driver: <module-bluez5-device.c>
	flags: HARDWARE DECIBEL_VOLUME LATENCY 
	state: SUSPENDED
	suspend cause: IDLE
	priority: 9050
	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 request: 2 KiB
	max rewind: 0 KiB
	monitor source: 3
	sample spec: s16le 2ch 44100Hz
	channel map: front-left,front-right
	             Stereo
	used by: 0
	linked by: 0
	fixed latency: 36.61 ms
	card: 1 <bluez_card.70_26_05_57_B1_60>
	module: 23
	properties:
		bluetooth.protocol = "a2dp_sink"
		bluetooth.a2dp_codec = "LDAC"
		device.description = "WH-1000XM2"
		device.string = "70:26:05:57:B1:60"
		device.api = "bluez"
		device.class = "sound"
		device.bus = "bluetooth"
		device.form_factor = "headset"
		bluez.path = "/org/bluez/hci0/dev_70_26_05_57_B1_60"
		bluez.class = "0x240404"
		bluez.alias = "WH-1000XM2"
		device.icon_name = "audio-headset-bluetooth"
		device.intended_roles = "phone"
	ports:
		headset-output: Headset (priority 0, latency offset 0 usec, available: unknown)
			properties:
				
	active port: <headset-output>
### Automatically load driver modules for Bluetooth hardware
.ifexists module-bluetooth-policy.so
load-module module-bluetooth-policy
.endif

.ifexists module-bluetooth-discover.so
#load-module module-bluetooth-discover
load-module module-bluetooth-discover a2dp_config="ldac_eqmid=hq ldac_fmt=f32"
.endif

Sound artifacts/cracking with aptX which started some time after the installation

Hello,
Thank you for your great work, really appreciate it.
My setup is Dell E7440 with Intel 7260, Kubuntu 18.04, Sennheiser M2 AEBT with aptX.
The modules were installed from the deb package.

At the beginning everything was great, I had no issues.
Some weeks later heavy cracking while listening started.
Calling pulseaudio -k fixes it, but I think it also messes up with the sound quality. Is it possible that after the aptX is no longer used?

piter@piter:~$ pactl list sinks | grep -e bluez -e a2dp_codec
	Name: bluez_sink.00_1B_66_84_1D_AF.a2dp_sink
	Driver: module-bluez5-device.c
	Monitor Source: bluez_sink.00_1B_66_84_1D_AF.a2dp_sink.monitor
		bluetooth.a2dp_codec = "aptX"
		device.api = "bluez"
		bluez.path = "/org/bluez/hci0/dev_00_1B_66_84_1D_AF"
		bluez.class = "0x240404"
		bluez.alias = "MOMENTUM M2 AEBT"
piter@piter:~$ pulseaudio -k
piter@piter:~$ pactl list sinks | grep -e bluez -e a2dp_codec
	Name: bluez_sink.00_1B_66_84_1D_AF.headset_head_unit
	Driver: module-bluez5-device.c
	Monitor Source: bluez_sink.00_1B_66_84_1D_AF.headset_head_unit.monitor
		device.api = "bluez"
		bluez.path = "/org/bluez/hci0/dev_00_1B_66_84_1D_AF"
		bluez.class = "0x240404"
		bluez.alias = "MOMENTUM M2 AEBT"

At the first glance it may seem like a bandwidth or link quality issue, but there are some points that make me think this is not the case:

  1. Everything is fine when I use the mobile phone (also with aptX) in the same environment, I can even be at a significant distance from the phone and everything is fine.
  2. Headphones are really close to the PC.
  3. Nothing in the environment changed, at the beginning it was fine.

After the issue has been observed I tried things like:

  1. Installing the package again,
  2. Compiling it from the source.
  3. Setting an option MultiProfile = multiple in /etc/bluetooth/main.conf seemed to work for a day, but the issue reoccurred.
  4. Manually switching output source back and forth sometimes used to fix it for a short time, but now it does not do the job.
  5. After pulseaudio -k there are no cracks, but executing it every headphones connection is a pain and I think that sound quality decreases as well.

As I have no idea what additional information I could share please find some random logs below ;)

piter@piter:~$ uname -a
Linux piter 4.19.8-041908-generic #201812080831 SMP Sat Dec 8 13:34:18 UTC 2018 x86_64 x86_64 x86_64 GNU/Linux
piter@piter:~$ blue
bluedevil-sendfile  bluemoon            bluetoothctl
bluedevil-wizard    bluetooth           bluetoothd
piter@piter:~$ blue
bluedevil-sendfile  bluemoon            bluetoothctl
bluedevil-wizard    bluetooth           bluetoothd
piter@piter:~$ bluetoothctl -v
bluetoothctl: 5.48
piter@piter:~$ pulseaudio -v
I: [pulseaudio] main.c: setrlimit(RLIMIT_NICE, (31, 31)) failed: Operation not permitted
I: [pulseaudio] main.c: setrlimit(RLIMIT_RTPRIO, (9, 9)) failed: Operation not permitted
I: [pulseaudio] core-util.c: Successfully gained nice level -11.
I: [pulseaudio] main.c: This is PulseAudio 12.2
I: [pulseaudio] main.c: Page size is 4096 bytes
I: [pulseaudio] main.c: Machine ID is 4cb345eb2c51419bad365be3c01b80e8.
I: [pulseaudio] main.c: Session ID is 3.
I: [pulseaudio] main.c: Using runtime directory /run/user/1000/pulse.
I: [pulseaudio] main.c: Using state directory /home/piter/.config/pulse.
I: [pulseaudio] main.c: Using modules directory /usr/lib/pulse-12.2/modules.
I: [pulseaudio] main.c: Running in system mode: no
E: [pulseaudio] pid.c: Daemon already running.
E: [pulseaudio] main.c: pa_pid_file_create() failed.

I messed a lot with the bt/modules maybe I should clean the BT and pulseaudio modules installation?
How can I do it to be sure that the setup is as good as it can be?

Any hints are very welcome!

Kind regards,
Piotr

High Latency due to forced LDAC?

Is there a way to force aptX Low Latency given that quality isn't the only discerning factor in these standards or has aptX LL not been reverse engineered? Or would the latency difference be negligible

SBC codec is marked "unavailable" on AirPods

$ bluetoothctl
[bluetooth]# connect 24:F6:77:DD:EE:00
Attempting to connect to 24:F6:77:DD:EE:00
[CHG] Device 24:F6:77:DD:EE:00 Connected: yes
Connection successful
[CHG] Device 24:F6:77:DD:EE:00 ServicesResolved: yes
[intelfx-pods]#
$ pactl list cards
<...>
Card #6
        Name: bluez_card.24_F6_77_DD_EE_00
        Driver: module-bluez5-device.c
        Owner Module: 30
        Properties:
                device.description = "intelfx-pods"
                device.string = "24:F6:77:DD:EE:00"
                device.api = "bluez"
                device.class = "sound"
                device.bus = "bluetooth"
                device.form_factor = "headphone"
                bluez.path = "/org/bluez/hci0/dev_24_F6_77_DD_EE_00"
                bluez.class = "0x240418"
                bluez.alias = "intelfx-pods"
                device.icon_name = "audio-headphones-bluetooth"
        Profiles:
                a2dp_sink_sbc: High Fidelity Playback (A2DP Sink: SBC) (sinks: 1, sources: 0, priority: 40, available: no)
                a2dp_sink_aac: High Fidelity Playback (A2DP Sink: AAC) (sinks: 1, sources: 0, priority: 40, available: yes)
                a2dp_sink_aptx: High Fidelity Playback (A2DP Sink: aptX) (sinks: 1, sources: 0, priority: 40, available: no)
                a2dp_sink_aptx_hd: High Fidelity Playback (A2DP Sink: aptX HD) (sinks: 1, sources: 0, priority: 40, available: no)
                a2dp_sink_ldac: High Fidelity Playback (A2DP Sink: LDAC) (sinks: 1, sources: 0, priority: 40, available: no)
                headset_head_unit: Headset Head Unit (HSP/HFP) (sinks: 1, sources: 1, priority: 30, available: no)
                off: Off (sinks: 0, sources: 0, priority: 0, available: yes)
        Active Profile: a2dp_sink_aac
        Ports:
                headphone-output: Headphone (priority: 0, latency offset: 0 usec, available)
                        Part of profile(s): a2dp_sink_sbc, a2dp_sink_aac, a2dp_sink_aptx, a2dp_sink_aptx_hd, a2dp_sink_ldac, headset_head_unit
                headphone-input: Bluetooth Input (priority: 0, latency offset: 0 usec, not available)
                        Part of profile(s): headset_head_unit

Note that the SBC profile is "available: no":

a2dp_sink_sbc: High Fidelity Playback (A2DP Sink: SBC) (sinks: 1, sources: 0, priority: 40, available: no)

I think this is wrong because these headphones work with stock PulseAudio (which presumably does not support any of the advanced codecs).

sony wh-1000xm2 using AptX HD instead of LDAC

pactl list sinks | grep -e bluez -e a2dp_codec Name: bluez_sink.04_5D_4B_DE_B9_93.a2dp_sink Driver: module-bluez5-device.c Monitor Source: bluez_sink.04_5D_4B_DE_B9_93.a2dp_sink.monitor bluetooth.a2dp_codec = "APTX_HD" device.api = "bluez" bluez.path = "/org/bluez/hci0/dev_04_5D_4B_DE_B9_93" bluez.class = "0x240404" bluez.alias = "WH-1000XM2"

Seems weird to me as it should automatically detect LDAC is enabled properly. I have libldac installed through the AUR, and it works on my phone.

Is there a config option to force AAC codec?

I had an early preview of this module installed on Fedora 29 and noticed that my AKG-Y50BT was connecting using AAC codec instead of AptX as I expected.
After updating to Fedora 30 headphones begin constantly connecting via AptX codec. And surprisingly I found myself preferring AAC more.

Is there a config option to "force" AAC? I did changed bluetooth.service as WIKI describing, but don't see AAC in KDE profiles selection window.

GPL is incompatible with FDK-AAC - redistribution permission needed for Fedora/RPMFusion

See this:

FSF issued a clear statement that the fdk-aac is GPL incompatible
https://www.gnu.org/licenses/license-list.en.html#fdk
Can you clarify with upstream about this ?
Please ask upstream to send an email to explicitly allow us to redistribute
the software when built with fdk-aac.

Please send the email at [email protected] from an upstream maintainer (using public maillist list).
The email will be added to the scm if allowed.
Thx in advances.

2 issues:

  • GPL incompatibility, see here, and for fdk-aac-free, here
  • From your public email, please send an email to the above address, cc me, too (gombosg at gmail dotcom)

e.g.

I, xx, upstream developer of the pulseaudio-modules-bluetooth-freeworld package explicitly allow RPMFusion to redistribute the software when built with fdk-aac libraries.

Thanks!

Building on Fedora 29

pkg-config libpulse --modversion returns 12.2-rebootstrapped
This causes a linker error because the actual lib is just /usr/lib/pulseaudio/libpulsecommon-12.2.so, but gcc wants to link -lpulsecommon-12.2-rebootstrapped

AAC passthrough?

I wonder if it's possible / doable / desirable to support some sort of AAC passthrough via PA's compressed stream passthrough feature, so that reencoding could be skipped if one plays an AAC-encoded stream on a bluetooth device that supports AAC natively?

glitches or crackling

It's better to separate processes to multiple threads, and store encoded data with queue instead of transport data after encoding immediately.

crackling sound / bandwith problem?

hi! first of all thank you, its awesome to have ldac on my notebook!

not 100% sure if this is an actual issue or my hardware is just crap ( i tried with usb bluetooth chips too though):

especially when using ldac_eqmid=hq i get a lot of crackling, probably a bandwith problem.
even if i rfkill block the wifi ( Intel Dual Band Wireless-AC 8265 ).

my questions:

  • is there a way to get more debug information, i.e. what quality is actually being used if ldac_eqmid=abr is set ?
  • is there other options to tune the bt stack e.g. adding more buffer ? (on os-x you can tune the buffers)
  • do the pulseaudio settings such as default-sample-format default-sample-rate and resample-method influence LDAC playback ?

Just wanted to thank you

Also don't worry about the poor English, it's not as important as amazing code and features like yours :)

Disable some profiles

My android phone starting play as SBC, then immediately switch to the aptX HD. I've tried to select LDAC through developer options seems no Bluetooth setting in there affect anything (nor bitrate nothing). But even if it did, there is no way to save selected profile, this option is temporary, for debugging purposes.
I am using loud expensive speakers with dolby digital plus audio card, and I would like to play from my phone wireless. aptX HD is not good enough, I clearly hear distortions. Its still "fine" though.

So, could i "hide" blueZ support of aptX codec for example? Or show it with a huge delay?

Ideal flow for devices with no LDAC support:

Connecting
Playing as SBC
Got the support of LDAC
Still playing as SBC
Got the support of aptX
Switching there as it preferable by Android ROM

Ideal flow for devices with LDAC support:

Connecting
Playing as SBC
Got the support of LDAC
Switching to LDAC there as it preferable by Android ROM
Got the support of aptX (or if it possible don't get data about it at all)
Still playing as LDAC cause they considered similar

I've read https://github.com/EHfive/pulseaudio-modules-bt/wiki#can-i-choose-codec-
But my OnePlus 5T with Android 8.1 has built-in LDAC support, and it still:

pactl list sources | grep -e bluez -e a2dp_codec
	Name: bluez_source.94_65_2D_C0_F5_5F.a2dp_source
	Driver: module-bluez5-device.c
		bluetooth.a2dp_codec = "APTX_HD"
		device.api = "bluez"
		bluez.path = "/org/bluez/hci0/dev_94_65_2D_C0_F5_5F"
		bluez.class = "0x5a020c"
		bluez.alias = "xxx"

Autoconnected device won't switch to A2DP sink profile

Thank you for this fantastic project first of all! It works great! However there's a small issue with bluetooth auto connect.

To be more elaborative, if I turn off my headphone while connected to a computer, and then turn the headphone back on again, the headphone will automatically reconnect, but in a low quality mono channel 8kHz mode. However, this can be easily fixed by simply disconnect and reconnect again (from the computer using commands like echo disconnect <MAC> | bluetoothctl; echo connect <MAC> | bluetoothctl). After the reconnection it will be in LDAC mode as expected.

I'm not familiar with pulseaudio or bluetooth, so this might be a trivial question, but I searched the Internet and find no useful information to this situation.

Here's some basic info:

OS: Gentoo x64 with Linux kernel 4.18.6
Wireless adapter: 03:00.0 Network controller [0280]: Broadcom Inc. and subsidiaries BCM4360 802.11ac Wireless Network Adapter [14e4:43a0] (rev 03)
Headphone: MDR-1000X
pulseaudio --version: pulseaudio 12.2
bluetoothctl --version: bluetoothctl: 5.50
Here's some outputs from `pactl list sinks` (Click to expand)
# after bluetooth autoconnect (low quality mode)
Sink #25
	State: SUSPENDED
	Name: bluez_sink.<MASKED>.headset_head_unit
	Description: MDR-1000X
	Driver: module-bluez5-device.c
	Sample Specification: s16le 1ch 8000Hz
	Channel Map: mono
	Owner Module: 48
	Mute: no
	Volume: mono: 38610 /  59%
	        balance 0.00
	Base Volume: 65536 / 100%
	Monitor Source: bluez_sink.<MASKED>.headset_head_unit.monitor
	Latency: 0 usec, configured 0 usec
	Flags: HARDWARE HW_VOLUME_CTRL LATENCY 
	Properties:
		bluetooth.protocol = "headset_head_unit"
		device.intended_roles = "phone"
		device.description = "MDR-1000X"
		device.string = "<MASKED>"
		device.api = "bluez"
		device.class = "sound"
		device.bus = "bluetooth"
		device.form_factor = "headset"
		bluez.path = "/org/bluez/hci0/dev_<MASKED>"
		bluez.class = "0x240404"
		bluez.alias = "MDR-1000X"
		device.icon_name = "audio-headset-bluetooth"
	Ports:
		headset-output: Headset (priority: 0)
	Active Port: headset-output
	Formats:
		pcm


# after reconnection (normal, LDAC)
Sink #27
	State: SUSPENDED
	Name: bluez_sink.<MASKED>.a2dp_sink
	Description: MDR-1000X
	Driver: module-bluez5-device.c
	Sample Specification: s32le 2ch 44100Hz
	Channel Map: front-left,front-right
	Owner Module: 50
	Mute: no
	Volume: front-left: 32717 /  50% / -18.10 dB,   front-right: 32717 /  50% / -18.10 dB
	        balance 0.00
	Base Volume: 65536 / 100% / 0.00 dB
	Monitor Source: bluez_sink.<MASKED>.a2dp_sink.monitor
	Latency: 0 usec, configured 0 usec
	Flags: HARDWARE DECIBEL_VOLUME LATENCY 
	Properties:
		bluetooth.protocol = "a2dp_sink"
		bluetooth.a2dp_codec = "LDAC"
		device.description = "MDR-1000X"
		device.string = "<MASKED>"
		device.api = "bluez"
		device.class = "sound"
		device.bus = "bluetooth"
		device.form_factor = "headset"
		bluez.path = "/org/bluez/hci0/dev_<MASKED>"
		bluez.class = "0x240404"
		bluez.alias = "MDR-1000X"
		device.icon_name = "audio-headset-bluetooth"
		device.intended_roles = "phone"
	Ports:
		headset-output: Headset (priority: 0)
	Active Port: headset-output
	Formats:
		pcm
And my `/etc/pulse/default.pa` config (Click to expand)
#!/usr/bin/pulseaudio -nF
#
# This file is part of PulseAudio.
#
# PulseAudio is free software; you can redistribute it and/or modify it
# under the terms of the GNU Lesser General Public License as published by
# the Free Software Foundation; either version 2 of the License, or
# (at your option) any later version.
#
# PulseAudio is distributed in the hope that it will be useful, but
# WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
# General Public License for more details.
#
# You should have received a copy of the GNU Lesser General Public License
# along with PulseAudio; if not, see <http://www.gnu.org/licenses/>.

# This startup script is used only if PulseAudio is started per-user
# (i.e. not in system mode)

.fail

### Automatically restore the volume of streams and devices
load-module module-device-restore
load-module module-stream-restore
load-module module-card-restore

### Automatically augment property information from .desktop files
### stored in /usr/share/application
load-module module-augment-properties

### Should be after module-*-restore but before module-*-detect
load-module module-switch-on-port-available

### Load audio drivers statically
### (it's probably better to not load these drivers manually, but instead
### use module-udev-detect -- see below -- for doing this automatically)
#load-module module-alsa-sink
#load-module module-alsa-source device=hw:1,0
#load-module module-null-sink
#load-module module-pipe-sink

### Automatically load driver modules depending on the hardware available
.ifexists module-udev-detect.so
load-module module-udev-detect
.else
### Use the static hardware detection module (for systems that lack udev support)
load-module module-detect
.endif

### Automatically connect sink and source if JACK server is present
.ifexists module-jackdbus-detect.so
.nofail
load-module module-jackdbus-detect channels=2
.fail
.endif

### Automatically load driver modules for Bluetooth hardware
.ifexists module-bluetooth-policy.so
load-module module-bluetooth-policy
.endif

.ifexists module-bluetooth-discover.so
# load-module module-bluetooth-discover
load-module module-bluetooth-discover a2dp_config="ldac_eqmid=abr ldac_fmt=s32"
.endif



### Load several protocols
.ifexists module-esound-protocol-unix.so
load-module module-esound-protocol-unix
.endif
load-module module-native-protocol-unix

### Network access (may be configured with paprefs, so leave this commented
### here if you plan to use paprefs)
#load-module module-esound-protocol-tcp
#load-module module-native-protocol-tcp

### Load the RTP receiver module (also configured via paprefs, see above)
#load-module module-rtp-recv

### Load the RTP sender module (also configured via paprefs, see above)
#load-module module-null-sink sink_name=rtp format=s16be channels=2 rate=44100 sink_properties="device.description='RTP Multicast Sink'"
#load-module module-rtp-send source=rtp.monitor

### Load additional modules from GSettings. This can be configured with the paprefs tool.
### Please keep in mind that the modules configured by paprefs might conflict with manually
### loaded modules.
.ifexists module-gsettings.so
.nofail
load-module module-gsettings
.fail
.endif


### Automatically restore the default sink/source when changed by the user
### during runtime
### NOTE: This should be loaded as early as possible so that subsequent modules
### that look up the default sink/source get the right value
load-module module-default-device-restore

### Automatically move streams to the default sink if the sink they are
### connected to dies, similar for sources
load-module module-rescue-streams

### Make sure we always have a sink around, even if it is a null sink.
load-module module-always-sink

### Honour intended role device property
load-module module-intended-roles

### Automatically suspend sinks/sources that become idle for too long
load-module module-suspend-on-idle

### If autoexit on idle is enabled we want to make sure we only quit
### when no local session needs us anymore.
.ifexists module-console-kit.so
load-module module-console-kit
.endif
.ifexists module-systemd-login.so
load-module module-systemd-login
.endif

### Enable positioned event sounds
load-module module-position-event-sounds

### Cork music/video streams when a phone stream is active
load-module module-role-cork

### Modules to allow autoloading of filters (such as echo cancellation)
### on demand. module-filter-heuristics tries to determine what filters
### make sense, and module-filter-apply does the heavy-lifting of
### loading modules and rerouting streams.
load-module module-filter-heuristics
load-module module-filter-apply

### Make some devices default
#set-default-sink output
#set-default-source input

build error

I get the following error when I type make:
pulseaudio-modules-bt/src/modules/bluetooth/module-bluetooth-discover.c:52:9: error: too many arguments to function ‘pa_module_load’ pa_module_load(&mm, m->core, "module-bluez5-discover", m->argument);

a2dp_sink_*: Unavailable profile (except SBC)

Fedora 29 with latest pulseaudio-module-bluetooth-freeworld package:

Name        : pulseaudio-module-bluetooth-freeworld
Version     : 1.1
Release     : 3.fc29
Architecture: x86_64
Install Date: mar 09 abr 2019 10:52:52 CEST
Group       : Unspecified
Size        : 257920
License     : GPLv3
Signature   : RSA/SHA1, jue 04 abr 2019 16:54:04 CEST, Key ID 1191a7c442f19ed0
Source RPM  : pulseaudio-module-bluetooth-freeworld-1.1-3.fc29.src.rpm
Build Date  : mié 03 abr 2019 19:35:01 CEST
Build Host  : buildvm-06.virt.rpmfusion.net
Relocations : (not relocatable)
Packager    : RPM Fusion
Vendor      : RPM Fusion
URL         : https://github.com/EHfive/pulseaudio-modules-bt/
Summary     : Bluetooth support for the PulseAudio sound server, supports aptX, LDAC codecs
Description :
Contains Bluetooth audio (A2DP/HSP/HFP) support for the PulseAudio sound server.
Includes support for LDAC, aptX and aptX-HD codecs.

I can select aptX, aptX-HD and LDAP codecs with pavucontrol or gnome settings but it doesn't work.

Journalctl says:

abr 11 14:21:55 galactica.minwi.lan pulseaudio[2276]: W: [pulseaudio] module-bluez5-device.c: Refused to switch profile to a2dp_sink_ldac: Unavailable profile
abr 11 14:21:58 galactica.minwi.lan pulseaudio[2276]: W: [pulseaudio] module-bluez5-device.c: Refused to switch profile to a2dp_sink_aptx_hd: Unavailable profile
abr 11 14:22:00 galactica.minwi.lan pulseaudio[2276]: W: [pulseaudio] module-bluez5-device.c: Refused to switch profile to a2dp_sink_aptx: Unavailable profile

Trying to package for Fedora 29

Hi, I'd like to make a COPR repo for this in Fedora since aptX is working great when building with your instructions.
I only want to upload the pulseaudio-module-bluetooth to the repo and not the whole PA to avoid issues - PA is an important package.
I tried the patch the current PA source SRPM package with your patches for the best system compatibility.

I applied them in order:

%patch901 -p1 -b _v1_1.a2dp
%patch902 -p1 -b _v1_2.a2dp_property
%patch903 -p1 -b _v1_3.ldac_header
%patch905 -p1 -b _v1_5.fix_ldac_frequencies
%patch906 -p1 -b _v2.1_1.aptx_aptx_hd_fix
%patch907 -p1 -F2 -b _v2.1_2.buildfile

They applied fine, but build fails with

modules/bluetooth/a2dp/a2dp_aptx.c:5:10: fatal error: libavcodec/avcodec.h: No such file or directory
 #include <libavcodec/avcodec.h>

It finds libavcodec during the configure phase:

checking for FF_AVCODEC... yes
checking for FF_AVUTIL... yes

And yet it fails.
I know I should contact the packager maybe but maybe you know why this fails or at least point me to the right direction why make doesn't find this folder (e.g. by adding the correct -I parameter).

Here's the complete build log with the error at the end:
build.log

Here's my modified RPM spec file:
pulseaudio.spec.txt
At line 335 you can see the configure parameters, maybe those are the culprit.

It would be my first package ever so I don't have much experience so I appreciate the help.

Enable AAC afterburner by default ?

Hello,

Since the AAC support is done through the Fraunhofer FDK AAC library, I've had a look at their wiki and they recommend to always enable the afterburner feature since it brings better quality (at the expense of more processing power required). However, the current implementation here disables it by defaut, so my question is shouldn't it be enabled instead ?

My source is: https://wiki.hydrogenaud.io/index.php?title=Fraunhofer_FDK_AAC#Afterburner

Thanks ! :)

patches don't apply

could you please release just one single (and complete) patch against pulsaudio-12.2 or so?
or even better: fork the pulseaudio repo and apply your changes to an extra branch, having a own build system and overwriting files on a users system isn't a good way to go, anyway

besides from that, love your work :)

Resume crashes on Manjaro

I installed this repo on Manjaro via https://aur.archlinux.org/packages/pulseaudio-modules-bt-git/ but I've found out that resuming from suspend basically dies. As soon as the laptop is woken up it is restarted - the title might be misleading but I didn't know how to describe the problem in few words.

There is nothing in the journal and I've been trying 4.18 and also 4.14.
I had to uninstall it and since then I can resume my laptop again.

Include Ubuntu 16.04 in the package

I had a tough time building the package on Ubuntu 16.04.5. Any chance this version could be added to the PPA? I'd love to use this!
Thanks

Check if bluetooth device supports LDAC/aptX HD/aptX/AAC and details

I'm on Debian testing and before I mess around trying to get Ubuntu PPA working on Debian, is there anyway to verify that my device supports those codecs in the first place?

$ pactl list | grep codec
$ pulseaudio --version
pulseaudio 12.2

There doesn't seem to be any codec entry in the output of pactl list. Is there any prods I can use to poke at my headset and find out what codecs it supports?

PS Idol animes are trash.

Multimedia keys on headphones doesn't work

Arch Linux 5.0.8-arch1-1-ARCH, after installation of pulseaudio-modules-bt-git multimedia keys on the headphones stops working. Tested on 2 different headphones. After reverting to pulseaudio-bluetooth multimedia keys starts working again. In journalctl I have this
bluetoothd[522]: avrcp-controller profile connect failed for FC:58:FA:00:BB:4E: Input/output error
both on pulseaudio-modules-bt-git and pulseaudio-bluetooth, but on pulseaudio-bluetooth keys worked perfectly.

make failed

failed if pulseaudio version is lower than 12

[ 6%] Linking C shared library libbluez5-util.so
[ 25%] Built target bluez5-util
[ 31%] Linking C shared library libldacBT_enc.so
[ 50%] Built target ldacBT_enc
[ 56%] Building C object CMakeFiles/module-bluetooth-discover.dir/pa/src/modules/bluetooth/module-bluetooth-discover.c.o
:0:0: warning: "FILE" redefined [-Wbuiltin-macro-redefined]
In file included from /home/user/pulseaudio-modules-bt/pa/src/modules/bluetooth/module-bluetooth-discover.c:24:0:
/home/user/pulseaudio-modules-bt/pa/src/pulsecore/core-util.h:296:42: warning: ‘struct sockaddr’ declared inside parameter list will not be visible outside of this definition or declaration
int pa_accept_cloexec(int sockfd, struct sockaddr *addr, socklen_t *addrlen);
^~~~~~~~
/home/user/pulseaudio-modules-bt/pa/src/modules/bluetooth/module-bluetooth-discover.c:28:10: fatal error: module-bluetooth-discover-symdef.h: Нет такого файла или каталога
#include "module-bluetooth-discover-symdef.h"
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
compilation terminated.
CMakeFiles/module-bluetooth-discover.dir/build.make:62: recipe for target 'CMakeFiles/module-bluetooth-discover.dir/pa/src/modules/bluetooth/module-bluetooth-discover.c.o' failed
make[2]: *** [CMakeFiles/module-bluetooth-discover.dir/pa/src/modules/bluetooth/module-bluetooth-discover.c.o] Error 1
CMakeFiles/Makefile2:141: recipe for target 'CMakeFiles/module-bluetooth-discover.dir/all' failed
make[1]: *** [CMakeFiles/module-bluetooth-discover.dir/all] Error 2
Makefile:129: recipe for target 'all' failed
make: *** [all] Error 2

lsb_release -a
No LSB modules are available.
Distributor ID: Ubuntu
Description: Ubuntu 18.04.1 LTS
Release: 18.04
Codename: bionic

Building DEB package

I've managed to get a working DEB package by building the binary as described (cmake .. && make).
Since I really hope this will be merged to the original PulseAudio (and, consequently will end up in repositories sooner or later), I did not bother with fancy stuff and using CPack.

However, I wanted to share my script for re-building pulseaudio-module-bluetooth using binaries build from these sources and the original DEB shenanigans from (Ubuntu/Debian) repository.

#!/bin/bash

# Builds pulseaudio-module-bluetooth DEB in current directory
# using binaries from CMake build
# Usage:
#
#   # do the cmake build, e.g.
#   git clone ... && mkdir build && cd build && cmake .. && make
#
#   # build a DEB from that binaries on Ubuntu (or maybe Debian)
#   cd ..
#   mkdir deb && cd deb
#   wget $THIS_SCRIPT_URL -O pkg-build.sh
#   ./pkg-build.sh
#
# This would generate a .deb file with -9git~<hash> in name, install it

BUILD_DIR=$1
PKG_NAME=pulseaudio-module-bluetooth
OS_CODENAME=$(lsb_release -sc)
# agli huck
#REPO_VERSION=$(apt policy "${PKG_NAME}" | grep ubuntu | head -n 1 | awk '{print $1}')

[ ! -d "$BUILD_DIR" ] && BUILD_DIR="../build"
if [ ! -d "$BUILD_DIR" ]; then
  echo "## ERROR: specify build directory with binaries as first argument" >&2
  exit 1
fi

rm -rf "$PKG_NAME"
rm -f *.deb

apt download "${PKG_NAME}/${OS_CODENAME}"

ORIG_PKG=$(find . -maxdepth 1 -name "${PKG_NAME}*.deb")

# extract original packages
mkdir "${PKG_NAME}"
dpkg-deb -x "${ORIG_PKG}" "${PKG_NAME}"
dpkg-deb -e "${ORIG_PKG}" "${PKG_NAME}/DEBIAN"

PLUGINS_DIR="$(find "$PKG_NAME" -type d -name 'pulse-*.*')/modules"

# copy new binaries
find "$BUILD_DIR" -maxdepth 1 -type f -name '*.so' -print -exec cp {} "${PLUGINS_DIR}" \;

# update version
GIT_HASH=$(git rev-parse --short HEAD)
TIMESTAMP=$(date '+%Y%m%d')
sed -e "s/^Version: \(.*\)$/Version: \1-9git+${TIMESTAMP}~${GIT_HASH}/" -i "${PKG_NAME}/DEBIAN/control"

# update md5sums
find "${PKG_NAME}" -type f ! -path "${PKG_NAME}/DEBIAN*" -exec md5sum {} + | sed -e "s|${PKG_NAME}/||g" > "${PKG_NAME}/DEBIAN/md5sums"

dpkg-deb -b "${PKG_NAME}" "${PKG_NAME}.deb"
dpkg-name "${PKG_NAME}.deb"

Doesn't build with fdk-aac 2.0

Latest 'Rawhide' version of Fedora comes with fdk-aac 2.0. Build fails with that since the build dependency is simply fdk-aac>=0.1.5 and 2.0 is accepted this way. Probably other distros will upgrade soon, as well.

Is it possible to add 2.0 support? (I know it's probably a breaking release.)

I have attached a build log.
build.log

Basically it's:

-- Checking for module 'fdk-aac>=0.1.5'
--   Found fdk-aac, version 2.0.0

but

BUILDSTDERR: /usr/bin/ld: cannot find -lfdk-aac

Here's the fdk-aac-devel-2.0 package info and here are all the new fdk-aac packages.

Let me know if this is a Fedora packaging issue, but the 2.0 update was as simple as a version bump. (Which only modified the source URL, with the same build config)

Thanks!

A2DP Sink dont support microphone

How can I use the microphone in a good quality as well? When I switch to A2DP Sink it doesn't show any recording device for my Mi Sports BT Earphones

a2dp_aptx.c: Error submitting the packet to the decoder

Hi, I have issue with aptx_HD sync

[aptx_hd @ 0x555cfda92f40] Synchronization error
D: [bluetooth] a2dp_aptx.c: Error submitting the packet to the decoder

That's what I see in pulseaudio -vvv, a lot of messages like this (500+ lines).
When it's happening there is no sound at all from the phone.
It's became very randomly, you can listen to music 5-30 minutes and then no sound after changing songs or closing currently playing player at the phone. It will stop output errors only if you pause or closing current playing song or player. After it stops output errors music playing perfectly.

My setup:
linux: Archlinux
laptop: linux-lts (4.19.31-1), ffmpeg (1:4.1.2-1), pulseaudio (12.2-2 , 2channels - 24bit - 48000Hz),
raspberry pi: almost the same setup.
phone: Xiaomi Redmi 5 Plus, RR 7.0.1 + installed aptX libs
Tried with only one phone , haven't any other device supporting aptX.

Have tried with hardware solution CSRA64215, it's working without any issue.
Just curious if there is something wrong with my setup that's preventing sync for aptX.

P.S. Thanks a lot for this modules.

Thank you, StS.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.