You are not logged in.
Pages: 1
The following is a simplified log of a BlueALSA session, with extraneous lines discreetly removed for clarity.
# COMMAND: Start BlueALSA with AAC codec and debug logging
sudo -u bluealsad bluealsad -p a2dp-source -p a2dp-sink -p hfp-ag -p hfp-hf -c -sbc -c aac -c msbc --aac-afterburner --aac-bitrate=320000 --aac-vbr --aac-true-bps --loglevel=debug
# DAEMON INITIALIZATION
bluealsad: [31361] D: log.c:701: FDK-AAC encoder capabilities: AAC=[AAC-LC AAC-SCAL DRC ] SBR=[SBR-PS ] DMX=[none]
bluealsad: [31361] D: log.c:701: FDK-AAC decoder capabilities: AAC=[AAC-LC HE-AAC AAC-LD AAC-ELD AAC-SCAL DRC ] SBR=[SBR-HQ SBR-PS ] DMX=[2ch 6ch 8ch ]
bluealsad: [31361] D: storage.c:86: Initializing persistent storage: /var/lib/bluealsa
bluealsad: [31361] D: main.c:707: Starting main dispatching loop
bluealsad: [31361] D: main.c:121: Acquired D-Bus service name: org.bluealsa
bluealsad: [31361] D: bluealsa-dbus.c:404: Registering BlueALSA D-Bus manager: /org/bluealsa
# AAC CODEC DISCOVERY
bluealsad: [31361] D: bluez.c:1271: Adding new Stream End-Point: EC:66:D1:BF:02:05: SNK: AAC
bluealsad: [31361] D: log.c:347: AAC_CODEC: AAC capabilities - Object Type=MPEG2-LC | MPEG4-LC, Sample Rate=8000 Hz | 11025 Hz | 12000 Hz | 16000 Hz | 22050 Hz | 24000 Hz | 32000 Hz | 44100 Hz | 48000 Hz, Channels=Mono | Stereo, VBR=enabled, Bitrate=320000
# AAC CODEC NEGOTIATION
bluealsad: [31361] D: dbus.c:43: Called: org.bluez.MediaEndpoint1.SelectConfiguration() on /org/bluez/hci0/A2DP/AAC/source/1
bluealsad: [31361] D: bluez.c:442: BlueZ endpoint select_configuration called
bluealsad: [31361] D: log.c:347: AAC_CODEC: _CODEC: A2DP peer capabilities - Object Type=MPEG2-LC | MPEG4-LC, Sample Rate=8000 Hz | 11025 Hz | 12000 Hz | 16000 Hz | 22050 Hz | 24000 Hz | 32000 Hz | 44100 Hz | 48000 Hz, Channels=Mono | Stereo, VBR=enabled, Bitrate=320000
bluealsad: [31361] D: a2dp-aac.c:664: AAC configuration_select called
bluealsad: [31361] D: dbus.c:43: Called: org.bluez.MediaEndpoint1.SetConfiguration() on /org/bluez/hci0/A2DP/AAC/source/1
bluealsad: [31361] D: log.c:347: AAC_CODEC: A2DP selected configuration - Object Type=MPEG4-LC, Sample Rate=48000 Hz, Channels=Stereo (2), VBR=enabled, Bitrate=320000
bluealsad: [31361] D: bluez.c:637: A2DP Source (AAC) configured for device EC:66:D1:BF:02:05
bluealsad: [31361] D: bluez.c:640: PCM configuration: channels=2 rate=48000
bluealsad: [31361] D: bluez.c:642: Delay reporting: unsupported
# AUDIO STREAMING SETUP
bluealsad: [31401] D: dbus.c:43: Called: org.bluealsa.PCM1.Open() on /org/bluealsa/hci0/dev_EC_66_D1_BF_02:05/a2dpsrc/sink
bluealsad: [31401] D: ba-transport.c:316: New A2DP transport: 28
bluealsad: [31401] D: ba-transport.c:317: A2DP socket MTU: 28: R:672 W:895
bluealsad: [31361] D: ba-transport.c:1082: Starting transport: A2DP Source (AAC)
bluealsad: [31361] D: ba-transport-pcm.c:287: Created BT socket duplicate: [28]: 29
bluealsad: [31361] D: ba-transport-pcm.c:366: Created new IO thread [ba-a2dp-aac]: A2DP Source (AAC)
bluealsad: [31419] D: a2dp-aac.c:332: AAC_CODEC: Encoder Info - FrameLength=1024, InputChannels=2, MaxOutBufBytes=1536, Delay=1600 samples
bluealsad: [31419] D: a2dp-aac.c:336: AAC_CODEC: Configuration - Bitrate=320000, Afterburner=enabled, VBR=enabled, Quality=VBR
bluealsad: [31419] D: a2dp-aac.c:391: PCM IO loop: START: a2dp_aac_enc_thread: A2DP Source (AAC)
# AAC Frame Monitoring
bluealsad: [31419] D: a2dp-aac.c:419: AAC_CODEC: Frame - Output bytes=497, Target bitrate=320000
bluealsad: [31419] D: a2dp-aac.c:419: AAC_CODEC: Frame - Output bytes=496, Target bitrate=320000
bluealsad: [31419] D: a2dp-aac.c:419: AAC_CODEC: Frame - Output bytes=600, Target bitrate=320000
bluealsad: [31419] D: a2dp-aac.c:419: AAC_CODEC: Frame - Output bytes=469, Target bitrate=320000 Command Line Options
sudo -u bluealsad bluealsad -p a2dp-source -p a2dp-sink -p hfp-ag -p hfp-hf -c -sbc -c aac -c msbc --aac-afterburner --aac-bitrate=320000 --aac-vbr --aac-true-bps --loglevel=debugsudo -u bluealsad: Runs the daemon under a dedicated user—nothing excessive, just sound security practice.
-p a2dp-source -p a2dp-sink: Enables bidirectional audio. One might call it thorough.
-p hfp-ag -p hfp-hf: Supports hands-free calling. Useful, if one must.
-c aac: Enables the AAC codec—rather more refined than the alternatives.
--aac-afterburner: Activates Fraunhofer’s quality enhancement. It does its work quietly.
--aac-bitrate=320000: Sets a generous bitrate. One might say it leaves nothing wanting.
--aac-vbr: Prefers variable bit rate—efficient without being showy.
--aac-true-bps: Ensures accurate bit-per-second reporting. A minor detail, but a correct one.
--loglevel=debug: Enables verbose logging. Helpful, if one is inclined to look.
NOTE: To enable debug, you have to compile bluez-alsa with --enable-debug. Then you can run bluealsad daemon with --loglevel=debug.
Security:
./configure --with-bluealsaduser=bluealsad # D-Bus policy files are automatically generated with the correct user permissionsRunning BlueALSA as the bluealsad user is not an indulgence—it is a matter of principle. The daemon operates with minimal privileges, should anything untoward occur.
Least Privilege: The bluealsad user has no unnecessary access. One might say it knows its place.
Systemd Sandboxing: Features such as ProtectSystem=strict and IPAddressDeny=any ensure the service remains discreet.
D-Bus Policy Control: Communication is limited to org.bluealsa. No eavesdropping, no surprises.
Filesystem Confinement: The daemon is restricted to /var/lib/bluealsa. One might call it tidy.
This is not paranoia—it is simply good form.
Daemon Startup Process
# FDK-AAC library capabilities - what audio formats we can encode/decode
bluealsad: [31361] D: log.c:701: FDK-AAC encoder capabilities: AAC=[AAC-LC AAC-SCAL DRC ] SBR=[SBR-PS ] DMX=[none]
bluealsad: [31361] D: log.c:701: FDK-AAC decoder capabilities: AAC=[AAC-LC HE-AAC AAC-LD AAC-ELD AAC-SCAL DRC ] SBR=[SBR-HQ SBR-PS ] DMX=[2ch 6ch 8ch ]EXPLANATION: BlueALSA checks what AAC formats your system supports. The encoder can handle basic AAC-LC and scalable coding, while the decoder supports advanced formats like HE-AAC for better compression.
# System initialization
bluealsad: [31361] D: storage.c:86: Initializing persistent storage: /var/lib/bluealsa
bluealsad: [31361] D: main.c:707: Starting main dispatching loop
bluealsad: [31361] D: main.c:121: Acquired D-Bus service name: org.bluealsa
bluealsad: [31361] D: bluealsa-dbus.c:404: Registering BlueALSA D-Bus manager: /org/bluealsaEXPLANATION: BlueALSA starts up, creates storage for remembering device settings, and registers with the Linux D-Bus system so applications can communicate with it.
AAC Codec Discovery
# Device announces its AAC support
bluealsad: [31361] D: bluez.c:1271: Adding new Stream End-Point: EC:66:D1:BF:02:05: SNK: AAC
bluealsad: [31361] D: log.c:347: AAC_CODEC: AAC capabilities - Object Type=MPEG2-LC | MPEG4-LC, Sample Rate=8000 Hz | 11025 Hz | 12000 Hz | 16000 Hz | 22050 Hz | 24000 Hz | 32000 Hz | 44100 Hz | 48000 Hz, Channels=Mono | Stereo, VBR=enabled, Bitrate=320000EXPLANATION: The Bluetooth device, that is, BT Headphones, EC:66:D1:BF:02:05 tells BlueALSA it supports AAC audio. It can handle many sample rates from 8kHz (voice quality) up to 48kHz (CD quality), supports mono and stereo, and can use Variable Bit Rate for efficient encoding.
AAC Codec Negotiation
# BlueZ asks BlueALSA to select the best AAC configuration
bluealsad: [31361] D: dbus.c:43: Called: org.bluez.MediaEndpoint1.SelectConfiguration() on /org/bluez/hci0/A2DP/AAC/source/1
bluealsad: [31361] D: bluez.c:442: BlueZ endpoint select_configuration called
bluealsad: [31361] D: log.c:347: AAC_CODEC: _CODEC: A2DP peer capabilities - Object Type=MPEG2-LC | MPEG4-LC, Sample Rate=8000 Hz | 11025 Hz | 12000 Hz | 16000 Hz | 22050 Hz | 24000 Hz | 32000 Hz | 44100 Hz | 48000 Hz, Channels=Mono | Stereo, VBR=enabled, Bitrate=320000
bluealsad: [31361] D: a2dp-aac.c:664: AAC configuration_select calledEXPLANATION: The Bluetooth system (BlueZ) asks BlueALSA to choose the best AAC settings. BlueALSA looks at what the device (that is, BT Headphones) supports and selects optimal parameters.
# Final configuration is selected and applied
bluealsad: [31361] D: dbus.c:43: Called: org.bluez.MediaEndpoint1.SetConfiguration() on /org/bluez/hci0/A2DP/AAC/source/1
bluealsad: [31361] D: log.c:347: AAC_CODEC: A2DP selected configuration - Object Type=MPEG4-LC, Sample Rate=48000 Hz, Channels=Stereo (2), VBR=enabled, Bitrate=320000
bluealsad: [31361] D: bluez.c:637: A2DP Source (AAC) configured for device EC:66:D1:BF:02:05
bluealsad: [31361] D: bluez.c:640: PCM configuration: channels=2 rate=48000
bluealsad: [31361] D: bluez.c:642: Delay reporting: unsupportedEXPLANATION: BlueALSA selects the best quality settings: MPEG4-LC at 48kHz stereo with 320kbps VBR. This provides near-CD quality audio. The PCM is configured to match these settings.
Audio Streaming Setup
# Application requests to play audio
bluealsad: [31401] D: dbus.c:43: Called: org.bluealsa.PCM1.Open() on /org/bluealsa/hci0/dev_EC_66_D1_BF_02:05/a2dpsrc/sink
bluealsad: [31401] D: ba-transport.c:316: New A2DP transport: 28
bluealsad: [31401] D: ba-transport.c:317: A2DP socket MTU: 28: R:672 W:895EXPLANATION: An application (like mpv) asks to play audio through the Bluetooth device. BlueALSA creates a transport channel with MTU (Maximum Transmission Unit) settings for efficient data transfer.
# Audio encoding starts
bluealsad: [31361] D: ba-transport.c:1082: Starting transport: A2DP Source (AAC)
bluealsad: [31361] D: ba-transport-pcm.c:287: Created BT socket duplicate: [28]: 29
bluealsad: [31361] D: ba-transport-pcm.c:366: Created new IO thread [ba-a2dp-aac]: A2DP Source (AAC)
bluealsad: [31419] D: a2dp-aac.c:332: AAC_CODEC: Encoder Info - FrameLength=1024, InputChannels=2, MaxOutBufBytes=1536, Delay=1600 samples
bluealsad: [31419] D: a2dp-aac.c:336: AAC_CODEC: Configuration - Bitrate=320000, Afterburner=enabled, VBR=enabled, Quality=VBR
bluealsad: [31419] D: a2dp-aac.c:391: PCM IO loop: START: a2dp_aac_enc_thread: A2DP Source (AAC)
bluealsad: [31361] D: ba-transport-pcm.c:473: PCM resume: 24EXPLANATION: BlueALSA starts the audio encoding process. It creates a dedicated thread for AAC encoding, with 1024-sample frames, 2-channel stereo input, and the afterburner enhancement enabled. The encoder is now ready to convert your audio into AAC format for Bluetooth transmission.
AAC Frame Monitoring
# AAC Frame Monitoring
bluealsad: [31419] D: a2dp-aac.c:419: AAC_CODEC: Frame - Output bytes=497, Target bitrate=320000
bluealsad: [31419] D: a2dp-aac.c:419: AAC_CODEC: Frame - Output bytes=496, Target bitrate=320000
bluealsad: [31419] D: a2dp-aac.c:419: AAC_CODEC: Frame - Output bytes=600, Target bitrate=320000
bluealsad: [31419] D: a2dp-aac.c:419: AAC_CODEC: Frame - Output bytes=469, Target bitrate=320000The AAC frame monitoring shows the real-time encoding efficiency of the Fraunhofer AAC encoder as it processes audio for Bluetooth transmission.
Each line represents one AAC audio frame that has been encoded from PCM audio data. The varying output bytes (469-600) demonstrate the Variable Bit Rate (VBR) encoding at work:
Target bitrate=320000: The configured maximum bitrate of 320 kbps for high-quality audio.
Output bytes variation: Shows VBR efficiency - simpler audio passages use fewer bytes (469), complex passages use more (600)
Real-time monitoring: Each frame is logged as it's encoded in the a2dp_aac_enc_thread (a2dp-aac.c)
The real-time monitoring reveals how AAC intelligently allocates bandwidth based on audio complexity, unlike fixed-bitrate codecs that waste data on simple passages. The afterburner enhancement you enabled further optimizes this process for better audio quality. The frame-by-frame variation is quite normal and indicates the encoder is working rather efficiently, adapting to the musical content as it processes each segment of audio.
The real-time monitoring appears only when --loglevel=debug is enabled
The byte variations are typical for VBR encoding with afterburner enabled
Each frame represents approximately 1024 samples of audio data
The actual transmission rate averages around the target 320 kbps over time
Notes
This simplified log illustrates the full Bluetooth audio pipeline — from daemon startup to active streaming — with a focus on AAC codec negotiation and configuration. It demonstrates how BlueALSA serves as a bridge between Linux applications and Bluetooth audio devices, handling codec discovery, negotiation, and real-time encoding with quiet efficiency.
ALSA configuration for BlueALSA virtual PCM with AAC codec
$ cat ~/.asoundrc
defaults.pcm.rate_converter "fftrate"
defaults.bluealsa.codec "aac"
pcm.!default "bluealsa"BlueALSA Commands
bluealsactl codec $(bluealsactl list-pcms | grep a2dpsrc | head -1) aac$ bluealsactl codec $(bluealsactl list-pcms | grep a2dpsrc | head -1)
Available codecs: SBC AAC
Selected codec: AACBlueALSA preserves the original sample rate when:
The source audio is 44.1kHz or 48kHz (the A2DP mandatory rates)
The Bluetooth receiver supports the same rate
When resampling is needed (e.g., DXD to 48kHz), it is performed by the default ALSA resampler (now fftrate)
Command for Real-Time Sample Rate Monitoring
$ bluecodec
Selected: AAC:40008484e200
MPEG-2,4 AAC <hex:40008484e200> {
Object Type ( MPEG4-LC )
Dynamic Range Control ( false )
Sample Rate ( 48000 Hz )
Channel Mode ( Stereo )
VBR ( true )
Bitrate ( 320000 )
}$ bluecodec
Selected: AAC:40010484e200
MPEG-2,4 AAC <hex:40010484e200> {
Object Type ( MPEG4-LC )
Dynamic Range Control ( false )
Sample Rate ( 44100 Hz )
Channel Mode ( Stereo )
VBR ( true )
Bitrate ( 320000 )
}bluecodec() {
local pcm=$(bluealsactl list-pcms | grep a2dpsrc | head -1)
local codec=$(bluealsactl --verbose codec "$pcm" | grep "Selected codec" | awk '{print $3}')
echo "Selected: $codec"
a2dpconf "$codec"
}Technical Details
BlueALSA preserves native sample rates because the D-Bus API exposes the actual PCM rate property, and the A2DP specification mandates support for 44.1kHz and 48kHz rates . When source and sink support the same rate, no resampling occurs, maintaining optimal audio quality.
The bluecodec function provides real-time visibility into the actual negotiated configuration, showing whether BlueALSA is transmitting at 44.1kHz, 48kHz, or other supported rates based on the codec capabilities and device compatibility.
On Afterburner and CPU Usage
$ man bluealsad | grep afterburner -A2
--aac-afterburner
Enables Fraunhofer AAC afterburner feature, which is a type of analysis by synthesis algorithm. This
feature increases the audio quality at the cost of increased processing power and overall memory con‐
sumption.$ cat bluez-alsa-4.3.1-86/src/ba-config.c | grep ENABLE_AAC -A21
#if ENABLE_AAC
/* There are two issues with the afterburner: a) it uses a LOT of power,
* b) it generates larger payload. These two reasons are good enough to
* not enable afterburner by default. */
.aac_afterburner = false,
/* By default try not to not use the VBR mode. Please note, that for A2DP
* sink the VBR mode might still be used if the connection is initialized
* by a remote BT device. */
.aac_prefer_vbr = false,
/* Do not enable true "bit per second" bit rate by default because it
* violates A2DP AAC specification. */
.aac_true_bps = false,
/* For CBR mode the 220 kbps bitrate should result in an A2DP frame equal
* to 651 bytes. Such frame size should fit within writing MTU of most BT
* headsets, so it will prevent RTP fragmentation which seems not to be
* supported by every BT headset out there. */
.aac_bitrate = 220000,
/* Use newer LATM syntax by default. Please note, that some older BT
* devices might not understand this syntax, so for them it might be
* required to use LATM version 0 (ISO-IEC 14496-3 (2001)). */
.aac_latm_version = 1,
#endifThe BlueALSA documentation suggests the afterburner “uses a LOT of power.” In practice, testing on an Intel Core i3-3220 (2012) shows average CPU usage of 3.47%, peaking at 6% during playback. One might conclude that the concern is, at best, a trifle overblown.
Tested with:
ASUS USB-BT540 Bluetooth 5.4 Dongle Adapter Compatible with Linux
Sennheiser HD 450BT Bluetooth Wireless Headphones
Bowers & Wilkins Px7 S2e Bluetooth Wireless Headphones
Sound Quality
AAC over Bluetooth isn’t Hi-Res by any stretch, but with afterburner and VBR at 320 kbps, it delivers transparent, near-CD quality for most listeners. The afterburner enhances perceptual quality through analysis-by-synthesis — it does work rather well. It won’t satisfy a true audiophile, but for the average person, it’s perfectly acceptable.
With AAC, BlueALSA delivers proper AAC sound quality. If you’re unsure what that means, try it yourself using Firefox and YouTube.
Step 1: Disable WebM support in Firefox (media.mediasource.webm.enabled = false).
Step 2: Play a high-quality AAC audio source, such as:
Robert de Visée – Prélude et Allemande (Jonas Nordberg, theorbo) on YouTube: _https://youtu.be/qeUcGD4rRRc
Reference media file:
Robert de Visée Prélude et Allemande, Jonas Nordberg, theorbo
_https://youtu.be/qeUcGD4rRRc$ youtube-dl -F "https://youtu.be/qeUcGD4rRRc" | grep "audio only" 249 webm audio only audio_quality_low 52k , webm_dash container, opus (48000Hz), 1.81MiB 250 webm audio only audio_quality_low 70k , webm_dash container, opus (48000Hz), 2.43MiB 140 m4a audio only audio_quality_medium 129k , m4a_dash container, mp4a.40.2 (44100Hz), 4.47MiB 251 webm audio only audio_quality_medium 137k , webm_dash container, opus (48000Hz), 4.75MiB$ firefox 2>&1 https://youtu.be/qeUcGD4rRRc Input: 44100 Hz, 2 ch, 's32_le' (0xa): dummy = 0, period = 1764 Output: 48000 Hz, 2 ch, 's16_le' (0x2): dummy = 0, period = 1920 Rates: 44100 --> 48000 (J: 0.00%, T: FFT, W: Vorbis) Ok.
Firefox settings for better sound quality:
Open about:config
Set media.mediasource.webm.enabled to false to force AAC (m4a) playback on YouTube
Set media.cubeb.backend to alsa for direct audio output on Linux
Disable resampling: set media.resampling.enabled to false
Adjust latency: set media.cubeb_latency_playback_ms to 160 for balanced performance
These settings help Firefox deliver cleaner, more consistent audio, especially when streaming AAC content.
about:configmedia.mediasource.webm.enabled false media.cubeb.backend alsa media.resampling.enabled false media.cubeb_latency_playback_ms 160Configuration Editor for Firefox
_https://support.mozilla.org/en-US/kb/about-config-editor-firefox
Advanced Audio Coding
_https://en.wikipedia.org/wiki/Advanced_Audio_Coding
The FDK-AAC licence
The FDK-AAC codec is open source under a permissive copyright licence that grants broad rights—allowing free redistribution, requiring source availability for binaries, permitting modifications with attribution, and imposing no royalty fees. However, it does not convey patent rights; separate licences are necessary for commercial use.
$ cat fdk-aac/NOTICE
...
AAC-ELD is considered the best-performing full-bandwidth communications codec
by independent studies and is widely deployed. AAC has been standardized by ISO
and IEC as part of the MPEG specifications.BlueALSA Logging: A Modest Affair
BlueALSA's default logging maintains a certain reserve - quite minimal by design, you see. The logging system resides in src/shared/log.c with corresponding declarations in src/shared/log.h
The Current Situation
By default, BlueALSA rather keeps to itself with basic error and warning messages. The debug macros are quite simply disabled in release builds:
#define debug(M, ...) do {} while (0)Rather tidy, though perhaps not terribly informative when things go awry.
Adding Comprehensive Logging
Should one wish for more verbose output, it's really not such a tremendous undertaking. The framework is already there - one merely
needs to sprinkle debug() statements about the codebase:
debug("Transport state changed: %s", state_name);
debug("Codec negotiation: %s selected", codec_name);The debug system handles the niceties - thread safety, priority filtering, and rather useful timestamps when built with --enable-debug-time.
A Matter of Compilation
Of course, one must remember to compile with debugging support:
./configure --enable-debug
makeQuite straightforward, really. The system then provides rather detailed output including file locations, thread IDs, and relative timing .
Notes
The understated approach to default logging keeps BlueALSA rather quiet in normal operation, though the comprehensive debug framework means adding detailed logging is merely a matter of adding a few well-placed statements here and there. Not terribly difficult, as these things go.
Last edited by igorzwx (2026-01-07 16:50:38)
Offline
BlueALSA Configuration
BlueALSA is already configured and ready to use. The ALSA configuration file for BlueALSA is located at:
/usr/share/alsa/alsa.conf.d/20-bluealsa.conf $ dpkg -S /usr/share/alsa/alsa.conf.d/20-bluealsa.conf
bluez-alsa:amd64: /usr/share/alsa/alsa.conf.d/20-bluealsa.confThis file contains optimal default settings that work for most users. These have been carefully selected to deliver the best performance. As audio quality is not a primary concern for Linux developers, you may wish to adjust some of the default settings.
What's Already Configured
The system already defines:
pcm.bluealsa - The main Bluetooth audio device.
ctl.bluealsa - Mixer controls for Bluetooth devices.
Note that pcm.bluealsa is a virtual PCM device, not a full virtual sound card. As such, it does not support direct use of ALSA plugins like dmix, dsnoop, or asym to enable software mixing or concurrent access. BlueALSA PCM devices are designed for direct Bluetooth audio streaming and lack built-in multi-client capabilities — only one application can use the PCM at a time.
Optimal Configuration for AAC codec
Here is the complete optimal configuration for AAC codec. Put this in ~/.asoundrc:
# File: ~/.asoundrc
defaults.pcm.rate_converter "fftrate"
defaults.bluealsa.ctl.extended "yes"
defaults.bluealsa.codec "aac"
pcm.!default "bluealsa"What These Settings Do
defaults.pcm.rate_converter "fftrate" - Uses high-quality sample rate conversion
defaults.bluealsa.ctl.extended "yes" - Shows which codec is actually being used
defaults.bluealsa.codec "aac" - Forces AAC codec for best quality
pcm.!default "bluealsa" - Makes Bluetooth audio the system default
If you open alsamixer for the BlueALSA virtual PCM device:
alsamixer -D bluealsayou will see codec controls like:
AAC Codec Enum - Shows the currently selected AAC codec
Volume Mode - Switch between "pass-through" and "software"
Sync - Client delay adjustment
Battery - Device battery level (if supported)
The codec control lets you verify your defaults.bluealsa.codec "aac" setting is working
The following default settings work well and don't need to be changed:
Volume mode: 'pass-through' (uses device's native volume control)
Delay: +0 ms (no extra delay added)
These settings are already optimal for most users.
Important: Do not load aptX or aptX-HD codecs in bluealsad, if you intend to use the AAC codec exclusively.
This ensures only AAC (and mandatory SBC) codecs are available for a2dp playback, as SBC codec cannot be disabled — it is required by the A2DP specification and is always enabled by default in BlueALSA.
To run bluealsad from the terminal, use:
sudo -u bluealsad bluealsad -p a2dp-source -p a2dp-sink -p hfp-ag -p hfp-hf -c -sbc -c aac -c msbc --aac-afterburner --aac-bitrate=320000 --aac-vbr --aac-true-bps In the init script /etc/init.d/bluealsad, configure the options accordingly:
BA_OPTS="-S -p a2dp-source -p a2dp-sink -p hfp-ag -p hfp-hf -c -sbc -c aac -c msbc --aac-afterburner --aac-bitrate=320000 --aac-vbr --aac-true-bps"This configuration avoids codec conflicts and ensures reliable AAC usage.
How BlueALSA Handles Sample Rates (Bit Perfect)
BlueALSA does not perform resampling. When sample rate conversion is required (e.g., from DXD to 48 kHz), it is handled by ALSA using the configured resampler — such as fftrate:
$ cat ~/.asoundrc | grep rate
defaults.pcm.rate_converter "fftrate"Since the AAC codec supports both 44.1 kHz and 48 kHz, no resampling is needed, and BlueALSA preserves the original sample rate — a concept often referred to as "bit perfect" in macOS contexts. The default BlueALSA configuration avoids unnecessary audio processing that could degrade sound quality.
When your audio player changes sample rates (e.g., from 48 kHz to 44.1 kHz), BlueALSA automatically renegotiates the connection with the Bluetooth device to match the new rate.
How to configure media applications
Note that it is generally not possible to disable resampling in Chromium-based browsers.
MPV Player
$ cat ~/.config/mpv/mpv.conf
ao=alsa
alsa-resample=yes
alsa-buffer-time=160000
alsa-periods=4Celluloid:
Open the Preferences menu.
Go to the Miscellaneous tab.
Enter mpv command-line options into the "Extra MPV Options" text box:
ao=alsa alsa-resample=yes alsa-buffer-time=160000 alsa-periods=4Audacious:
go to Preferences → Audio → Buffer size
set 2000 ms
aplay and arecord
aplay -F 40000 -B 160000 input.wav
arecord -F 40000 -B 160000 -V mono -f CD output.wavFirefox
about:config
media.mediasource.webm.enabled false
media.cubeb.backend alsa
media.resampling.enabled false
media.cubeb_latency_playback_ms 160Configuration Editor for Firefox
_https://support.mozilla.org/en-US/kb/about-config-editor-firefox
Last edited by igorzwx (Today 17:36:06)
Offline
Pages: 1