A2DP sink without pulseaudio A2DP sink without pulseaudio linux linux

A2DP sink without pulseaudio


I know this is an old post, but hopefully the answer is useful to people currently working on this.

You can use /etc/bluetooth/audio.conf, which is the system-wide file, or ~/.asoundrc, which is your local file. Both are read by BlueZ/ALSA. However, I think you need to include the MAC address in your config file, z.B.:

pcm.btheadset {    type bluetooth    device "XX:XX:XX:XX:XX:XX" #MAC address    profile "auto"}

The best resources I've found for this are:

1) James B's blog post: Bluez must be one of the best kept secrets in Linux
He explains the structure and interface between BlueZ and ALSA, which I found nowhere else on the internet.

2) His second post with code: Bluez A2DP AudioSink for ALSA

3) The ALSA site, which introduces the structure of pcm plugins, but doesn't really explain them very well.

4) Some ALSA plugin tutorials: The ALSA wiki

Some useful commands:

$sudo service bluetooth restart$sudo alsa force-reload

Run these after you change the asoundrc or audio.conf files.


Here you find a manual to configure bluetooth with ALSA or Pulseaudio:

-tested on Linux Mint 17.3 Mate, 64bit / Ubuntu 14.04 Mate, 64bit-

HOW TO MAKE ALSA AND BLUETOOTH WORK TOGETHER WITHOUT PA

This part is for pure ALSA-based systems without Pulseaudio like KXStudio, QStudio64,Tango studio..!

Be sure that Pulseaudio is deinstalled and your soundcardsconfigured right in ALSA!

  • delete pulse-audio cookies and files in/home/USERNAME/.config/pulse

    1. Modify your bluetooth-audio.conf:type:

    gksudo pluma /etc/bluetooth/audio.conf

    Set

    # This section contains options which are not specific to any# particular interface

    [General]Enable=Socket

Save the file.

  1. setup ~/.asoundrc filetype:

sudo hcitool scan

Scanning ...XX:XX:XX:XX:XX:XXStereo Headset

Create a hidden-file named .asoundrc in your home-folder!and write:

    pcm.!default {        type plug        slave.pcm {             type bluetooth             device "XX:XX:XX:XX:XX:XX"             profile "auto"        }}

Replace “XX:XX..” with the adress of your device.

Save the file!

Run these after you change the asoundrc or audio.conf files:

sudo service bluetooth restartsudo alsa force-reload

or reboot your computer!———————————————————————————————————–—-

Go to your blueman-applet at your taskbar, search & setup your new device!Note: Some bluetooth-devices need a passphrase (eg. 0000) by default

  • while some others takes shuffle-pairing.Keep your found and paired device to “trust”!

Connect your device as AUDIO via A2DP!

————————————————————————————————————

If your device is connected with your system you can play sound with totem (gui), vlc (gui+terminal), mplayer (terminal), qmmp (gui), banshee and browsers over bluetooth while setting the output in players to “default”!

—————————————————————————————————–———

RENAME THE .ASOUNDRC IN HOME-FOLDER TO “.ASOUNDRC_OFF”TO GET YOUR OLD SYSTEM-SETTINGS WITHOUT BLUETOOTH BACK!

type: mv /home/USERNAME/.asoundrc /home/USERNAME/.asoundrcOFF->to disable the bluetooth-specific asoundrc

type: mv /home/USERNAME/.asoundrcOFF /home/USERNAME/.asoundrc-> to enable it!

Alternative:

Make two “scripts” to activate/deactivate bluetooth with .asoundrc in your home-folder:

Create one empty file and write/paste:

#!/bin/bashmv /home/USERNAME/.asoundrc /home/USERNAME/.asoundrcOFFor:#!/bin/bashcd /home/USERNAME/mv .asoundrc .asoundrcOFF

To activate your .asoundrc for bluetooth again, create another file with following entry:

#!/bin/bashmv /home/USERNAME/.asoundrcOFF /home/USERNAME/.asoundrc

or:

#!/bin/bashcd /home/USERNAME/mv .asoundrcOFF .asoundrc

Make the files executable and run them with “open with terminal”!Now you have two “buttons” to switch bluetooth-sound On or Off.

Give them individual-icons:;-)

————————————————————————————————————-

PLAYERS

————–

It’s recommend to use totem, Qmmp or Banshee-player - because there is nothing more to do thanplay and listen! Also totem-player shows videos too.

VLC-player needs the “default” sounddriver for bluetooth to working right!

Check in: /home/USERNAME/.config/vlc/vlcrc

that alsa-audio-devicein >>line1666<<is:

# ALSA Device Name (string)alsa-audio-device=default

Use this commands to use players with terminal:To play music, type:

MPlayer

———––

mplayer /home/USERNAME/Musik/1.mp3

If you hear no sound or get errors try:

mplayer -ao alsa:device=default /home/USERNAME/Musik/1.mp3

VLC-Player

—————-

cvlc /home/USERNAME/Musik/1.mp3vlc /home/USERNAME/Musik/1.mp3rvlc /home/USERNAME/Musik/1.mp3To add whole directories type:rvlc add /home/USERNAME/Musik/

type: start/stop/next... to navigate!

or use the vlc-gui.

—————————————————————————————————–——-

To use mplayer with graphical-interface you have to install the gui-package:type:

sudo apt-get install mplayer-gui

Open a terminal via Ctrl-Alt-T and use the commands below.Use the lines and type/copy one by one to avoid confusion(!):

cd /usr/share/mplayer/skins/defaultfor FILE in *.png; do sudo convert “$FILE” -define png:format=png24 “$FILE”; donecd /usr/share/mplayer/skins; sudo rm default; sudo ln -s Blue default

———————————————————————————————————–

Now you can start the mplayer-gui without errors!

If you prefer the terminal type:

gmplayer /home/USERNAME/Musik/1.mp3

or

gmplayer -ao alsa:device=default /home/USERNAME/Musik/1.mp3if you have problems!

terminal command without gui:

mplayer /DIRECTION/TO/FILE

Available Output-Modules and Drivers:

mplayer -vo help

———————————————————————-

BLUETOOTH WITH PULSEAUDIO

————————————————–--------

For Linux systems that comes with pulseaudio:

(1.) Edit /etc/bluetooth/audio.conf and uncomment the following line:

AutoConnect=true
  1. Run the following command to install latest packages for blueman and related modules:

    sudo add-apt-repository ppa:blueman/ppa

    sudo apt-get update

    sudo apt-get upgrade bluemanenter code here

(3.) Check if the following lines are added in /etc/pulse/default.pa:

.ifexists module-bluetooth-discover.soload-module module-bluetooth-discover.endif

If not, add the lines.

REBOOT!

  1. Run the new blueman-applet.

Right click on the panel applet and turn bluetooth on.The old profie of you bluetooth device would still be there, remove it.Right click on the blueman-panel applet and select Setup New Device.Complete the wizard for your device.(If you have problems with “pairing” restart your system and skip this step!)

Now you get a connected bluetooth device!

To send/hear audio over it just follow these 2 steps:

  • Open Mate-volume control-settings (or pavucontrol) with rightclick in taskbar,browse to “HARDWARE” -and use the dropdown to turn the Built-in audio profiles of all other soundcards “off”

  • so that the bluetooth-device gets active!

  • use the other dropdown to set the bluetooth device to use A2DP

Now start the totem-player or vlc (with pulseaudio-output) to send audio to bluetooth!

Enjoy your sound!;-)

WLAN-ISSUES:

——————–—In case you see a WiFi connection drop after connecting to the bluetooth device run the followingcommand:

$ echo “options iwlwifi 11n_disable=1 bt_coex_active=0 power_save=0 auto_agg=0 swcrypto=1” |sudo tee -a /etc/modprobe.d/iwlwifi.conf > /dev/null

tested 2017 for LM 17.3 (Rosa) MATE and Ubuntu 14.04 by chalee:

http://mayastudio.tumblr.com/bluetooth


My guess is that your audio path isn't routing the bluetooth to your speakers. I have seen similar issue, which was fixed by manually doing step 5 "Connect PulseAudio bluetooth source to PulseAudio ALSA sink" from this link: http://jprvita.wordpress.com/2009/12/15/1-2-3-4-a2dp-stream/