Bluez-Alsa

Under development: PCMCIA, wireless, etc.
Message
Author
User avatar
greengeek
Posts: 5789
Joined: Tue 20 Jul 2010, 09:34
Location: Republic of Novo Zelande

Bluez-Alsa

#1 Post by greengeek »

I am in the middle of efforts to connect bluetooth devices to my Slacko 5.6 derivative and trying to understand the required information, which includes the following:

- what protocol does the bluetooth device use?
- what functions does the device have?
- what bluetooth driver module is in use in the puppy?
- how is alsa configured?
- how do individual programmes interface with the alsa setup in order to correctly interface the bluetooth device?
etc
etc

However - Alsa never had the functionality required to handle features available in some modern bluetooth devices - it appears necessary to use pulseaudio to access all of the recent functionality.

I won't be using pulseaudio - i need to stick with Alsa - but i still want to make my bluetooth devices as useable as possible.

I stumbled across a Github project which is intended to update Alsa to include the latest features. I don't have the knowledge to use this yet but others may be interested in the github progress:

https://github.com/Arkq/bluez-alsa

** I have placed this in "cutting edge" because the github effort seems to be an attempt to develop new functionality rather than something that already offers a puppy useable pet or similar. Hope that's a reasonable place for it.

User avatar
rcrsn51
Posts: 13096
Joined: Tue 05 Sep 2006, 13:50
Location: Stratford, Ontario

#2 Post by rcrsn51 »

The Stretch-live Starter Kit has an bluetooth app that uses bluez-alsa.

Trying to incorporate it into an older Puppy is a significant problem because you also need all the other bluetooth infrastructure.

User avatar
greengeek
Posts: 5789
Joined: Tue 20 Jul 2010, 09:34
Location: Republic of Novo Zelande

#3 Post by greengeek »

rcrsn51 wrote:The Stretch-live Starter Kit has an bluetooth app that uses bluez-alsa.
Thanks - just gave that a try now. Very different to puppy. I could not find any method to connect audio output to my bluetooth device (Marley chant sport BT speaker).

Would I need to download extra software to get this going?

cheers!

User avatar
rcrsn51
Posts: 13096
Joined: Tue 05 Sep 2006, 13:50
Location: Stratford, Ontario

#4 Post by rcrsn51 »

Code: Select all

apt-get update
apt-get install bt4stretch
Instructions are here. You also need to install an mplayer package like peasymp3.
Very different to puppy.
Actually, it's exactly like Puppy. It's a light-weight Linux with a layered filesystem, frugal install, save folder, add-on sfs modules and access to a mainstream repo.

User avatar
rcrsn51
Posts: 13096
Joined: Tue 05 Sep 2006, 13:50
Location: Stratford, Ontario

#5 Post by rcrsn51 »

No reply?

User avatar
greengeek
Posts: 5789
Joined: Tue 20 Jul 2010, 09:34
Location: Republic of Novo Zelande

#6 Post by greengeek »

Out of town at the moment. Blackberry and Android only. :(

User avatar
greengeek
Posts: 5789
Joined: Tue 20 Jul 2010, 09:34
Location: Republic of Novo Zelande

#7 Post by greengeek »

rcrsn51 wrote:

Code: Select all

apt-get update
apt-get install bt4stretch
Instructions are here. You also need to install an mplayer package like peasymp3..
No joy so far. I tried to connect to the internet via peasywifi but without success. Read the help file which said use the I/F button to scan for wifi interfaces but it just came back with a box saying "Your possible wifi interfaces" and an OK button.

I tried to use prtscrn key to capture the message and desktop contents but got a message saying "Failed to execute child process "scrot".

I am assuming apt-get can't work without first establishing an internet connection via peasy wifi?

EDIT : I am using a Toshiba M700 with a "Network controller: Intel Corporation PRO/Wireless 4965 AG or AGN [Kedron] Network Connection (rev 61)" internal wifi interface.

User avatar
rcrsn51
Posts: 13096
Joined: Tue 05 Sep 2006, 13:50
Location: Stratford, Ontario

#8 Post by rcrsn51 »

This is a firmware issue - the Starter Kit only contains a selection of the Intel firmware.

1. Run: dmesg | grep -i firmware.

2. This should identify the missing file, probably iwlwifi-4965-2.ucode.

3. Connect to Ethernet and download the package firmware-iwlwifi via apt-get.

4. Or get the single file from a Puppy and drop it into Stretch.

User avatar
greengeek
Posts: 5789
Joined: Tue 20 Jul 2010, 09:34
Location: Republic of Novo Zelande

#9 Post by greengeek »

Thanks, I'm hoping to try this over the next couple of nights. I will try to get to the point of bluetooth attachment then post back.

User avatar
greengeek
Posts: 5789
Joined: Tue 20 Jul 2010, 09:34
Location: Republic of Novo Zelande

#10 Post by greengeek »

rcrsn51 wrote:This is a firmware issue - the Starter Kit only contains a selection of the Intel firmware.

1. Run: dmesg | grep -i firmware.

2. This should identify the missing file, probably iwlwifi-4965-2.ucode.

3. Connect to Ethernet and download the package firmware-iwlwifi via apt-get.

4. Or get the single file from a Puppy and drop it into Stretch.
Thanks - that was exactly the missing file. As it turns out using the ethernet cable was the most sensible way to go (haven't used it for years so it never came to mind!)

Instead of downloading that file and getting wifi going I used apt-get via ethernet to do an update then download bt4stretch.

I had mixed success - I was able to use bt4stretch to connect to my BT headphones (the headphones have a voice prompt that says "bluetooth successfully connected") but could not get a player running.

I tried:
apt-get gmplayer but the response was:
invalid operation gmplayer.

Similar response if I tried to download mplayer or peasymp3.

Any tips?

cheers!

ps: here's the terminal output of my use of bt4stretch to pair with the headphones:

Code: Select all

[NEW] Controller 00:03:7A:B7:4C:9C live [NEW] Controller 00:03:7A:B7:4C:9C live [default]
[bluetooth]# scan on
Discovery started
[CHG] Controller 00:03:7A:B7:4C:9C Discovering: yes
[NEW] Device F2:FA:91:DD:FA:C6 F2-FA-91-DD-FA-C6
[CHG] Device F2:FA:91:DD:FA:C6 LegacyPairing: no
[CHG] Device F2:FA:91:DD:FA:C6 Name: 488126
[CHG] Device F2:FA:91:DD:FA:C6 Alias: 488126
[CHG] Device F2:FA:91:DD:FA:C6 LegacyPairing: yes
[CHG] Device F2:FA:91:DD:FA:C6 RSSI: -42
[bluetooth]# pair F2:FA:91:DD:FA:C6
Attempting to pair with F2:FA:91:DD:FA:C6
[CHG] Device F2:FA:91:DD:FA:C6 Connected: yes
[CHG] Device F2:FA:91:DD:FA:C6 UUIDs: 0000110b-0000-1000-8000-00805f9b34fb
[CHG] Device F2:FA:91:DD:FA:C6 UUIDs: 0000110e-0000-1000-8000-00805f9b34fb
[CHG] Device F2:FA:91:DD:FA:C6 UUIDs: 0000111e-0000-1000-8000-00805f9b34fb
[CHG] Device F2:FA:91:DD:FA:C6 ServicesResolved: yes
[CHG] Device F2:FA:91:DD:FA:C6 Paired: yes
Pairing successful
[CHG] Device F2:FA:91:DD:FA:C6 ServicesResolved: no
[CHG] Device F2:FA:91:DD:FA:C6 Connected: no
[bluetooth]# connect F2:FA:91:DD:FA:C6
Attempting to connect to F2:FA:91:DD:FA:C6
[CHG] Device F2:FA:91:DD:FA:C6 Connected: yes
Connection successful
[CHG] Device F2:FA:91:DD:FA:C6 ServicesResolved: yes
[488126]# 

User avatar
rcrsn51
Posts: 13096
Joined: Tue 05 Sep 2006, 13:50
Location: Stratford, Ontario

#11 Post by rcrsn51 »

apt-get gmplayer
It's
apt-get install gmplayer
But get peasymp3 instead. Its .asouncdrc file already has the lines for bluetooth setup. Mplayer is an automatic dependency of peasymp3.

Your post above shows a successful BT connection to the speaker. That's the hard part. Now you just need to insert its MAC address into the .asouncdrc file. Use a copy/paste.

Then you can run the built-in player.

User avatar
bigpup
Posts: 13886
Joined: Sun 11 Oct 2009, 18:15
Location: S.C. USA

#12 Post by bigpup »

Maybe this will work.

pBluetooth bluetooth manager
http://www.murga-linux.com/puppy/viewtopic.php?p=946012
The things they do not tell you, are usually the clue to solving the problem.
When I was a kid I wanted to be older.... This is not what I expected :shock:
YaPI(any iso installer)

Pro
Posts: 109
Joined: Fri 12 Feb 2010, 11:12

#13 Post by Pro »


User avatar
greengeek
Posts: 5789
Joined: Tue 20 Jul 2010, 09:34
Location: Republic of Novo Zelande

#14 Post by greengeek »

Thanks for pointing out that thread, I will join in at some point but need to finish my tests with Stretch Live Starter and also with Slacko 5.6 first.
cheers

Pro
Posts: 109
Joined: Fri 12 Feb 2010, 11:12

#15 Post by Pro »

rcrsn51, good work on bt4stretch

Some info for you:
bluetoothctl (above 5.50) now have working non-interactive mode, ex. bluetoothctl --timeout 10 scan on
(scan device 10s and exit)

For hidd device may be not need hidd
#bluetoothctl connect device_mac_addr
and udev rules for autoconnect device, may be good choice (i not have bt mouse for test this)

User avatar
greengeek
Posts: 5789
Joined: Tue 20 Jul 2010, 09:34
Location: Republic of Novo Zelande

#16 Post by greengeek »

rcrsn51 wrote:
apt-get gmplayer
It's
apt-get install gmplayer
But get peasymp3 instead. Its .asouncdrc file already has the lines for bluetooth setup. Mplayer is an automatic dependency of peasymp3.

Your post above shows a successful BT connection to the speaker. That's the hard part. Now you just need to insert its MAC address into the .asouncdrc file. Use a copy/paste.

Then you can run the built-in player.
Thanks. All steps now completed successfully, however I have the following issues:

Mplayer and peasymp3 only play to the inbuilt soundcard (i did not install gmplayer, just the peasy package). I tried to hash out the "default" lines which specified the inbuilt soundcard in .asoundrc but failed to hit the sweet spot. Couldnt get peasy to stream to the bt headphones.

By contrast the "Play" function in the bt4stretch gui did start playing to my BT headphones but the playback was intermittently extremely distorted - hard to describe but very choppy and almost as if two versions were playing at once at faster than normal speed. Between bursts of this strange behaviour the audio played correctly.

I will shelve this for the moment and come back to it when I have learned a bit more. I am about to post a thread with a howto for the Slacko 5.6 procedure as i have found a way to get that going really easily (not Bluez-Alsa, just an older bluez pet that seems working on Slacko 5.6)

User avatar
rcrsn51
Posts: 13096
Joined: Tue 05 Sep 2006, 13:50
Location: Stratford, Ontario

#17 Post by rcrsn51 »

The bluez-alsa project exists because bluez5 dropped direct support for ALSA and expects you to use pulseaudio.

This is all discussed here.

The bluez-alsa technique will only play through a special setup like the mplayer in bt4stretch (AFAIK). It works by piping the mplayer output into a customized aplay (running a background process) that can see the BT device. So depending on your hardware and the current load on your computer, the results may not be satisfactory.

For example, if you only wanted to play MP3s, you could replace mplayer with a simpler audio player that might work better.

ALSA by itself cannot see the BT device. In this system, there is no ALSA device named "btheadset" that you can select.

The earlier versions of bluez had hooks into ALSA. Assuming that you could meet all the dependencies of the bluez package and you had a compatible ALSA, this might produce better quality audio output. There was a more direct path between the audio source and the BT output device.

User avatar
greengeek
Posts: 5789
Joined: Tue 20 Jul 2010, 09:34
Location: Republic of Novo Zelande

#18 Post by greengeek »

rcrsn51 wrote:The bluez-alsa technique will only play through a special setup like the mplayer in bt4stretch (AFAIK). It works by piping the mplayer output into a customized aplay (running a background process) that can see the BT device. So depending on your hardware and the current load on your computer, the results may not be satisfactory.
...
ALSA by itself cannot see the BT device. In this system, there is no ALSA device named "btheadset" that you can select.

The earlier versions of bluez had hooks into ALSA. .
Interesting - thanks for that info. The bluez package i have been testing in Slacko 5.6 provides a .asoundrc file that includes the "btheadset" device and I did try that in my Stretch starter testing but without any understanding of what should/would work. (It didn't work of course).

I plan to come back to this for more testing as there is so much to learn about bluetooth (and alsa configuration) and also because streaming to a bt headset is only one possible function - I will probably need the bluez-alsa at some point to connect to bidirectional devices.

User avatar
rcrsn51
Posts: 13096
Joined: Tue 05 Sep 2006, 13:50
Location: Stratford, Ontario

#19 Post by rcrsn51 »

greengeek wrote:By contrast the "Play" function in the bt4stretch gui did start playing to my BT headphones but the playback was intermittently extremely distorted - hard to describe but very choppy and almost as if two versions were playing at once at faster than normal speed. Between bursts of this strange behaviour the audio played correctly.
I wonder if running the bt4stretch processes at higher priority might solve this problem.

In /usr/local/bin/bt4stretch, change:

Code: Select all

line 15: nice -n -10 mplayer ...
line 193: nice -n -10 bluealsa &

User avatar
greengeek
Posts: 5789
Joined: Tue 20 Jul 2010, 09:34
Location: Republic of Novo Zelande

#20 Post by greengeek »

rcrsn51 wrote:The bluez-alsa project exists because bluez5 dropped direct support for ALSA and expects you to use pulseaudio.

This is all discussed here.
Thanks for the link. I will quote part of it:
With this application (later named as BlueALSA), one can achieve the same goal as with PulseAudio, but with less dependencies and more bare-metal-like. BlueALSA registers all known Bluetooth audio profiles in Bluez, so in theory every Bluetooth device (with audio capabilities) can be connected. In order to access the audio stream, one has to connect to the ALSA PCM device called bluealsa. The device is based on the ALSA software PCM plugin.
I had not heard of bluealsa so that's on my list to google. This is a project I want to get my teeth into. Can't really explain why my brain processes pulseaudio as repulseaudio. I just don't want it. Nice to see alsa extended once more.

I will get back to testing stretch live and will try the priority mod in a few days. Most of today has been refining a package for Slacko 5.6 - almost done. I have blended bt4stretch with puppybt and thrown out some of the more advanced functionality that I don't need yet. Need to make a thread to get that off my chest then will come back to bluez-alsa.

Post Reply