Did you know that you can use your Linux PC as Bluetooth speakers for your mobile phone? No? No, problem! I will explain how to turn your Linux PC into Bluetooth speakers for your phone.
If you don't know already, it is possible to play the audio or video files in our phone and listen them in our Laptop or Desktop via Bluetooth using Pulseaudio.
To put this more simply, we can redirect the sound from a mobile phone to a computer with the help of Pulseaudio and Bluetooth.
Table of Contents
Prerequisites
Obviously, you should have a Bluetooth-enabled mobile phone and a Linux PC (desktop or laptop). The PC running GNU/Linux must have Bluetooth hardware capability i.e. a Bluetooth receiver and transmitter.
I tested this guide on my DELL Laptop running with Ubuntu 18.04 LTS and an old HP Tablet PC.
First, make sure you have installed Bluez, Pulseaudio and pulseaudio bluetooth module on your Linux system. Most Linux distributions comes pre-installed with these tools. Just in case if they are missing, install them as shown below.
Install Bluez On Linux
To install Bluez on Arch Linux and its variants, run:
$ sudo pacman -S bluez
On Debian, Ubuntu:
$ sudo apt install bluez
On Fedora, CentOS, RHEL:
$ sudo dnf install bluez
Or,
$ sudo yum install bluez
On openSUSE:
$ sudo zypper install bluez
After installing Bluez, make sure the bluetooth service is started and enabled on boot.
$ sudo systemctl start bluetooth
$ sudo systemctl enable bluetooth
To verify the bluetooth status, run:
$ systemctl status bluetooth
Install Pulseaudio On Linux
PulseAudio is an open source, cross-platform, network-capable sound server program distributed via the freedesktop.org project.
It supports Linux, and various BSD distributions such as FreeBSD and OpenBSD, macOS. Pulseaudio is available in the default repositories of most Linux distributions.
To enable playback via Bluetooth, we should install pulseaudio bluetooth module.
Run the following command to install Pulseaudio and other required programs on Arch Linux and its variants such as EndeavourOS and Manjaro Linux:
$ sudo pacman -S pulseaudio pavucontrol pulseaudio-bluetooth
On Debian, Ubuntu and Linux Mint, simply run:
$ sudo apt install pulseaudio pulseaudio-utils pavucontrol pulseaudio-module-bluetooth
Fedora, RHEL 8, AlmaLinux 8, Rocky Linux 8:
$ sudo dnf install pulseaudio pulseaudio-utils pavucontrol pulseaudio-module-bluetooth
CentOS 7.x., RHEL 7.x:
$ sudo yum install pulseaudio pulseaudio-utils pavucontrol pulseaudio-module-bluetooth
openSUSE:
$ sudo zypper install pulseaudio pulseaudio-utils pavucontrol pulseaudio-module-bluetooth
Pair the Linux PC with your Mobile Phone
Make sure the mobile phone has been paired with your PC. Bluetooth pairing is very easy! You probably have done it already many times.
Switch on Bluetooth on your Mobile phone and your Linux system.
In Android device, turn on Bluetooth from Settings window.
In Ubuntu GNOME, Bluetooth can be switched on from System settings.
After the Bluetooth has been turned on in both devices, they will start to scan for the nearest Bluetooth devices and list them. From the Linux PC, just click on the device to pair it.
You should see the same Bluetooth PIN on your mobile phone. Just click Pair to pair it with the Linux PC.
Once the mobile has been paired with your Ubuntu PC, you will see them under the Devices tab in Bluetooth section.
Similarly, you will see your Linux PC is listed under the paired devices tab in your mobile phone.
Now both devices have been paired and are ready to use!
Turn your Linux PC into Bluetooth Speakers for your Phone
On my Ubuntu 18.04 desktop, it worked fine out of the box. No configuration is actually required!
I installed "pulseaudio-module-bluetooth" package, paired up my phone with my PC and I can be able to listen the music playing in phone from my Laptop instantly.
I could adjust the volumes either from the mobile device or computer. I guess Pusleaudio took care of everything behind the scenes. Pulseaudio is awesome!
If it doesn't work out of the box for any reason, create a file named ~/.config/pulse/system.pa:
$ mkdir ~/.config/pulse/
$ nano ~/.config/pulse/system.pa
Add the following lines in it:
.include /etc/pulse/system.pa load-module module-bluetooth-policy load-module module-bluetooth-discover
Save and close the file. Restart Bluetooth service to take effect changes using command:
$ sudo systemctl restart bluetooth
You can directly edit "/etc/pulse/system.pa" file and make the changes. However, It is strongly recommended not to edit system-wide configuration files, but rather edit user ones.
That's why you should create the "~/.config/pulse" directory, then copy the system configuration files into it and edit according to your need.
Rather than being a complete copy, ~/.config/pulse/default.pa file can start with the line ".include /etc/pulse/default.pa" and then just override the defaults. This way we can avoid problems when the pulseaudio updates in future.
Troubleshooting Pulseaudio
Even though, I could able to turn my Laptop into Bluetooth speakers instantly without any additional configurations, the audio playback is terrible and stutters quite a lot. Yes, the audio is listenable, but it's annoying.
First, make sure the Bluetooth playback profile is set to A2DP (High Fidelity Playback).
To do so, open Pulseaudio volume control (Pavucontrol) from Dash or Menu. And select "High Fidelity Capture (A2DP Source)" from profile drop-down box under Configuration section.
Next you need to set correct buffer size (latency). If the Bluetooth sound is choppy, stuttering and distorted, this might be caused by the A2DP implementation, and how it buffers sound before encoding it.
I simply changed the buffer's size to fix the audio stuttering problem.
First, find the Bluetooth device name and its port using command:
$ pactl list | grep -Pzo '.*bluez_card(.*\n)*'
Sample output:
Name: bluez_card.7C_D3_0A_0B_D6_30 Driver: module-bluez5-device.c Owner Module: 36 Properties: device.description = "HP 7 VoiceTab" device.string = "7C:D3:0A:0B:D6:30" device.api = "bluez" device.class = "sound" device.bus = "bluetooth" device.form_factor = "phone" bluez.path = "/org/bluez/hci0/dev_7C_D3_0A_0B_D6_30" bluez.class = "0x5a020c" bluez.alias = "HP 7 VoiceTab" device.icon_name = "audio-card-bluetooth" Profiles: a2dp_source: High Fidelity Capture (A2DP Source) (sinks: 0, sources: 1, priority: 20, available: yes) headset_audio_gateway: Headset Audio Gateway (HSP/HFP) (sinks: 1, sources: 1, priority: 10, available: no) off: Off (sinks: 0, sources: 0, priority: 0, available: yes) Active Profile: a2dp_source Ports: phone-output: Phone (priority: 0, latency offset: 0 usec, not available) Part of profile(s): headset_audio_gateway phone-input: Phone (priority: 0, latency offset: 0 usec, available) Part of profile(s): a2dp_source, headset_audio_gateway
As you see in the above output, the name of the Bluetooth device is "bluez_card.7C_D3_0A_0B_D6_30" and port is "phone-output". And the buffer size (latency) is 0.
Set the buffer size (latency) using command:
$ pactl set-port-latency-offset bluez_card.7C_D3_0A_0B_D6_30 phone-output 125000
Here, I am using 125 millisecond buffer. You can set your own that works for you. Also change the name and port values in the above command.
Now, restart your Bluetooth service using command:
$ sudo systemctl restart bluetooth
Or reboot your system. The audio stuttering problem should be gone by now.
I followed some other workarounds mentioned in the AskUbuntu, LinuxMint and ArchWiki forums (links are attached at the end). But the above solution only fixed my problem.
Here are some other solutions suggested by users to fix Bluetooth audio problem.
Solution 1:
Edit the ALSA configuration file:
$ sudo nano /etc/modprobe.d/alsa-base.conf
Add the following line at the end:
options snd-hda-intel model=generic
This setting is only relevant if the primary sound card on the PC running GNU/Linux is an HDA Intel device (usually on the motherboard).
It will do nothing if the primary sound card is some other device, for example Creative, Terratech, VIA, etc. Thanks for the input Mr.Bryan.
Save and close the file. Reboot your system.
Solution 2:
This was suggested by a user in Linux Mint forum.
Edit file ~/.config/pulse/system.pa:
$ sudo ~/.config/pulse/system.pa
Add the following line:
load-module module-udev-detect tsched=0
Save and close the file. Reboot your system.
Hope this helps.
Resources:
18 comments
You do not make it clear in the article that the PC running GNU/Linux must have Bluetooth hardware capability ie a Bluetooth receiver and transmitter.
Also you fail to explain that adding the line
“options snd-hda-intel model=generic”
is only relevant if the primary sound card on the PC running GNU/Linux is an HDA Intel device (usually on the motherboard. It will do nothing if the primary sound card is some other device (Creative, Terratech, VIA, etc).
Thanks for the input, Bryan. I have added your note in the guide.
Thanks for this tutorial.
A little typo correction: the ‘install’ keyword in the ‘install bluez’ section for arch linux should be removed (pacman -S install bluez)
Fixed. Thank you.
What about going the other way? Turning your bluetooth phone into a speaker for your compter?
Good idea. I will search about it.
Good idea.
help turn off pulseaudio static noise
Did you try making calls?
Yes. It didn’t work.
Can we do the same for input to pc also (making the pc a phone terminal) ?
I guess so. Please check “SoundWire” application.
Yay! I got it to work.
But now.. next thing. How can I get media buttons to work?
Say I want to play and pause my phone’s music or audiobook player from my pc.
How can I get my pc to send those button signals to my phone?
KDE Connect may be? I haven’t tried it by the way. Please check it yourself. If you find any other, please share it too.
https://ostechnix.com/kde-connect-access-files-notifications-android-devices/
I use Ubuntu Mate 16.04 this method works except that, my hardware adapter was not enabled by default and managed to enable using some configs. I wish to use my desktop to attend calls instead of smartphone (when am on desktop). I made a voice call from my mobile, but I was not able to hear the other person’s voice in my desktop and I think even my voice was not transmitted to my smartphone from desktop while on call!
Any tools that can help me with this situation? or do I need to make my own?
My final desire would be to make calls/send SMS from desktop using CLI at least (makecall _or_ sendsms “” _or_ .
As of now, I don’t think there’s no notification in my desk when I get a call on my smartphone (my words sound like https://play.google.com/store/apps/details?id=com.microsoft.appmanager&hl=en_IN&gl=US)
I don’t know any tools at the moment. I am sorry.
Thank you very much, you are a live saver!
Thanx, Guru!
Did not know of this functionality.
Everything worked out of the box on my xubuntu notebook.
And any way of getting linux to work as a chromecast receiver?
I don’t have any chromecast device at the moment. So I couldn’t comment about it. Please try on Google. Good luck.