This thread has been locked.

If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.

WL1831 - A2DP sink profile with BlueZ4 and Pulseaudio 5.0

Other Parts Discussed in Thread: WL1831

Hi All,


We are using wl1831 module from TI in our custom board with imx6 processor.

We need to implement the A2DP sink profile. Mobile device will play audio and it should be listenable on board speaker through bluetooth.

We are using Bluez4 with Pulseaudio 5.0 and SBC 1.2.

The problem with our setup is , Mobile device is not getting detected as bluez source.

Below are the changes i have done to implement Bluetooth A2DP sink profile

  • /etc/bluetooth/audio.conf

Enable=Source,Sink,Media,Socket
SBCSources=1

  • /etc/dbus-1/system.d/bluetooth.conf

<busconfig>                                                                     
                                                               
  <!-- ../system.conf have denied everything, so we just punch some holes -->
                                                                             
  <policy context="default">                                                 
    <allow own="org.bluez"/>
    <allow send_destination="org.bluez"/>
    <allow send_interface="org.bluez.Agent"/>
  </policy>                                  
                                             
  <!-- allow users at the console, see consolekit or libpam-foreground -->
  <policy at_console="true">                                              
    <allow send_destination="org.bluez"/>                                 
  </policy>                              
                                         
  <policy user="pulse">
     <allow send_destination="org.bluez"/>
     <allow send_interface="org.freedesktop.DBus.ObjectManager"/>
  </policy>                                                      
</busconfig>  

  • /etc/dbus-1/system.d/pulseaudio-system.conf

<busconfig>                                                              
                                                                         
  <!-- System-wide PulseAudio runs as 'pulse' user. This fragment is
       not necessary for user PulseAudio instances. -->          
                                                                   
  <policy user="pulse">                                            
    <allow own="org.pulseaudio.Server"/>                           
    <allow send_destination="org.bluez"/>                          
    <allow send_interface="org.freedesktop.DBus.ObjectManager"/>   
  </policy>
                                                                    
</busconfig>

  • /etc/pulse/system.pa

.ifexists module-bluetooth-policy.so                              
load-module module-bluetooth-policy       
.endif                                                     
                                                                          
.ifexists module-bluetooth-discover.so                                 
load-module module-bluetooth-discover                         
.endif                                                                    
                                                                     
load-module module-switch-on-connect

  • /etc/pulse/daemon.conf

; resample-method = trivial


============================================================


Procedure after boot:


hciconfig hci0 up

bluetooth -n &

hciconfig hci0 piscan

pulseaudio --system --realtime &

hcitool scan

bt-device -c <BD-Address>

Here i am getting this log.

E: [pulseaudio] bluez4-util.c: org.bluez.HandsfreeGateway.GetProperties() failed: org.freedesktop.DBus.Error.Unknowt
E: [pulseaudio] bluez4-util.c: org.bluez.HandsfreeGateway.GetProperties() failed: org.freedesktop.DBus.Error.UnknownMethod: Method "Get

and when i run,

pactl load-module module-bluez4-device path=<path> name=<name> address=<BD-Address>

I am getting,

W: [pulseaudio] module-bluez4-device.c: Profile 'a2dp' not valid or not supported by device.
W: [pulseaudio] module-bluez4-device.c: Default profile not connected, selecting off profile

but if i do sdptool browse <BD-address>, I am seeing that device supports the a2dp.

Now, if i see the sources with "pactl list sources short", It does not show the bluez source for my paired mobile.

 

=========================================================================================


Questions:

  • Do i need to do anything special for TI specific module?
  • Do TI modules supports a2dp sink profile with Bluez4 stack?
  • Is it anything related to Bluetooth firmware? To and From data transfer is fine.

Please provide your suggestions

Thanks,

Jags

  • Hi Jags,

    1. No, nothing specific on the TI module side.
    2. It only depends on the stack. There is no such limitation on the device side.
    3. Not likely, but it is always recommended to use the latest Bluetooth firmware (git://git.ti.com/wilink8-bt/ti-bt-firmware.git)

    I think this is some configuration issue with the pulse audio itself. Are you able to connect to the phone via the BlueZ dbus APIs (dbus-send --print-reply --system --dest=org.bluez <path> org.bluez.AudioSource.Connect
    )?

    Regards,
    Gigi Joseph.
  • Hi Gigi,

    Thanks for your valuable and informative reply.

    Yes, I am able to connect to the phone via the dbus API. And i Play song from the phone, it is going to bluetooth and not on the phone speaker.

    but as pulseaudio is not detecting phone as a bluez source, i can not not loopback alsa sink and bluez source.

    Is there any way, i can check whether i am receiving any audio data from the phone to the wl1831?

    To play Bluetooth audio, I need to run the command like,

    pactl load-module module-loopback source=<Bluez source> sink=<alsa sink>
    but as there is no bluez source i am not able to run it.
  • Hi Jags,

    RE Qn. " Is there any way, i can check whether i am receiving any audio data from the phone to the wl1831? "
    If you are using the Shared Transport driver, you can modify: drivers/misc/ti-st/st_core.c

    static void st_tty_receive(struct tty_struct *tty, const unsigned char *data,
    char *tty_flags, int count)
    {
    //#ifdef VERBOSE //Comment this
    print_hex_dump(KERN_DEBUG, ">in>", DUMP_PREFIX_NONE,
    16, 1, data, count, 0);
    //#endif //Comment this.

    This would print out the incoming BT data (slows the system but).

    Note: askubuntu.com/.../a2dp-connection-not-shown-in-pulseaudio (maybe this helps!)

    Regards,
    Gigi Joseph.