Hi,
I have a development board based on the Freescale iMX6 on which we have added the TI WL1273L. My job is to make the Bluetooth part work as a HSP and HFP audio gateway, but as I'm new to Android I not sure were to begin. I've added:
service hciattach /system/bin/logwrapper /system/bin/hciattach /dev/ttymxc4 texas 115200 flow
to init.rc. And have successfully paired a headset using the Bluetooth settings UI, used bt_sco_app, tinycap and tinyplay to record and playback a sample:
tinycap /sdcard/Music/temp.wav -D 1 -c 1 -r 8000 -b 8
tinyplay /sdcard/Music/temp.wav -D 1
I added the BluetoothSCOApp to our build, but when I play a song using the Music app the audio goes to the speaker. (The connected headset supports A2DP)
So I guess, I'm missing something to make the Android upper layers aware of the Bluetooth.
Any help would be much appreciated!
/Thomas
EDIT:
Can someone help me with what files I would need to modify? I expect that TI has implemented the driver and HAL interface, so do I just need to modify our audio_policy.conf?
Thanks!
EDIT 2:
I added A2DP to the audio_policy.conf and the audio was routed to the headset, but it's very unstable. If I play back a song with the Music app, it's doesn't always play in the headset. I think the BT link breaks and I have to reboot the dev board to get Bluetooth working again. If the audio is played in the headset the sound stutters very badly.
After a reboot the Bluetooth isn't always working.
Is it "just" a matter of configuration to get Bluetooth working or do I have to implement something?
/Thomas
已解决! 转到解答。
Hi ,
I don't know how Android handle the Bluetooth but on a Linux system when the Audio is not redirected properly is because BlueZ is not configured properly or your audio server had some issues like version problems or incompatibility.
First of all check BlueZ is configured properly for audio streaming from the device to a headset. Check the audio configuration on /etc/bluetooth/audio.conf. There's a line under General tag which allow you to enable the types of connections for audio.
Depending on you Bluetooth version maybe you need to enable more than one like Source,Gateway and sometimes socket. Some versions of Bluez had a bug issue when socket is enable you need to check the sources of your version.
This need to be done before the hciattach. Now you should check your Bluetooth interface support a2dp streaming profile. Even when is very common today is not 100% guarantee your device support the required profiles.
That could be check after you perform the hciattach executing hciconfig -a <yourdevice>.
Now after verifying all this check the device when is paring with another device is exported as sink or/and source. In your case check your i.mx bluetooth device is exported in the system as source.
In a vanilla or distro kernel pulseaudio runs as audio server and you need to had the bluetooth plugins.Then executing pactl list sources your device should be listed there.
When is not listed that mean one of the devices doesn't work support the profile, the pair was successful but with hidden issues or and very common the versions of your software libraries had a incompatibility issue even when there's
no error printing. On my experience is very common dbus and pulseaudio are not the recommended versions or pulseaudio libraries are from older versions. On BlueZ and Pulseaudio release documentations mentions the versions expected.
In your case you are using Android which should use a different user land but should still using dbus for messaging the BlueZ IPC to the system.
I don't know what you could check on the Android side.
i would leave some link which could be useful:
https://wiki.archlinux.org/index.php/Bluetooth_Headset
http://ceworkbench.wordpress.com/2011/03/21/configuring-linux-as-an-a2dp-audio-sink/
http://jprvita.wordpress.com/2009/12/15/1-2-3-4-a2dp-stream/
http://forum.xda-developers.com/showthread.php?t=1023193
http://wiki.gentoo.org/wiki/Bluetooth_Headset
Regards,
-Israel.
Hi ,
I don't know how Android handle the Bluetooth but on a Linux system when the Audio is not redirected properly is because BlueZ is not configured properly or your audio server had some issues like version problems or incompatibility.
First of all check BlueZ is configured properly for audio streaming from the device to a headset. Check the audio configuration on /etc/bluetooth/audio.conf. There's a line under General tag which allow you to enable the types of connections for audio.
Depending on you Bluetooth version maybe you need to enable more than one like Source,Gateway and sometimes socket. Some versions of Bluez had a bug issue when socket is enable you need to check the sources of your version.
This need to be done before the hciattach. Now you should check your Bluetooth interface support a2dp streaming profile. Even when is very common today is not 100% guarantee your device support the required profiles.
That could be check after you perform the hciattach executing hciconfig -a <yourdevice>.
Now after verifying all this check the device when is paring with another device is exported as sink or/and source. In your case check your i.mx bluetooth device is exported in the system as source.
In a vanilla or distro kernel pulseaudio runs as audio server and you need to had the bluetooth plugins.Then executing pactl list sources your device should be listed there.
When is not listed that mean one of the devices doesn't work support the profile, the pair was successful but with hidden issues or and very common the versions of your software libraries had a incompatibility issue even when there's
no error printing. On my experience is very common dbus and pulseaudio are not the recommended versions or pulseaudio libraries are from older versions. On BlueZ and Pulseaudio release documentations mentions the versions expected.
In your case you are using Android which should use a different user land but should still using dbus for messaging the BlueZ IPC to the system.
I don't know what you could check on the Android side.
i would leave some link which could be useful:
https://wiki.archlinux.org/index.php/Bluetooth_Headset
http://ceworkbench.wordpress.com/2011/03/21/configuring-linux-as-an-a2dp-audio-sink/
http://jprvita.wordpress.com/2009/12/15/1-2-3-4-a2dp-stream/
http://forum.xda-developers.com/showthread.php?t=1023193
http://wiki.gentoo.org/wiki/Bluetooth_Headset
Regards,
-Israel.