Headless Pi3 - Wie Pulseaudio einrichten? (Gelöst)Umstieg auf Stretch /BlueAlsa

Begonnen von schwatter, 23 Januar 2018, 23:07:18

Vorheriges Thema - Nächstes Thema

schwatter

Nabend,

ich versuche schon seit 3 Tagen meinen Headless Raspi3 mit einem Bluetoothspeaker zu verbinden.

[/root@raspi3-fhem:~# pulseaudio --version
pulseaudio 5.0
root@raspi3-fhem:~# bluetoothd -v
5.23


Problem,
Pulseaudio benötigt einen Desktop. Das habe ich folgendermaßen gelöst.

Xvfb :1 -screen 0 1x1x8 &
export DBUS_SESSION_BUS_ADDRESS=unix:path=/run/dbus/system_bus_socket
DISPLAY=:1 dbus-launch
DISPLAY=:1 pulseaudio --start


Per bluetoothctl habe ich meinen Speaker erst auf trust gesetzt und dann gepaired.
Außerdem diverse Configs angepasst, nach den ganzen Anleitungen im Internet.

Angefangen habe ich mit dieser Anleitung.

https://github.com/davidedg/NAS-mod-config/blob/master/bt-sound/bt-sound-Bluez5_PulseAudio5.txt

Nachdem ich nicht weiterkam, und von einem Problem zum anderen stolpert bin, habe ich mich stark verfranzt...

Normal wird per

Zitatpactl list sinks short

der Bluetoothspeaker angezeigt. Ich bekomme es aber nicht hin...

Wernieman

#1
1. Seit wann braucht opulsaudio einen Desktop?
2. Unter welchem User lässt Du denn pulsaudio laufen?
3. Hast Du das passende Modul installiert? pulseaudio-module-bluetooth

Edit:
Allerdings noch ein Hinweis:
Bluetooth legt sich heufig bei nichtbenuzung schlafen .. dann verlierst Du die Konnektion.  Hatten es schon mehrfach hier im Forum besprochen. Eine Lösung dafür wurde nicht gefunden, aber wir sind auch n icht im Spezialforum für pulseaudio/bluetooth
- Bitte um Input für Output
- When there is a Shell, there is a Way
- Wann war Dein letztes Backup?

Wie man Fragen stellt: https://tty1.net/smart-questions_de.html

schwatter

Das Modul ist installiert

Zitatroot@raspi3-fhem:~# apt-get install pulseaudio-module-bluetooth
Reading package lists... Done
Building dependency tree
Reading state information... Done
pulseaudio-module-bluetooth is already the newest version.
0 upgraded, 0 newly installed, 0 to remove and 0 not upgraded.
root@raspi3-fhem:~#

Außerdem

Zitatapt-get update && apt-get upgrade

Was ich noch vergessen habe zu erwähnen. Ich nutze

Zitatroot@raspi3-fhem:~# cat /proc/version
Linux version 4.9.35-v7+ (dc4@dc4-XPS13-9333) (gcc version 4.9.3 (crosstool-NG crosstool-ng-1.22.0-88-g8460611) ) #1014 SMP Fri Jun 30 14:47:43 BST 2017
root@raspi3-fhem:~#

Und habe das HM-MOD-RPI-PCB HomeMatic Funkmodul für Raspberry Pi installiert und nach dem Wiki eingerichtet.

https://wiki.fhem.de/wiki/HM-MOD-RPI-PCB_HomeMatic_Funkmodul_f%C3%BCr_Raspberry_Pi

Meine pulseaudio.service in /etc/systemd/system

[Unit]
Description=Pulse Audio

[Service]
Type=simple
ExecStart=/usr/bin/pulseaudio --system --disallow-exit --disable-shm

[Install]
WantedBy=multi-user.target


Meine dbus-org.bluez.service in /etc/systemd/system

[Unit]
Description=Bluetooth service
Documentation=man:bluetoothd(8)

[Service]
Type=dbus
BusName=org.bluez
ExecStart=/usr/lib/bluetooth/bluetoothd
NotifyAccess=main
#WatchdogSec=10
#Restart=on-failure
CapabilityBoundingSet=CAP_NET_ADMIN CAP_NET_BIND_SERVICE
LimitNPROC=1

[Install]
WantedBy=bluetooth.target
Alias=dbus-org.bluez.service


Meine dbus-org.freedesktop.Avahi.service in  in /etc/systemd/system

# This file is part of avahi.
#
# avahi is free software; you can redistribute it and/or modify it
# under the terms of the GNU Lesser General Public License as
# published by the Free Software Foundation; either version 2 of the
# License, or (at your option) any later version.
#
# avahi is distributed in the hope that it will be useful, but WITHOUT
# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
# or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public
# License for more details.
#
# You should have received a copy of the GNU Lesser General Public
# License along with avahi; if not, write to the Free Software
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
# USA.

[Unit]
Description=Avahi mDNS/DNS-SD Stack
Requires=avahi-daemon.socket

[Service]
Type=dbus
BusName=org.freedesktop.Avahi
ExecStart=/usr/sbin/avahi-daemon -s
ExecReload=/usr/sbin/avahi-daemon -r
NotifyAccess=main

[Install]
WantedBy=multi-user.target
Also=avahi-daemon.socket
Alias=dbus-org.freedesktop.Avahi.service


Meine pulseadio.conf in /etc/dbus-1/system.d/

<!DOCTYPE busconfig PUBLIC
"-//freedesktop//DTD D-BUS Bus Configuration 1.0//EN"
"http://www.freedesktop.org/standards/dbus/1.0/busconfig.dtd">
<busconfig>
  <policy user="root">
    <allow own="org.pulseaudio.Server"/>
    <allow send_destination="org.bluez"/>
    <allow send_interface="org.bluez.Manager"/>
  </policy>
  <policy user="pulse">
    <allow own="org.pulseaudio.Server"/>
    <allow send_destination="org.bluez"/>
    <allow send_interface="org.bluez.Manager"/>
  </policy>
  <policy context="default">
    <deny own="org.pulseaudio.Server"/>
    <deny send_destination="org.bluez"/>
    <deny send_interface="org.bluez.Manager"/>
  </policy>
</busconfig>


Meine pulseadio-bluetooth.conf in /etc/dbus-1/system.d/

<busconfig>
 
<policy user="pulse"> 
  <allow send_destination="org.bluez"/> 
</policy> 

</busconfig> 


Meine pulseadio-system.conf in /etc/dbus-1/system.d/

<?xml version="1.0"?><!--*-nxml-*-->
<!DOCTYPE busconfig PUBLIC "-//freedesktop//DTD D-BUS Bus Configuration 1.0//EN"
"http://www.freedesktop.org/standards/dbus/1.0/busconfig.dtd">

<!--
This file is part of PulseAudio.

PulseAudio is free software; you can redistribute it and/or modify it
under the terms of the GNU Lesser General Public License as
published by the Free Software Foundation; either version 2.1 of the
License, or (at your option) any later version.

PulseAudio is distributed in the hope that it will be useful, but WITHOUT
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General
Public License for more details.

You should have received a copy of the GNU Lesser General Public
License along with PulseAudio; if not, see <http://www.gnu.org/licenses/>.
-->

<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"/>
  </policy>

</busconfig>


Meine Configs in /etc/pulse/

Client

# This file is part of PulseAudio.
#
# PulseAudio is free software; you can redistribute it and/or modify
# it under the terms of the GNU Lesser General Public License as published by
# the Free Software Foundation; either version 2 of the License, or
# (at your option) any later version.
#
# PulseAudio is distributed in the hope that it will be useful, but
# WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
# General Public License for more details.
#
# You should have received a copy of the GNU Lesser General Public License
# along with PulseAudio; if not, see <http://www.gnu.org/licenses/>.

## Configuration file for PulseAudio clients. See pulse-client.conf(5) for
## more information. Default values are commented out.  Use either ; or # for
## commenting.

; default-sink =
; default-source =
; default-server =
; default-dbus-server =

; autospawn = yes
; daemon-binary = /usr/bin/pulseaudio
; extra-arguments = --log-target=syslog

; cookie-file =

; enable-shm = yes
; shm-size-bytes = 0 # setting this 0 will use the system-default, usually 64 MiB

; auto-connect-localhost = no
; auto-connect-display = no


Demon

# This file is part of PulseAudio.
#
# PulseAudio is free software; you can redistribute it and/or modify
# it under the terms of the GNU Lesser General Public License as published by
# the Free Software Foundation; either version 2 of the License, or
# (at your option) any later version.
#
# PulseAudio is distributed in the hope that it will be useful, but
# WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
# General Public License for more details.
#
# You should have received a copy of the GNU Lesser General Public License
# along with PulseAudio; if not, see <http://www.gnu.org/licenses/>.

## Configuration file for the PulseAudio daemon. See pulse-daemon.conf(5) for
## more information. Default values are commented out.  Use either ; or # for
## commenting.

; daemonize = no
; fail = yes
; allow-module-loading = yes
; allow-exit = yes
; use-pid-file = yes
system-instance = yes
; local-server-type = user
; enable-shm = yes
; enable-memfd = yes
; shm-size-bytes = 0 # setting this 0 will use the system-default, usually 64 MiB
; lock-memory = no
; cpu-limit = no

; high-priority = yes
; nice-level = -11

; realtime-scheduling = yes
; realtime-priority = 5

; exit-idle-time = 20
; scache-idle-time = 20

; dl-search-path = (depends on architecture)

; load-default-script-file = yes
; default-script-file = /etc/pulse/default.pa

; log-target = auto
; log-level = notice
; log-meta = no
; log-time = no
; log-backtrace = 0

resample-method = trivial
; avoid-resampling = false
; enable-remixing = yes
; remixing-use-all-sink-channels = yes
; enable-lfe-remixing = no
; lfe-crossover-freq = 0

; flat-volumes = yes

; rlimit-fsize = -1
; rlimit-data = -1
; rlimit-stack = -1
; rlimit-core = -1
; rlimit-as = -1
; rlimit-rss = -1
; rlimit-nproc = -1
; rlimit-nofile = 256
; rlimit-memlock = -1
; rlimit-locks = -1
; rlimit-sigpending = -1
; rlimit-msgqueue = -1
; rlimit-nice = 31
; rlimit-rtprio = 9
; rlimit-rttime = 200000

; default-sample-format = s16le
; default-sample-rate = 44100
; alternate-sample-rate = 48000
; default-sample-channels = 2
; default-channel-map = front-left,front-right

; default-fragments = 4
; default-fragment-size-msec = 25

; enable-deferred-volume = yes
; deferred-volume-safety-margin-usec = 8000
; deferred-volume-extra-delay-usec = 0


Default

#!/usr/bin/pulseaudio -nF
#
# This file is part of PulseAudio.
#
# PulseAudio is free software; you can redistribute it and/or modify it
# under the terms of the GNU Lesser General Public License as published by
# the Free Software Foundation; either version 2 of the License, or
# (at your option) any later version.
#
# PulseAudio is distributed in the hope that it will be useful, but
# WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
# General Public License for more details.
#
# You should have received a copy of the GNU Lesser General Public License
# along with PulseAudio; if not, see <http://www.gnu.org/licenses/>.

# This startup script is used only if PulseAudio is started per-user
# (i.e. not in system mode)

.fail

### Automatically restore the volume of streams and devices
load-module module-device-restore
load-module module-stream-restore
load-module module-card-restore

### Automatically augment property information from .desktop files
### stored in /usr/share/application
load-module module-augment-properties

### Should be after module-*-restore but before module-*-detect
load-module module-switch-on-port-available

### Load audio drivers statically
### (it's probably better to not load these drivers manually, but instead
### use module-udev-detect -- see below -- for doing this automatically)
#load-module module-alsa-sink
#load-module module-alsa-source device=hw:1,0
#load-module module-oss device="/dev/dsp" sink_name=output source_name=input
#load-module module-oss-mmap device="/dev/dsp" sink_name=output source_name=input
#load-module module-null-sink
#load-module module-pipe-sink

### Automatically load driver modules depending on the hardware available
.ifexists module-udev-detect.so
load-module module-udev-detect
.else
### Use the static hardware detection module (for systems that lack udev support)
load-module module-detect
.endif

### Automatically connect sink and source if JACK server is present
.ifexists module-jackdbus-detect.so
.nofail
load-module module-jackdbus-detect channels=2
.fail
.endif

### Automatically load driver modules for Bluetooth hardware
.ifexists module-bluetooth-policy.so
load-module module-bluetooth-policy
.endif

.ifexists module-bluetooth-discover.so
load-module module-bluetooth-discover
.endif

### Load several protocols
.ifexists module-esound-protocol-unix.so
load-module module-esound-protocol-unix
.endif
load-module module-native-protocol-unix

### Network access (may be configured with paprefs, so leave this commented
### here if you plan to use paprefs)
#load-module module-esound-protocol-tcp
#load-module module-native-protocol-tcp
#load-module module-zeroconf-publish

### Load the RTP receiver module (also configured via paprefs, see above)
#load-module module-rtp-recv

### Load the RTP sender module (also configured via paprefs, see above)
#load-module module-null-sink sink_name=rtp format=s16be channels=2 rate=44100 sink_properties="device.description='RTP Multicast Sink'"
#load-module module-rtp-send source=rtp.monitor

### Load additional modules from GConf settings. This can be configured with the paprefs tool.
### Please keep in mind that the modules configured by paprefs might conflict with manually
### loaded modules.
.ifexists module-gconf.so
.nofail
load-module module-gconf
.fail
.endif

### Automatically restore the default sink/source when changed by the user
### during runtime
### NOTE: This should be loaded as early as possible so that subsequent modules
### that look up the default sink/source get the right value
load-module module-default-device-restore

### Automatically move streams to the default sink if the sink they are
### connected to dies, similar for sources
load-module module-rescue-streams

### Make sure we always have a sink around, even if it is a null sink.
load-module module-always-sink

### Honour intended role device property
load-module module-intended-roles

### Automatically suspend sinks/sources that become idle for too long
load-module module-suspend-on-idle

### If autoexit on idle is enabled we want to make sure we only quit
### when no local session needs us anymore.
.ifexists module-console-kit.so
load-module module-console-kit
.endif
.ifexists module-systemd-login.so
load-module module-systemd-login
.endif

### Enable positioned event sounds
load-module module-position-event-sounds

### Cork music/video streams when a phone stream is active
load-module module-role-cork

### Modules to allow autoloading of filters (such as echo cancellation)
### on demand. module-filter-heuristics tries to determine what filters
### make sense, and module-filter-apply does the heavy-lifting of
### loading modules and rerouting streams.
load-module module-filter-heuristics
load-module module-filter-apply

### Make some devices default
#set-default-sink output
#set-default-source input


System

#!/usr/bin/pulseaudio -nF
#
# This file is part of PulseAudio.
#
# PulseAudio is free software; you can redistribute it and/or modify it
# under the terms of the GNU Lesser General Public License as published by
# the Free Software Foundation; either version 2 of the License, or
# (at your option) any later version.
#
# PulseAudio is distributed in the hope that it will be useful, but
# WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
# General Public License for more details.
#
# You should have received a copy of the GNU Lesser General Public License
# along with PulseAudio; if not, see <http://www.gnu.org/licenses/>.

# This startup script is used only if PulseAudio is started in system
# mode.

### Automatically load driver modules depending on the hardware available
.ifexists module-udev-detect.so
load-module module-udev-detect
.else
### Use the static hardware detection module (for systems that lack udev/hal support)
load-module module-detect
.endif

### Load several protocols
.ifexists module-esound-protocol-unix.so
load-module module-esound-protocol-unix
.endif
load-module module-native-protocol-unix

### Automatically restore the volume of streams and devices
load-module module-stream-restore
load-module module-device-restore

### Automatically restore the default sink/source when changed by the user
### during runtime
### NOTE: This should be loaded as early as possible so that subsequent modules
### that look up the default sink/source get the right value
load-module module-default-device-restore

### Automatically move streams to the default sink if the sink they are
### connected to dies, similar for sources
load-module module-rescue-streams

### Make sure we always have a sink around, even if it is a null sink.
load-module module-always-sink

### Automatically suspend sinks/sources that become idle for too long
load-module module-suspend-on-idle

### Enable positioned event sounds
load-module module-position-event-sounds

### Automatically load driver modules for Bluetooth hardware 
.ifexists module-bluetooth-policy.so 
load-module module-bluetooth-policy 
.endif 

.ifexists module-bluetooth-discover.so 
load-module module-bluetooth-discover 
.endif 


Folgende Rechte vergeben

usermod -a -G pulse-access,audio root
usermod -a -G pulse-access,audio pi
usermod -a -G pulse-access,audio fhem



Warum ich es hier im Forum versuche? Da hier viele intelligente Menschen sind, mit sehr guten Linuxkenntnissen.



Wernieman

#3
Also ... Du kriegst den Lautsprecher Gepeert?

P.S. Rasperry3 interner oder USB-Bluetooth?

P.P.S.
Was ich immer noch nicht verstehe, warum brauchst Du einen Desktop? Kann es sein, das Du eine Desktop-Distri und nicht eine "Server-Distri" installiert hast? Wäre für ein Headless-System "blöde" ...
- Bitte um Input für Output
- When there is a Shell, there is a Way
- Wann war Dein letztes Backup?

Wie man Fragen stellt: https://tty1.net/smart-questions_de.html

schwatter

Genau, ich bekomme den Speaker gepaired. Ich versuche es mit dem internen Bluetoothmodul.

root@raspi3-fhem:~# sudo hciconfig -a
hci0:   Type: BR/EDR  Bus: UART
        BD Address: B8:27:EB:CA:88:44  ACL MTU: 1021:8  SCO MTU: 64:1
        UP RUNNING PSCAN
        RX bytes:940 acl:4 sco:0 events:54 errors:0
        TX bytes:1605 acl:2 sco:0 commands:50 errors:0
        Features: 0xbf 0xfe 0xcf 0xfe 0xdb 0xff 0x7b 0x87
        Packet type: DM1 DM3 DM5 DH1 DH3 DH5 HV1 HV2 HV3
        Link policy: RSWITCH SNIFF
        Link mode: SLAVE ACCEPT
        Name: 'RaspStream'
        Class: 0x0c0000
        Service Classes: Rendering, Capturing
        Device Class: Miscellaneous,
        HCI Version: 4.1 (0x7)  Revision: 0x145
        LMP Version: 4.1 (0x7)  Subversion: 0x2209
        Manufacturer: Broadcom Corporation (15)


Der Lautsprecher disconnected bei einem reboot und connected auch wieder automatisch. Signalisiert er mir auch.
Den Fakedesktop benötige ich, wegen dem dbus-daemon.

ZitatHowever, Pulseaudio needs dbus, and dbus needs an X session. Without graphical session, Pulseaudio is only able to run in system mode, which is officially not recommanded.

Quelle:
https://github.com/mk-fg/pulseaudio-mixer-cli/issues/17
https://unix.stackexchange.com/questions/105964/launch-a-fake-minimal-x-session-for-pulseaudio-dbus

mumpitzstuff

https://wiki.fhem.de/wiki/Text2Speech

Bei mir läuft es. Ich hatte die Anleitung dazu im Wiki abgelegt.

schwatter

Danke, ich werde mich mal stumpf nach der Anleitung richten.

2 Fragen,

- Betreibst du auch einen Headless?
- Nutzt du auch das HM-MOD-RPI-PCB HomeMatic Funkmodul für Raspberry Pi?

mumpitzstuff

Headless=ohne Oberfläche? Ja.
Ich verwende ein hmlan und kein raspberry Modul. Ich glaube aber nicht, das sich daraus schwierigkeiten ergeben.

schwatter

#8
So ich habe es soweit abgearbeitet.

Der erste Fehler kommt ab

sudo pacmd set-sink-volume 0 65535

Ausgabe

pi@raspi3-fhem:~ $ systemctl status pulseaudio
● pulseaudio.service - PulseAudio Sound System
   Loaded: loaded (/etc/systemd/system/pulseaudio.service; enabled)
   Active: active (running) since Thu 2018-01-25 19:14:26 CET; 5s ago
Main PID: 1159 (pulseaudio)
   CGroup: /system.slice/pulseaudio.service
           └─1159 /usr/bin/pulseaudio
pi@raspi3-fhem:~ $ sudo pacmd set-sink-volume 0 65535
No PulseAudio daemon running, or not running as session daemon.
pi@raspi3-fhem:~ $


Eingeloggt bin ich als User Pi

Außerdem scheinen 2 Einträge veraltet zu seien?

bluetooth-agent 0000 &

Ergibt
pi@raspi3-fhem:~ $  bluetooth-agent 0000
-bash: bluetooth-agent: command not found


Außerdem
/etc/init.d/alsasound restart

Suche ich in dem Verzeichnis, habe ich nur

/etc/init.d/alsa-utils


edit:
Ich habe gelesen, das blueman zu Konflikten führen kann. Diesen habe ich mir durch abkopieren eingefangen. Diesen habe ich nun entfernt.

edit2:


pi@raspi3-fhem:~ $ sudo apt-get install bluez-alsa
Reading package lists... Done
Building dependency tree
Reading state information... Done
Package bluez-alsa is not available, but is referred to by another package.
This may mean that the package is missing, has been obsoleted, or
is only available from another source

E: Package 'bluez-alsa' has no installation candidate
pi@raspi3-fhem:~ $



Das bekomme ich mit pulseaudio -vvvv

W: [pulseaudio] server-lookup.c: Unable to contact D-Bus: org.freedesktop.DBus.Error.NotSupported: Unable to autolaunch a dbus-daemon without a $DISPLAY for X11
I: [pulseaudio] main.c: Daemon startup complete.





Wernieman

Das liegt an dem DBus gedööns, was Du in der ersten Anleitung gemacht hast.
- Bitte um Input für Output
- When there is a Shell, there is a Way
- Wann war Dein letztes Backup?

Wie man Fragen stellt: https://tty1.net/smart-questions_de.html

schwatter

@Wernieman

ja genau.

@mumpitzstuff

Kann es sein, das dein bluetoothpaket bluez4-... heißt?
Welche Version hast du von Pulseaudio?
Besteht die Möglichkeit, das du dein BluetoothSetup gegen Updates gesichert hast?

mumpitzstuff

Also ich habs genauso gemacht wie in der Anleitung.

Das ist meine bluez Version:  Version: 5.23-2+rpi2
Pulseaudio ist bei mir in der Version 5 installiert.
Ich habe nichts irgendwie gesichert.

schwatter

Mh ok, alles wie bei mir.
Dann weiß ich auch nicht weiter  :-\

mumpitzstuff

#13
Lass dich nicht von dem einen Fehler bei Volume setzen beirren. Mach mal einfach die Schritte weiter bis zum Schluss. Den Fehler mit dem pulseaudio have ich auch wenn ich das so versuche wie du aufzurufen. Das klappt bei mir auch nur wenn es als daemon beim Startup geladen wird.

Das ganze alsa Zeugs steht nicht in meiner Anleitung. Da bringst du grad was durcheinander. Schließ einfach die bluetootheinrichtung wie beschrieben ab (Punkte 12 und 13) und dann geht das bestimmt auch.

schwatter

#14
Hatte ich schon abgearbeitet. Funktioniert noch nicht.

Wenn ich

pactl list sinks short

eingebe. Dann müsste da doch ein 2ter Device mit Kennung bluez.... auftauchen?

Ich habe das Gefühl, das die Module module-bluetooth-policy und module-bluetooth-discover nicht geladen werden.
Denn, Pulseaudio läuft und gibt den Ton an meine 3,5mm Klinke weiter.

pi@raspi3-fhem:~ $ aplay -L
default
    Playback/recording through the PulseAudio sound server
null
    Discard all samples (playback) or generate zero samples (capture)
pulse
    PulseAudio Sound Server
bluetooth
sysdefault:CARD=ALSA
    bcm2835 ALSA, bcm2835 ALSA
    Default Audio Device
front:CARD=ALSA
    bcm2835 ALSA, bcm2835 ALSA
    Default Audio Device
dmix:CARD=ALSA,DEV=0
    bcm2835 ALSA, bcm2835 ALSA
    Direct sample mixing device
dmix:CARD=ALSA,DEV=1
    bcm2835 ALSA, bcm2835 IEC958/HDMI
    Direct sample mixing device
dsnoop:CARD=ALSA,DEV=0
    bcm2835 ALSA, bcm2835 ALSA
    Direct sample snooping device
dsnoop:CARD=ALSA,DEV=1
    bcm2835 ALSA, bcm2835 IEC958/HDMI
    Direct sample snooping device
hw:CARD=ALSA,DEV=0
    bcm2835 ALSA, bcm2835 ALSA
    Direct hardware device without any conversions
hw:CARD=ALSA,DEV=1
    bcm2835 ALSA, bcm2835 IEC958/HDMI
    Direct hardware device without any conversions
plughw:CARD=ALSA,DEV=0
    bcm2835 ALSA, bcm2835 ALSA
    Hardware device with all software conversions
plughw:CARD=ALSA,DEV=1
    bcm2835 ALSA, bcm2835 IEC958/HDMI
    Hardware device with all software conversions


Welches Setting ist hier notwendig? Auto? Oder ist es egal, da der Ton normal immer an Bluetooth geroutet wird und an das 2te Device?

sudo amixer cset numid=3 X



Als User Pi bekomme ich das

pi@raspi3-fhem:~ $ systemctl -l status pulseaudio.service
● pulseaudio.service - PulseAudio Sound System
   Loaded: loaded (/etc/systemd/system/pulseaudio.service; enabled)
   Active: active (running) since Fri 2018-01-26 19:57:27 CET; 55s ago
Main PID: 460 (pulseaudio)
   CGroup: /system.slice/pulseaudio.service
           └─460 /usr/bin/pulseaudio



Als User Root das

root@raspi3-fhem:~# systemctl -l status pulseaudio.service
● pulseaudio.service - PulseAudio Sound System
   Loaded: loaded (/etc/systemd/system/pulseaudio.service; enabled)
   Active: active (running) since Fri 2018-01-26 19:57:27 CET; 12min ago
Main PID: 460 (pulseaudio)
   CGroup: /system.slice/pulseaudio.service
           └─460 /usr/bin/pulseaudio

Jan 26 19:57:26 raspi3-fhem pulseaudio[460]: N: [pulseaudio] main.c: Running in system mode, forcibly disabling SHM mode!
Jan 26 19:57:26 raspi3-fhem pulseaudio[460]: N: [pulseaudio] main.c: Running in system mode, forcibly disabling exit idle time!
Jan 26 19:57:26 raspi3-fhem pulseaudio[460]: W: [pulseaudio] main.c: OK, so you are running PA in system mode. Please note that you most likely shouldn't be doing that.
Jan 26 19:57:26 raspi3-fhem pulseaudio[460]: W: [pulseaudio] main.c: If you do it nonetheless then it's your own fault if things don't work as expected.
Jan 26 19:57:26 raspi3-fhem pulseaudio[460]: W: [pulseaudio] main.c: Please read http://pulseaudio.org/wiki/WhatIsWrongWithSystemMode for an explanation why system mode is usually a bad idea.
Jan 26 19:57:27 raspi3-fhem pulseaudio[460]: W: [pulseaudio] authkey.c: Failed to open cookie file '/var/run/pulse/.config/pulse/cookie': No such file or directory
Jan 26 19:57:27 raspi3-fhem pulseaudio[460]: W: [pulseaudio] authkey.c: Failed to load authorization key '/var/run/pulse/.config/pulse/cookie': No such file or directory
Jan 26 19:57:27 raspi3-fhem pulseaudio[460]: W: [pulseaudio] authkey.c: Failed to open cookie file '/var/run/pulse/.pulse-cookie': No such file or directory
Jan 26 19:57:27 raspi3-fhem pulseaudio[460]: W: [pulseaudio] authkey.c: Failed to load authorization key '/var/run/pulse/.pulse-cookie': No such file or directory
Jan 26 19:57:27 raspi3-fhem systemd[1]: Started PulseAudio Sound System.
root@raspi3-fhem:~#

mumpitzstuff

Wirf doch bitte mal einfach alle Zweifel über Board und mach bei der Bluetooth Einrichtung weiter. Punkt 12 und 13. Du machst die ganze Zeit an Dingen rum, die vielleicht gar keine Rolle spielen. Wenn Pulseaudio läuft, dann hast du 99,9% geschafft...

schwatter

Aber das hab ich alles durch. Bis zum Ende.
Es funktioniert noch immer nicht. Nun bin
ich auf Fehlersuche.

mumpitzstuff

Klappt denn die Bluetooth Koppelung? Das zeigen die Geräte meist durch eine LED oder eine Ansage an.

schwatter

#18
Ja, macht die Box. Ist auch nicht zu übersehen. Die Box ist eine Divoom Aura Box.
Schalte ich sie an und aus signalisiert sie es per Ton und auch per Lichtmuster auf dem Display
das sie connected und disconnected.
Als Test, mache ich ein sudo shutdown -r now auf meinem Raspi, ist die Box disconnected und
das Display zeigt blinkend ein Bluetoothsymbol an. Nach dem der Raspi neu gestartet ist, erlischt
das Symbol und die Box geht zur normalen eingestellten Animation über.

pi@raspi3-fhem:~ $ bluetoothctl
[NEW] Controller B8:27:EB:CA:88:44 RaspStream [default]
[NEW] Device 11:75:58:6D:02:93 AuraBox-light
[bluetooth]# info 11:75:58:6D:02:93
Device 11:75:58:6D:02:93
        Name: AuraBox-light
        Alias: AuraBox-light
        Class: 0x240404
        Icon: audio-card
        Paired: yes
        Trusted: yes
        Blocked: no
        Connected: yes
        LegacyPairing: no
        UUID: Serial Port               (00001101-0000-1000-8000-00805f9b34fb)
        UUID: Audio Sink                (0000110b-0000-1000-8000-00805f9b34fb)
        UUID: A/V Remote Control Target (0000110c-0000-1000-8000-00805f9b34fb)
        UUID: A/V Remote Control        (0000110e-0000-1000-8000-00805f9b34fb)
        UUID: Handsfree                 (0000111e-0000-1000-8000-00805f9b34fb)
        UUID: Generic Access Profile    (00001800-0000-1000-8000-00805f9b34fb)
        UUID: Device Information        (0000180a-0000-1000-8000-00805f9b34fb)
        UUID: Vendor specific           (49535343-fe7d-4ae5-8fa9-9fafd205e455)
[bluetooth]#


[bluetooth]# show B8:27:EB:CA:88:44
Controller B8:27:EB:CA:88:44
        Name: raspi3-fhem
        Alias: RaspStream
        Class: 0x00041c
        Powered: yes
        Discoverable: no
        Pairable: yes
        UUID: PnP Information           (00001200-0000-1000-8000-00805f9b34fb)
        UUID: Generic Access Profile    (00001800-0000-1000-8000-00805f9b34fb)
        UUID: Generic Attribute Profile (00001801-0000-1000-8000-00805f9b34fb)
        UUID: A/V Remote Control        (0000110e-0000-1000-8000-00805f9b34fb)
        UUID: A/V Remote Control Target (0000110c-0000-1000-8000-00805f9b34fb)
        Modalias: usb:v1D6Bp0246d0517
        Discovering: no



Kommt vielleicht Inkompatibilität oder von mir eine schlechte Konfiguration in Frage. Ich habe
so gut wie jeden Tip im Internet probiert,vielleicht wirken sich Reste irgendwie noch negativ aus.

mumpitzstuff

Was genau passiert denn wenn du versuchst etwas abzuspielen?

mplayer -ao pulse http://stream01.iloveradio.de/iloveradio1.mp3

schwatter

Der Player öffnet sich normal und spielt ab. Aus der Bluetoothbox kommt kein Ton.
Stecke ich noch im Betrieb die Klinke rein, kommt aus den normalen Kabellautsprechern der Ton.

schwatter

Gerade folgendes festgestellt. Nachdem der Pi gestartet ist, egal ob als user root oder pi, kann ich die zwei Befehle absetzen.

pactl load-module module-bluetooth-policy
pactl load-module module-bluetooth-discover


Das dürfte nicht sein, das sie ja laut Config geladen werden sollen.

mumpitzstuff

Poste mal den Inhalt der Datei, wo die beiden Module geladen werden sollen. Guck außerdem ob in deinen Logfiles irgendwas zu finden ist. Ich kann mich dunkel erinnern, dass ich damals ein bestimmtes Modul nicht laden durfte, da das ansonsten blockiert hat.

schwatter

Im Moment nervt mich das so sehr, das ich mich umgeschaut habe.

Raspian Stretch bietet was ganz tolles an. Nennt sich BlueAlsa.
Ich versuche mal ein make oder steige vielleicht auf Stretch um.

https://github.com/Arkq/bluez-alsa/tree/msbc

https://www.sigmdel.ca/michel/ha/rpi/bluetooth_01_en.html

Leider ist es nicht in der Jessie sources.list.

mumpitzstuff

Jessie hat Pulseaudio. Ist halt Linux und damit Bastelbude sondergleichen.

Wernieman

ZitatIst halt Linux und damit Bastelbude sondergleichen.

Dafür ist auch vieles Möglich .. und Das Problem dürfte nicht Linux, sondern Pulsaudio sein ...

Kannst Du überhaupt, ohne Pulsaudio, den Lautsprecher verwenden?

Gucke mal nach: https://wiki.ubuntuusers.de/Bluetooth/Einrichtung/

Btw:
Bevor Du Dir etwas reinkompilierst, versuche es mal mit Standart-Applikationen. Es gibt nicht nur pulseaudio!
- Bitte um Input für Output
- When there is a Shell, there is a Way
- Wann war Dein letztes Backup?

Wie man Fragen stellt: https://tty1.net/smart-questions_de.html

schwatter

@Wernieman

Ich bin die Tips durchgegangen. Ist soweit alles ok bei mir. Hast du einen Namen für eine Pulseaudioalternative griffbereit?
Selbst in deinem Link ganz unten wird mal wieder auf Pulseaudio verwiesen.

Soweit ich das überblicken kann sind hier 2 Komponenten das Problem. Einmal ganz klar Pulseaudio
und zum 2ten bluez5. Da laut vielen Aussagen ab Version 5 die Vermittlung zischen Bluetooth und Audio auf
3rd Partyprogramme ausgelagert wurde.

Zitat
This project is a rebirth of a direct integration between Bluez and ALSA. Since Bluez >= 5, the build-in integration has been removed in favor of 3rd party audio applications. From now on, Bluez acts as a middleware between an audio application, which implements Bluetooth audio profile, and a Bluetooth audio device.

Quelle:
https://github.com/Arkq/bluez-alsa/tree/msbc

Auf einer 2ten SD-Card hab ich jetzt Stretch am Laufen. Fhem läuft auf anhieb super. Nur meine MQTT-Device muss ich nochmal bekanntmanchen oder neu einbinden.
Bei Zeit versuch ich mich da mit Bluetooth.

Wernieman

Speziell bei Blue gilt: Neuere Distri hat meistens (nicht immer) eine bessere Implementierung.

Kann Dir jetzt nicht sooo viele Tips geben, da ich im Audiobereich nicht soo unterwegs bin. Hatte vor ?5? Jahren mal mit Alternativen gespielt ... und wie ich festellen musste, wieder vergessen :o(

Sorry Dir da nicht viele Hilfestellungen geben zu können. Hatte mich deshalb hier auch schon etwas ausgeklingt ....
- Bitte um Input für Output
- When there is a Shell, there is a Way
- Wann war Dein letztes Backup?

Wie man Fragen stellt: https://tty1.net/smart-questions_de.html

schwatter

#28
ok, kein Problem.

Sooooo, das ersteMal Audio aus meinem Speaker  :) Und zwar unter Stretch.
Die Einrichtung ist wirklich sehr leicht mit BlueALSA. Erst konnte ich schon Wavefiles abspielen. Dann versuchte ich eine MP3 mit mpg321, leider nur Rauschen.
Zuletzt habe ich mplayer installiert. Damit klappte auch mplayer http://stream01.iloveradio.de/iloveradio1.mp3.
Jetzt funktioniert sogar mpg321 mit MP3. Ich denke, das mplayer noch dependencies mit installiert hat.

Außerdem, mein Homematic, IT, CUL_TX läuft out of the Box. Ich musste nur für MQTT ein cpan -i Net::MQTT::Message ausführen.

Wernieman

- Bitte um Input für Output
- When there is a Shell, there is a Way
- Wann war Dein letztes Backup?

Wie man Fragen stellt: https://tty1.net/smart-questions_de.html

schwatter

In meinem Fall ja. Da Stretch BlueALSA als Pakete bereitstellt.
Sehr einfach einzurichten.

schwatter

Problem:
- Audio nur als User pi. Root und fhem haben keinen Sound.

Warum?
- Die Config /etc/asound.conf ist nicht vorhanden. Diese setzt Audiosettings Systemwide.


Lösung:
- User root und fhem zur group audio hinzufügen
- Config /etc/asound.conf anlegen und mit folgenden Inhalt


pcm.!default {
        type plug
        slave.pcm {
                type bluealsa
                device "00:00:00:00:00:00"   #<- hier passende Mac des Speakers eintragen
                profile "a2dp"
        }
}





schwatter

Problem:
- Jetzt unter Stretch bekomme ich mit BlueAlsa nach einem Reboot kein Autoconnect bei meinem Bluetoothspeaker.

Lösung:
- Ich habe einfach folgendes in die /etc/rc.local gepackt.

#!/bin/bash
#
# rc.local
#
# This script is executed at the end of each multiuser runlevel.
# Make sure that the script will "exit 0" on success or any other
# value on error.
#
# In order to enable or disable this script just change the execution
# bits.
#
# By default this script does nothing.
#
echo -e "connect 11:75:58:6D:02:93" | bluetoothctl
sleep 5
amixer -D bluealsa sset 'AuraBox-audio - A2DP' 80%
sleep 1
amixer -D bluealsa sset 'AuraBox-audio - SCO' 80%
exit 0


Wichtig hier, die erste Zeile muss wie oben angepasst werden, damit die Datei auch ausgeführt wird.
Aus "#!/bin/sh -e" wird "#!/bin/bash". Außerdem die Mac anpassen unter "echo -e.......".
Um Zugriffsproblemen aus dem Weg zu gehen, habe ich der Datei noch ein

chmod +x  /etc/rc.local

verpasst. Damit hat dann jeder User Zugriff und darf darauf zugreifen.

schwatter

So, auch die letzte Hürde ist geschafft.

Damit Autoconnect beim Start/Restart funktioniert, muss bluealsa.service angepasst werden.

sudo systemctl disable bluealsa
sudo nano /lib/systemd/system/bluealsa.service


Dann

WantedBy=graphic.target

ändern zu

WantedBy=multi-user.target

Als Abschluss

sudo systemctl enable bluealsa

Warum das bis jetzt in der RaspianLite noch nicht angepasst wurde ist mir ein Rätsel.


edit:

Erst funktionierte es,....jetzt wieder nicht :-P