Been having problems with pairing and maintaining conected my bluetooth speaker, finally after reading and reading, found some steps to achieve it. Please read ahead.
First of all we need to configure/change the audio configuration for our bluetooth device (in my case, Bose Soundlink), I wouldn't assume that this steps would work for every bluetooth device, so give it a try, and hopefully it'll work.
We type in this command.
sudo nano /etc/bluetooth/audio.conf
This will open or if not exist previously then create the audio configuration file for out bluetooth adapter(s), I have 2 different adapters and this seems to work for both.
We have to enter or replace the following lines to look like:
Under [General] section.
[General] Disable=Socket Enable=Media,Source,Sink,Gateway
The order is important so don't alter it otherwise it won't work. I am no expert on Pulseaudio, and I found that the documentation is in simple words, well, Daunting!, I honestly have other things to do and finding the right bits and whistles have taken enough of my time already.
Save the file and exit. Once back in the command line, restart Bluetooth with this command.
sudo service bluetooth restart
this will restart the whole bluetooth stack, You don't need to do this if you plan to boot before continuing, since the next steps should be issued every time you boot (I can use some help here to find out how to run commands every time the machine boots up again)
Once the service is restarted, you can then issue.
sudo pactl load-module module-bluetooth-discover
The command above tells pulseaudio to load a module that handles bluetooth devices discovery.
in the same command line enter:
sudo pactl load-module module-switch-on-connect
The command above tells pulseaudio to switch the last device connected as the default audio sink/output.
The last step is to pair the bluetooth device with your computer, if You already have paired it as I were, I hard booted my bluetooth speaker in order to prevent any old pairing info to interfere, as well as deleted my old pairing trials which wouldn't work correctly.
After pairing things should be working, the Sink should be redirected, and the connection to your Bluetooth Speaker should be steady, some times Pulseaudio needs you to tell him where do you want to redirect the sound, (for instance ALSA Containers from Firefox, Flash files in other words), so you need to install the Pulseaudio Volume Control and change the output.
I hope this helps.
Good Luck EN