Setup bluetooth speaker with imx6 apalis board, pulseaudio

Hello Experts,

I want to connect and play an audio file in Bluetooth speaker using apalis imx6 board.
How can I do this ?
I read the articles in internet, seems we need to configure the pulseaudio.
I am able to enable bluetooth controller in apalis board and able to see the bluetooth speaker MAC ID using 'bluetoothctl" command, but don’t know how to connect and play an audio file.

Able to compile the pulseaudio source code in apalis imx6 board and don’t know how to configure the pulseaudio to play an audio file.

Any reference links for configuring the BT speaker for apalis imx6 board ??

Got the below log while running the pulseaudio.
Once I run the pulseaudio, not able to see the bluez stack in pactl command output.

root@apalis-imx6:~# 
root@apalis-imx6:~# pulseaudio 
W: [pulseaudio] main.c: This program is not intended to be run as root (unless --system is specified).   

Got the below error while running as normal user.

apalis-imx6:~$ pulseaudio 
E: [pulseaudio] module.c: Failed to load module "module-alsa-sink" (argument: ""): initialization failed.
E: [pulseaudio] main.c: Module load failed.
E: [pulseaudio] main.c: Failed to initialize daemon.
apalis-imx6:~$ 
apalis-imx6:~$ 

In my understanding, source should be apalis imx6 audio card and sink should be BT speaker device.
But not able to see any BT speaker in pacmd & pactl command output.

I have attached the pacmd and pactl commands output log.

Can you please help me out of this issue ?

link text

Regards,

Titus S.

Sorry but we do not have any experience with the use of Pulseaudio on our Embedded Linux images. You may find the community post here and here helpful.

Thanks for your reply.
Can you please help me how I can interface bluetooth speaker to toradex imx apalis board ?
Is there any other method for interfacing BT speaker other than pulseaudio ?

Is there any other method for interfacing BT speaker other than pulseaudio ?

No. bluez5 user space stack required for Bluetooth dropped support for ALSA, so pulseaudio is the only option. See this commit.

Can you please help me how I can interface bluetooth speaker to toradex imx apalis board?

Sorry but we do not have any information on this setup. You may find this NXP community [post] 2 helpful.

Hi eschall,

Here is the update now.
Able to pair & connect my BT speaker and able to list as sink devices.
Still I am hearing the music in LINE OUT of apalis board not in BT speaker.

apalis-imx6:~$ 
apalis-imx6:~$ pactl list sinks
Sink #1
        State: SUSPENDED
        Name: bluez_sink.00_1F_47_A6_B1_B8
        Description: LG SOUND BAR
        Driver: module-bluez5-device.c
        Sample Specification: s16le 2ch 44100Hz
        Channel Map: front-left,front-right
        Owner Module: 20
        Mute: no
        Volume: front-left: 65536 / 100% / 0.00 dB,   front-right: 65536 / 100% / 0.00 dB
                balance 0.00
        Base Volume: 65536 / 100% / 0.00 dB
        Monitor Source: bluez_sink.00_1F_47_A6_B1_B8.monitor
        Latency: 0 usec, configured 0 usec
        Flags: HARDWARE DECIBEL_VOLUME LATENCY 
        Properties:
                bluetooth.protocol = "a2dp_sink"
                device.description = "LG SOUND BAR"
                device.string = "00:1F:47:A6:B1:B8"
                device.api = "bluez"
                device.class = "sound"
                device.bus = "bluetooth"
                device.form_factor = "hifi"
                bluez.path = "/org/bluez/hci0/dev_00_1F_47_A6_B1_B8"
                bluez.class = "0x240428"
                bluez.alias = "LG SOUND BAR"
                device.icon_name = "audio-card-bluetooth"
        Ports:
                hifi-output: HiFi (priority: 0)
        Active Port: hifi-output
        Formats:
                pcm
apalis-imx6:~$ 
apalis-imx6:~$ pactl list modules
=========

        Usage counter: n/a
        Properties:
                module.author = "Colin Guthrie"
                module.description = "Load filter sinks automatically when needed"
                module.version = "10.99.1-1-gc2dd5"

Module #18
        Name: module-bluetooth-discover
        Argument: 
        Usage counter: n/a
        Properties:
                module.author = "Jo�ão Paulo Rechi Vita"
                module.description = "Detect available Bluetooth daemon and load the corres"
                module.version = "9.0"

Module #19
        Name: module-bluez5-discover
        Argument: 
        Usage counter: n/a
        Properties:
                module.author = "Jo�ão Paulo Rechi Vita"
                module.description = "Detect available BlueZ 5 Bluetooth audio devices and "
                module.version = "9.0"

Module #20
        Name: module-bluez5-device
        Argument: path=/org/bluez/hci0/dev_00_1F_47_A6_B1_B8
        Usage counter: 0
        Properties:
                module.author = "Jo�ão Paulo Rechi Vita"
                module.description = "BlueZ 5 Bluetooth audio sink and source"
                module.version = "9.0"
apalis-imx6:~$ 
apalis-imx6:~$ 
apalis-imx6:~$ 
apalis-imx6:~$ aplay -l
**** List of PLAYBACK Hardware Devices ****
card 0: imx6qapalissgtl [imx6q-apalis-sgtl5000], device 0: HiFi sgtl5000-0 []
  Subdevices: 1/1
  Subdevice #0: subdevice #0
card 1: imxspdif [imx-spdif], device 0: S/PDIF PCM snd-soc-dummy-dai-0 []
  Subdevices: 1/1
  Subdevice #0: subdevice #0
card 2: imxhdmisoc [imx-hdmi-soc], device 0: i.MX HDMI Audio Tx hdmi-hifi-0 []
  Subdevices: 1/1
  Subdevice #0: subdevice #0
apalis-imx6:~$ 
apalis-imx6:~$ 
apalis-imx6:~$ 
apalis-imx6:~$ aplay audio_test.wav 
Playing WAVE 'audio_test.wav' : Signed 16 bit Little Endian, Rate 44100 Hz, Stereo
^CAborted by signal Interrupt...

apalis-imx6:~$ 
apalis-imx6:~$ 
apalis-imx6:~$

You have to add the user to the audio group in the file /etc/group .Or type
gpasswd -a audio
at the command level

aplay specifically uses the ALSA API’s to play audio, so this is to be expected…

You have to use a playback command which supports Pulseaudio. There is paplay (if installed) or GStreamer also has pulsesink. E.g. Something like this should work

gst-launch-1.0 filesrc location=thesong.mp3 ! decodebin ! audioconvert ! pulsesink device=bluez_sink.00_1F_47_A6_B1_B8

(the device property is probably not even necessary since you only have one Pulseaudio sink.

Thanks.
Will try and let you know.

Thanks.
Will try and let you know.

Hello,

gst-launch-1.0 filesrc location=thesong.mp3 ! decodebin ! audioconvert ! pulsesink device=bluez_sink.00_1F_47_A6_B1_B8

It worked! Thanks much!
I was this stage for couple of weeks, eventually I came out of this problem.
Thanks again. Appreciate your help. God bless !

Able to hear the music in BT speaker using the below command. Thanks to stefan.tx

gst-launch-1.0 filesrc location=thesong.mp3 ! decodebin ! audioconvert ! pulsesink device=bluez_sink.00_1F_47_A6_B1_B8

Hi Titus,

You are on the right track i do have some experience in pulse audio, so lets come to the point

So from the your previous post pactl list sinks listed your Bluetooth Speaker

$ pactl list sinks

So you the sink is “bluez_sink.00_1F_47_A6_B1_B8” Ok.

So run this command

$ pactl set-default-sink bluez_sink.00_1F_47_A6_B1_B8

Now you bluetooth Speak is the default sink of pulseaudio
To check everything works fine,use paplay commad to play a wav file, you can find the

$ paplay /usr/share/sounds/alsa/Front_Center.wav

You Should have heard Front_Center at the Bluetooth Speakers.

Another method is also there to make your BT Speakers as default sink for your board…

Regards,

Thanks for the help.

which BT dongle is easiest one for MCIMX6Q5EYM10AD in LINUX KERNAL VERSION 3.14.52 ?
I know MCIMX6Q5EYM10AD can support only a few BT chipset like as BCM4339
But, we can not use BCM4339 as it is WIFI and BT combo solution so that duplication of WIFI function
brings about conflict (it’s not sure. the engineer in our company is afraid of it)

I am looking for BT dongle manufacturer who can provide perfect drive source for it to be detected and operated smoothly in that environment (MCIMX6Q5EYM10AD in LINUX KERNAL VERSION 3.14.52 )

S/W resources in our company is so limited that they can’t design drive source by themselves.
that’s why I look for BT dongle manufacturer and BT dongle part NO to make the efforts of our company minimize .

any comments or sending email to sunghoka1@gamil.com would be highly appreciated

hi klee

Could you provide some more information about the toradex module you are using? Hardware and software version? It would be also nice to ask a new question.

Best regards
Jaski