• This repository has been archived on 25/Jan/2021
  • Stars
    star
    1,753
  • Rank 26,564 (Top 0.6 %)
  • Language
    C
  • License
    GNU General Publi...
  • Created over 6 years ago
  • Updated almost 4 years ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

[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

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/>.

More Repositories

1

einat-ebpf

An eBPF-based Endpoint-Independent(Full Cone) NAT for Linux
Rust
124
star
2

Some-js-script-for-FB2K

Foobar2000一些插件的js脚本
JavaScript
107
star
3

ldacBT

CMake build script for AOSP libldac
CMake
73
star
4

userscripts

Ehfive’s userscripts monorepo
JavaScript
38
star
5

v2ray-jsonschema

V2Ray v4, v5 configuration JSON schemas that build through Go type reflection
Go
20
star
6

fish-bash2env

A lightweight fish plugin to import environment variables set by given bash command/script.
Shell
12
star
7

pw-capture

Vulkan/OpenGL (game) capture for PipeWire
Rust
12
star
8

flakes

NixOS configurations & Nix packages for @EHfive's mail server & NanoPi R2S router
Nix
11
star
9

genshin-midi-lyre

Play midi file with Windsong Lyre in Genshin Impact
Python
10
star
10

LLproxy-web

LLproxy前端, 使用vue-cli实现, 依赖于webpack, 通过AJAX方法调用LLproxy-api呈现内容
Vue
6
star
11

LLproxy

LLproxy 后端代理服务, 用于收集lovelive!手游 国服的用户信息并存入MySQL数据库,使用DNS劫持及HTTP/HTTPS劫持收集甚至更改用户的HTTP request, response
Python
6
star
12

uefi-toys

UEFI tools including reset tool, loopback driver, util
Rust
3
star
13

LLproxy-api

LLproxy 后端api服务, 通过查询MySQL数据库为LLproxy-web前端提供大多数数据接口, 使用Flask Web框架 及 Flask-RESTful 框架实现 获取用户信息示例: https://llsif.sokka.cn/api/llproxy/userInfo/?uid=865384
Python
2
star
14

archlinux-eh5-repo

Arch user repo of eh5
Shell
1
star
15

spa-json

parse/stringify PipeWire SPA JSON in JavaScript
JavaScript
1
star
16

vscode-sops-fs

VS Code SOPS virtual filesystem extension
TypeScript
1
star
17

ash-layer

Vulkan layer bindings atop Ash
Rust
1
star
18

protonmail-proxy

[WIP] protonmail fake auth, API, IMAP/SMTP proxy(bridge) server
TypeScript
1
star
19

solidjs-mini-program-poc

SolidJS 小程序概念验证及研究
TypeScript
1
star