tomk
Posts: 6
Joined: Wed Apr 13, 2016 4:33 pm

Audio output to bluetooth speaker on Pi2 B not working

Wed Apr 13, 2016 4:54 pm

I tried the whole day to get an bluetooth audio speaker on my PI2 working. I looked at all sorts of tutorials and tried various things but audio will not be output to the speaker. I have the speaker paired and on pairing it creates a short noise.

My config:

Code: Select all

PRETTY_NAME="Raspbian GNU/Linux 7 (wheezy)"
NAME="Raspbian GNU/Linux"
VERSION_ID="7"
VERSION="7 (wheezy)"

Code: Select all

$lsusb
Bus 001 Device 002: ID 0424:9514 Standard Microsystems Corp.
Bus 001 Device 001: ID 1d6b:0002 Linux Foundation 2.0 root hub
Bus 001 Device 003: ID 0424:ec00 Standard Microsystems Corp.
Bus 001 Device 004: ID 0a12:0001 Cambridge Silicon Radio, Ltd Bluetooth Dongle (HCI mode)
Bus 001 Device 005: ID 0658:0200 Sigma Designs, Inc.
$
$ sudo bluez-test-device list
11:11:11:11:8A:72 EasyAcc-Mc
$
$ sudo hciconfig -a
hci0:   Type: BR/EDR  Bus: USB
        BD Address: 00:1B:10:00:2A:EC  ACL MTU: 1017:8  SCO MTU: 64:1
        UP RUNNING
        RX bytes:3508 acl:51 sco:0 events:147 errors:0
        TX bytes:2458 acl:56 sco:0 commands:67 errors:0
        Features: 0xff 0xff 0x8f 0xfe 0x9b 0xff 0x79 0x83
        Packet type: DM1 DM3 DM5 DH1 DH3 DH5 HV1 HV2 HV3
        Link policy: RSWITCH HOLD SNIFF PARK
        Link mode: SLAVE ACCEPT
        Name: 'openhab-0'
        Class: 0x4e0100
        Service Classes: Networking, Rendering, Capturing, Telephony
        Device Class: Computer, Uncategorized
        HCI Version: 2.1 (0x4)  Revision: 0x5000
        LMP Version: 2.1 (0x4)  Subversion: 0x420e
        Manufacturer: Broadcom Corporation (15)
$
$ cat ~/.asoundrc
pcm.bluetooth {
    type bluetooth
    device  11:11:11:11:8A:72
    profile "auto"
}
$
$ cat /etc/bluetooth/audio.conf
# Configuration file for the audio service

# This section contains options which are not specific to any
# particular interface
[General]

# Switch to master role for incoming connections (defaults to true)
#Master=true

# If we want to disable support for specific services
# Defaults to supporting all implemented services
#Disable=Control,Source
# TK: mod
Enable=Source,Sink,Socket,Media

# SCO routing. Either PCM or HCI (in which case audio is routed to/from ALSA)
# Defaults to HCI
#SCORouting=PCM

# Automatically connect both A2DP and HFP/HSP profiles for incoming
# connections. Some headsets that support both profiles will only connect the
# other one automatically so the default setting of true is usually a good
# idea.
# TK: mod
AutoConnect=true

# Headset interface specific options (i.e. options which affect how the audio
# service interacts with remote headset devices)
[Headset]

# Set to true to support HFP, false means only HSP is supported
# Defaults to true
HFP=true

# Maximum number of connected HSP/HFP devices per adapter. Defaults to 1
MaxConnected=1

# Set to true to enable use of fast connectable mode (faster page scanning)
# for HFP when incomming call starts. Default settings are restored after
# call is answered or rejected. Page scan interval is much shorter and page
# scan type changed to interlaced. Such allows faster connection initiated
# by a headset.
FastConnectable=false

# Just an example of potential config options for the other interfaces
#[A2DP]
#SBCSources=1
#MPEG12Sources=0
$
$ aplay -l
**** List of PLAYBACK Hardware Devices ****
card 0: ALSA [bcm2835 ALSA], device 0: bcm2835 ALSA [bcm2835 ALSA]
  Subdevices: 8/8
  Subdevice #0: subdevice #0
  Subdevice #1: subdevice #1
  Subdevice #2: subdevice #2
  Subdevice #3: subdevice #3
  Subdevice #4: subdevice #4
  Subdevice #5: subdevice #5
  Subdevice #6: subdevice #6
  Subdevice #7: subdevice #7
card 0: ALSA [bcm2835 ALSA], device 1: bcm2835 ALSA [bcm2835 IEC958/HDMI]
  Subdevices: 1/1
  Subdevice #0: subdevice #0


I tried to play back with various methods

Code: Select all

 $ aplay /usr/share/sounds/alsa/Front_Center.wav
Playing WAVE '/usr/share/sounds/alsa/Front_Center.wav' : Signed 16 bit Little Endian, Rate 48000 Hz, Mono
$
$ speaker-test -twav

speaker-test 1.0.25

Playback device is default
Stream parameters are 48000Hz, S16_LE, 1 channels
WAV file(s)
Rate set to 48000Hz (requested 48000Hz)
Buffer size range from 512 to 32768
Period size range from 512 to 32768
Using max buffer size 32768
Periods = 4
was set period_size = 8192
was set buffer_size = 32768
 0 - Front Left
Time per period = 0.872076
 0 - Front Left
Time per period = 1.529272
 0 - Front Left
Time per period = 1.374720
 0 - Front Left
Time per period = 1.535837
 0 - Front Left
Time per period = 1.528370
 0 - Front Left
$
$ sudo mplayer -volume 10 -ao alsa:device=bluetooth  doorbell.mp3
MPlayer svn r34540 (Raspbian), built with gcc-4.6 (C) 2000-2012 MPlayer Team
mplayer: could not connect to socket
mplayer: No such file or directory
Failed to open LIRC support. You will not be able to use your remote control.

Playing doorbell.mp3.
libavformat version 53.21.1 (external)
Mismatching header version 53.19.0
Audio only file format detected.
Load subtitles in ./
==========================================================================
Requested audio codec family [mpg123] (afm=mpg123) not available.
Enable it at compilation.
Opening audio decoder: [ffmpeg] FFmpeg/libavcodec audio decoders
libavcodec version 53.35.0 (external)
Mismatching header version 53.32.2
AUDIO: 44100 Hz, 2 ch, floatle, 128.0 kbit/4.54% (ratio: 16000->352800)
Selected audio codec: [ffmp3float] afm: ffmpeg (FFmpeg MPEG layer-3 audio)
==========================================================================
[AO_ALSA] alsa-lib: pcm.c:2217:(snd_pcm_open_noupdate) Unknown PCM bluetooth
[AO_ALSA] Playback open error: No such file or directory
Failed to initialize audio driver 'alsa:device=bluetooth'
Could not open/initialize audio device -> no sound.
Audio: no sound
Video: no video


Exiting... (End of file)

None of them gave me any sound. mplayer obviously didn't detect the audio device which is kind of a hint. However, I do have no idea how to proceed from there on.
In the middle of all my attempts I also had pulseaudio installed which I removed again after reading that some users could fix their problems by deinstalling.

I am really desperate on getting that to work but I am totally stuck now.

Any help would be highly appreciated.

User avatar
Douglas6
Posts: 5066
Joined: Sat Mar 16, 2013 5:34 am
Location: Chicago, IL

Re: Audio output to bluetooth speaker on Pi2 B not working

Wed Apr 13, 2016 5:28 pm

You'll need PulseAudio. Reinstall it along with the Bluetooth modules.

Code: Select all

sudo apt-get install pulseaudio pulseaudio-module-bluetooth 
If a speaker is connected, PulseAudio will automatically route audio to it. This on the latest Raspbian Jessie with BlueZ 5.

tomk
Posts: 6
Joined: Wed Apr 13, 2016 4:33 pm

Re: Audio output to bluetooth speaker on Pi2 B not working

Wed Apr 13, 2016 6:51 pm

Ok, I installed it.

Not working.... Any other ideas?

Code: Select all

$ sudo mplayer -volume 10 -ao alsa:device=bluetooth  doorbell.mp3
MPlayer svn r34540 (Raspbian), built with gcc-4.6 (C) 2000-2012 MPlayer Team
mplayer: could not connect to socket
mplayer: No such file or directory
Failed to open LIRC support. You will not be able to use your remote control.

Playing doorbell.mp3.
libavformat version 53.21.1 (external)
Mismatching header version 53.19.0
Audio only file format detected.
Load subtitles in ./
==========================================================================
Requested audio codec family [mpg123] (afm=mpg123) not available.
Enable it at compilation.
Opening audio decoder: [ffmpeg] FFmpeg/libavcodec audio decoders
libavcodec version 53.35.0 (external)
Mismatching header version 53.32.2
AUDIO: 44100 Hz, 2 ch, floatle, 128.0 kbit/4.54% (ratio: 16000->352800)
Selected audio codec: [ffmp3float] afm: ffmpeg (FFmpeg MPEG layer-3 audio)
==========================================================================
[AO_ALSA] alsa-lib: pcm.c:2217:(snd_pcm_open_noupdate) Unknown PCM bluetooth
[AO_ALSA] Playback open error: No such file or directory
Failed to initialize audio driver 'alsa:device=bluetooth'
Could not open/initialize audio device -> no sound.
Audio: no sound
Video: no video


Exiting... (End of file)

User avatar
Douglas6
Posts: 5066
Joined: Sat Mar 16, 2013 5:34 am
Location: Chicago, IL

Re: Audio output to bluetooth speaker on Pi2 B not working

Wed Apr 13, 2016 7:03 pm

Give yourself PulseAudio privileges

Code: Select all

sudo usermod -a -G pulse-access pi
Then try

Code: Select all

pactl list sinks
If your speaker is connected, you should see a second Bluetooth sink. Try using aplay to play a wav file.

tomk
Posts: 6
Joined: Wed Apr 13, 2016 4:33 pm

Re: Audio output to bluetooth speaker on Pi2 B not working

Wed Apr 13, 2016 9:24 pm

I see the second sink

Code: Select all

 $ pactl list sinks
Sink #0
        State: SUSPENDED
        Name: alsa_output.0.analog-stereo
        Description: bcm2835 ALSA Analog Stereo
        Driver: module-alsa-card.c
        Sample Specification: s16le 2ch 48000Hz
        Channel Map: front-left,front-right
        Owner Module: 4
        Mute: no
        Volume: 0:   2% 1:   2%
                0: -106.36 dB 1: -106.36 dB
                balance 0.00
        Base Volume:  86%
                     -4.00 dB
        Monitor Source: alsa_output.0.analog-stereo.monitor
        Latency: 0 usec, configured 0 usec
        Flags: HARDWARE HW_MUTE_CTRL HW_VOLUME_CTRL DECIBEL_VOLUME LATENCY
        Properties:
                alsa.resolution_bits = "16"
                device.api = "alsa"
                device.class = "sound"
                alsa.class = "generic"
                alsa.subclass = "generic-mix"
                alsa.name = "bcm2835 ALSA"
                alsa.id = "bcm2835 ALSA"
                alsa.subdevice = "0"
                alsa.subdevice_name = "subdevice #0"
                alsa.device = "0"
                alsa.card = "0"
                alsa.card_name = "bcm2835 ALSA"
                alsa.long_card_name = "bcm2835 ALSA"
                device.bus_path = "/devices/virtual/sound/card0"
                sysfs.path = "/devices/virtual/sound/card0"
                device.string = "hw:0"
                device.buffering.buffer_size = "65536"
                device.buffering.fragment_size = "65536"
                device.access_mode = "mmap+timer"
                device.profile.name = "analog-stereo"
                device.profile.description = "Analog Stereo"
                device.description = "bcm2835 ALSA Analog Stereo"
                alsa.mixer_name = "Broadcom Mixer"
                module-udev-detect.discovered = "1"
                device.icon_name = "audio-card"
        Ports:
                analog-output: Analog Output (priority: 9900)
        Active Port: analog-output
        Formats:
                pcm

Sink #1
        State: SUSPENDED
        Name: bluez_sink.11_11_11_11_8A_72
        Description: EasyAcc-Mc
        Driver: module-bluetooth-device.c
        Sample Specification: s16le 1ch 8000Hz
        Channel Map: mono
        Owner Module: 6
        Mute: no
        Volume: 0: 100%
                balance 0.00
        Base Volume: 100%
        Monitor Source: bluez_sink.11_11_11_11_8A_72.monitor
        Latency: 0 usec, configured 0 usec
        Flags: HARDWARE HW_VOLUME_CTRL LATENCY
        Properties:
                bluetooth.protocol = "sco"
                device.intended_roles = "phone"
                device.description = "EasyAcc-Mc"
                device.string = "11:11:11:11:8A:72"
                device.api = "bluez"
                device.class = "sound"
                device.bus = "bluetooth"
                device.form_factor = "headset"
                bluez.path = "/org/bluez/2342/hci0/dev_11_11_11_11_8A_72"
                bluez.class = "0x240404"
                bluez.name = "EasyAcc-Mc"
                device.icon_name = "audio-headset-bluetooth"
        Formats:
                pcm
I tried

Code: Select all

 $ aplay /usr/share/sounds/alsa/Front_Center.wav
Playing WAVE '/usr/share/sounds/alsa/Front_Center.wav' : Signed 16 bit Little Endian, Rate 48000 Hz, Mono
but with no success.

To check whether the speaker works I paired it with my mobile and it works.

User avatar
Douglas6
Posts: 5066
Joined: Sat Mar 16, 2013 5:34 am
Location: Chicago, IL

Re: Audio output to bluetooth speaker on Pi2 B not working

Wed Apr 13, 2016 9:36 pm

Hmm, that works for me. Try paplay, and you might try a longer audio file, 'green' speakers sometimes swallow the first bit of audio. Are you able to play audio to the onboard audio jack when the Bluetooth speaker is not connected? I think I forced audio to the jack with raspi-config.

tomk
Posts: 6
Joined: Wed Apr 13, 2016 4:33 pm

Re: Audio output to bluetooth speaker on Pi2 B not working

Thu Apr 14, 2016 6:40 am

Ok, I tried headphones directly on the3 audio jack and a longer wav file.

Only

Code: Select all

omyplayer  -o local t.wav
produced the sound to the headphone on the audio jack.

All other players produced just noise. So whenever I played the file I clearly heard noise being created.

User avatar
startrek.steve
Posts: 390
Joined: Thu Aug 30, 2012 7:19 pm

Re: Audio output to bluetooth speaker on Pi2 B not working

Thu Apr 14, 2016 7:40 am

Try playing through VLC, you can choose the output device within the program.
Pi 2 running LibreElec Krypton, Pi 2 running Wheezy Desktop, Pi 1 headless Wheezy, downloading Radio, Pi 1 running Picore headless Media Server, Pi Zero to be an Old Time Radio Project. Pi 3 testing. Pi Zero W downloading Radio shows headless.

tomk
Posts: 6
Joined: Wed Apr 13, 2016 4:33 pm

Re: Audio output to bluetooth speaker on Pi2 B not working

Thu Apr 14, 2016 4:49 pm

Try playing through VLC, you can choose the output device within the program.
Thanks for that advice. But I need to make it work in general, since eventually I would like to use it from OpenHab. So if can get it to work only with VLC it will probably get me nowhere.

tomk
Posts: 6
Joined: Wed Apr 13, 2016 4:33 pm

Re: Audio output to bluetooth speaker on Pi2 B not working

Wed Apr 20, 2016 4:52 pm

I freshly installed a Raspberry 3 with Jessie and tried it again which at first did not work.

Then however, I came across the following description https://gist.github.com/dlech/7e9d28bcc ... tooth-conf

After performing all the listed steps, it worked!!!! :D :D :D :D

Return to “Troubleshooting”