8 Replies Latest reply on Dec 24, 2015 12:39 PM by SKhan

    How to set bluetooth headset as a pulseaudio source

    SKhan

      Hi,

       

      - I'm able to play audio on a bluetooth headset from my Edison: wav files using the gst-launch-1.0 command, and ogg files using the gstreamer helloworld.c program.

      - I'm now trying to record audio data as either raw data or in wav format.

      - But I don't even see my bluetooth headset listed in pactl list sources after I connect via bluetoothctl, only as a sink.

       

      Is there something obvious I'm missing?

        • 1. Re: How to set bluetooth headset as a pulseaudio source
          Intel_Peter

          Hello Skhan,

           

          I don't have access to a Bluetooth headset, nevertheless let me see if I can find something that might help you. I'll try to get back to you as soon as possible.

          Could you provide us any other information that you consider important, like the image you are currently using and your headset’s model?

           

          Peter.

          • 2. Re: How to set bluetooth headset as a pulseaudio source
            SKhan

            Wow thanks for the quick response, @Intel_Peter!

            I've flashed it with the a Yocto linux image. Here's what I see when I run cat /etc/issue: Poky (Yocto Project Reference Distro) 1.7.2 \n \l

            I'm using a Plantronics Voyager Legend bluetooth headset. I didn't need to install gstreamer from AlexT's repo, only the gstreamer-dev package.

            Thanks!

            • 3. Re: How to set bluetooth headset as a pulseaudio source
              Intel_Peter

              Thanks SKhan,

               

              This information will be of much help, I'm still working on this, I'll try to get back to you as soon as I can.

               

              Peter.

              • 4. Re: How to set bluetooth headset as a pulseaudio source
                Intel_Peter

                I followed section 4.4 of the Edison Audio Setup Guide using a Plantronics BT300. Since the Bluetooth headset has a USB adapter, I treated it as a "USB headset".

                If using the Arduino Kit, activate the USB host mode by moving the SW1 to right position.

                Note: external power source is needed in this mode for both Edison Kit for Arduino and Breakout board.

                 

                1. Plug the USB headset for the Bluetooth adapter.

                 

                2. Check if the device is correctly mounted:

                 

                root@MyEdison_Lab:~# cat /proc/asound/pcm
                00-00: Loopback PCM : Loopback PCM : playback 8 : capture 8
                00-01: Loopback PCM : Loopback PCM : playback 8 : capture 8
                01-00: 14 : : playback 1 : capture 1
                01-01: ((null)) : : playback 1 : capture 1
                01-02: ((null)) : : playback 1 : capture 1
                02-00: USB Audio : USB Audio : playback 1 : capture 1                   <--- Should look like this
                
                
                

                 

                3. From this USB device, you can see the number of streams handled by the device:

                 

                root@MyEdison_Lab:~# pactl list | grep Name | grep usb
                Name: alsa_output.usb-Plantronics_Plantronics_BT300_85c1bafebff57e4e80e864d6f4c9aa8a-00-BT300.analog-mono                    <--- We want this
                Name: alsa_output.usb-Plantronics_Plantronics_BT300_85c1bafebff57e4e80e864d6f4c9aa8a-00-BT300.analog-mono.monitor
                Name: alsa_input.usb-Plantronics_Plantronics_BT300_85c1bafebff57e4e80e864d6f4c9aa8a-00-BT300.analog-mono
                Name: alsa_card.usb-Plantronics_Plantronics_BT300_85c1bafebff57e4e80e864d6f4c9aa8a-00-BT300
                
                
                

                 

                4. Set the default audio output device using pactl command:

                 

                pactl set-default-sink alsa_output.usb-Plantronics_Plantronics_BT300_85c1bafebff57e4e80e864d6f4c9aa8a-00-BT300.analog-mono
                
                
                

                 

                5. Use the arecord -l command to list the audio devices and find the USB headset adapter, display should look something like this:

                 

                root@MyEdison_Lab:~# arecord -l
                **** List of CAPTURE Hardware Devices ****
                card 0: Loopback [Loopback], device 0: Loopback PCM [Loopback PCM]
                Subdevices: 8/8
                Subdevice #0: subdevice #
                card 0: Loopback [Loopback], device 1: Loopback PCM [Loopback PCM]
                Subdevices: 8/8
                Subdevice #0: subdevice #0
                Subdevice #1: subdevice #1
                Subdevice #2: subdevice #2
                Subdevice #7: subdevice #7
                card 1: dummyaudio [dummy-audio], device 0: 14 []
                Subdevices: 1/1
                Subdevice #0: subdevice #0
                card 1: dummyaudio [dummy-audio], device 1: ((null)) []
                Subdevices: 1/1
                Subdevice #0: subdevice #0
                card 1: dummyaudio [dummy-audio], device 2: ((null)) []
                Subdevices: 1/1
                Subdevice #0: subdevice #0
                card 2: BT300 [Plantronics BT300], device 0: USB Audio [USB Audio]                             <-- This is our USB adapter device
                Subdevices: 1/1
                Subdevice #0: subdevice #0
                
                
                

                 

                7. From the displayed output take note of the card# and the device# (in this example is 2 and 0) as we will need it for the following step.

                 

                8. Device is ready to record/play audio. Use the arecord command to record and store in a file locally on Edison's home directory.

                Note: to stop recording use Ctrl + C.

                 

                root@MyEdison_Lab:~# arecord -D hw:2,0 -f S16_LE -r16000 audio_record.wav
                
                
                

                 

                You can use "arecord -h" to get more information.

                 

                9. Use aplay command to play the file generated on your headset:

                 

                root@MyEdison_Lab:~# aplay -D hw:2,0 -f S16_LE -r16000 audio_record.wav
                
                
                

                 

                You can use "aplay -h" to get more information.

                 

                I hope this helps, let us know.

                 

                Peter.

                • 5. Re: How to set bluetooth headset as a pulseaudio source
                  SKhan

                  Hi Intel_Peter,

                   

                  Honestly appreciate you taking the effort. I don't have any trouble using alsa for playing and recording audio with my USB headset. For my project, I specifically need to be able to interface with a bluetooth headset (err, via bluetooth) and use Gstreamer which is where I'm struggling with setting the headset as a source. 

                  Btw, I'm wondering... what happens when you do the following?

                  - rfkill unblock bluetooth

                  - bluetoothctl (and cnnect to your headset)

                  - pactl list | grep bluez

                  Do you see your device as a sink, source or both? I'm wondering if there's something inherently wrong with trying to set a bluetooth headset as a source.

                  • 6. Re: How to set bluetooth headset as a pulseaudio source
                    Intel_Peter

                    I see, let me do some more tests and I'll get back to you.

                     

                    Peter.

                    • 7. Re: How to set bluetooth headset as a pulseaudio source
                      Intel_Peter

                      My output to pactl list | grep bluez is the following:

                       

                      Name: module-bluez5-discover 
                      Name: module-bluez5-device 
                      Argument: path=/org/bluez/hci0/dev_0C_E0_E4_12_3F_CD 
                      Name: bluez_sink.0C_E0_E4_12_3F_CD 
                      Driver: module-bluez5-device.c 
                      Monitor Source: bluez_sink.0C_E0_E4_12_3F_CD.monitor 
                      device.api = "bluez" 
                      bluez.path = "/org/bluez/hci0/dev_0C_E0_E4_12_3F_CD" 
                      bluez.class = "0x240404" 
                      bluez.alias = "PLT_Legend" 
                      Name: bluez_sink.0C_E0_E4_12_3F_CD.monitor 
                      Driver: module-bluez5-device.c 
                      Monitor of Sink: bluez_sink.0C_E0_E4_12_3F_CD 
                      device.api = "bluez" 
                      bluez.path = "/org/bluez/hci0/dev_0C_E0_E4_12_3F_CD" 
                      bluez.class = "0x240404" 
                      bluez.alias = "PLT_Legend" 
                      Name: bluez_card.0C_E0_E4_12_3F_CD 
                      Driver: module-bluez5-device.c 
                      device.api = "bluez" 
                      bluez.path = "/org/bluez/hci0/dev_0C_E0_E4_12_3F_CD" 
                      bluez.class = "0x240404" 
                      bluez.alias = "PLT_Legend"
                      

                       

                      As you can see mine is also only recognized as sink. I'm not sure if (as you mentioned) it is because we are trying to use a headset.

                       

                      Peter.

                      • 8. Re: How to set bluetooth headset as a pulseaudio source
                        SKhan

                        So then maybe this is a dead end. I should probably focus on looking for alternative solutions. Thanks for your efforts, Intel_Peter. Appreciate it.