Webradio über Bluetooth auf Raspi

Begonnen von call_me_driver, 22 Juli 2018, 15:13:37

Vorheriges Thema - Nächstes Thema

call_me_driver

Hey,

ich hatte mir vor einiger Zeit schon ein kleines - sehr einfaches - Webradio eingerichtet.

define Webradio MPD

Hab dort eine Playlist hinterlegt mit dem entsprechenden Sender. Funktioniert und gibt mir den Sound auf meine Boxen aus (über den normalen Kopfhöhrerausgang)

Jetzt würde ich gerne des ganze via Bluetooth machen. Meinen Bluetooth-Lautsprecher konnt ich schon verbinden.
Ich kann auch schon auf dem Raspi direkt Musik abspielen (mit der alten Playlist)

mplayer -ao alsa -playlist /var/lib/mpd/playlists/WebStreams.txt

Aber ich bekomms nicht hin, dass der MPD über bluetooth geht. Hab versucht mit Streamradio - des wohl auf dem mplayer basiert (??) - aber da kommt gar kein sound.
https://wiki.fhem.de/wiki/Modul_StreamRadio_Einrichtungshilfe

Hatte iwer schon hier erfolg? Wie kann ich den mplayer in fhem ansteuern?

thx


schwatter

#1
Tag,

hier bei mir solltest du alle Infos finden.
Speziell Beitrag #31 sollte helfen.

https://forum.fhem.de/index.php/topic,83226.0.html

edit:

Auch toll in Verbindung mit MPD, kann ich dir noch upmpdcli empfehlen.
https://www.lesbonscomptes.com/upmpdcli/downloads.html

call_me_driver

hm hm.... des sieht schon gut aus. des connecten hab ich ja geschafft.
und  hab mittlerweile auch gemerkt - die ausgabe geht nur als pi-user.

root geht nicht (und fhem vermutlich auch nicht).

fehlermeldung (root):
[AO_ALSA] alsa-lib: dlmisc.c:254:(snd1_dlobj_cache_get) Cannot open shared library /usr/lib/arm-linux-gnueabihf/alsa-lib/libasound_module_pcm_bluealsa.so

die datei is auch wirklich nicht da, aber beim pi-user gehts ja.
hattest du sowas auch?

schwatter

Probier bitte das


user@debian:~# sudo addgroup fhem dialout
user@debian:~# sudo addgroup fhem mail
user@debian:~# sudo addgroup fhem audio
user@debian:~# sudo addgroup fhem sudo


und das


user@debian:~# sudo visudo


Dort fügst du das ein:

fhem    ALL=NOPASSWD: ALL

call_me_driver

hatte ich bereits alles... daher... keine änderung... leider

schwatter

Groups von mir:

root@raspiFhem:~# groups mpd
mpd : audio


Hast du bluealsa installiert?

apt-get install bluealsa

call_me_driver

#6
installiert wars, aber wohl etwas älter? oder defekt.... jedenfalls bringt er jetzt ne andere fehlermeldung

[AO_ALSA] alsa-lib: bluealsa-pcm.c:679:(_snd_pcm_bluealsa_open) Couldn't get BlueALSA transport: No such device
[AO_ALSA] Playback open error: No such device
Failed to initialize audio driver 'alsa'


schwatter

#7
wie schaut deine /etc/dbus-1/system.d/bluetooth.conf aus?

<!-- This configuration file specifies the required security policies
     for Bluetooth core daemon to work. -->

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

  <!-- ../system.conf have denied everything, so we just punch some holes -->

  <policy user="root">
    <allow own="org.bluez"/>
    <allow send_destination="org.bluez"/>
    <allow send_interface="org.bluez.Agent1"/>
    <allow send_interface="org.bluez.MediaEndpoint1"/>
    <allow send_interface="org.bluez.MediaPlayer1"/>
    <allow send_interface="org.bluez.ThermometerWatcher1"/>
    <allow send_interface="org.bluez.AlertAgent1"/>
    <allow send_interface="org.bluez.Profile1"/>
    <allow send_interface="org.bluez.HeartRateWatcher1"/>
    <allow send_interface="org.bluez.CyclingSpeedWatcher1"/>
    <allow send_interface="org.bluez.GattCharacteristic1"/>
    <allow send_interface="org.bluez.GattDescriptor1"/>
    <allow send_interface="org.freedesktop.DBus.ObjectManager"/>
    <allow send_interface="org.freedesktop.DBus.Properties"/>
  </policy>

  <!-- allow users of bluetooth group to communicate -->
  <policy group="bluetooth">
    <allow send_destination="org.bluez"/>
  </policy>

  <policy at_console="true">
    <allow send_destination="org.bluez"/>
  </policy>

  <!-- allow users of lp group (printing subsystem) to


Außerdem ist Pulseaudio noch ein Fehlerfaktor. Lieber deinstallieren.

edit:

Sehe gerade, bluealsa läuft bei mir per root


root@raspiFhem:~# ps auxw | grep bluealsa
root       443  0.0  0.5  62684  5156 ?        Ssl  Jul20   3:18 /usr/bin/bluealsa
root     14156  0.0  0.0   4776   576 pts/0    S+   18:24   0:00 grep bluealsa
root@raspiFhem:~#


Und hier ein Auszug von https://github.com/Arkq/bluez-alsa


Configuration & Usage
The main component of the BlueALSA is a program called bluealsa. It should be run as a root during system startup (root privileges are not required per se, the only requirement is a write access to /var/run/bluealsa). This program acts as a proxy between Bluez and ALSA.

In order to stream audio to the e.g. Bluetooth headset, firstly one has to connect the device. The most straightforward method is to use Bluez CLI utility called bluetoothctl. When the device is connected one can use the bluealsa virtual PCM device as follows:

$ aplay -D bluealsa:HCI=hci0,DEV=XX:XX:XX:XX:XX:XX,PROFILE=a2dp Bourree_in_E_minor.wav
Setup parameters of the bluealsa PCM device can be set in the local .asoundrc configuration file like this:

$ cat ~/.asoundrc
defaults.bluealsa.interface "hci0"
defaults.bluealsa.device "XX:XX:XX:XX:XX:XX"
defaults.bluealsa.profile "a2dp"
defaults.bluealsa.delay 10000
BlueALSA also allows to capture audio from the connected Bluetooth device. To do so, one has to use the capture PCM device, e.g.:

$ arecord -D bluealsa capture.wav
Using this feature, it is possible to create Bluetooth-powered speaker. It is required to forward audio signal from the BlueALSA capture PCM to some other playback PCM (e.g. build-id audio card). In order to simplify this task, there is a program called bluealsa-aplay, which acts as a simple BlueALSA player. Connect your Bluetooth device (e.g. smartphone) and do as follows:

$ bluealsa-aplay XX:XX:XX:XX:XX:XX
In order to control input or output audio level, one can use provided bluealsa control plugin. This plugin allows adjusting the volume of the audio stream or simply mute/unmute it, e.g.:

$ amixer -D bluealsa sset '<control name>' 70%
where the control name is the name of a connected Bluetooth device with a control element suffix, e.g.:

$ amixer -D bluealsa sset 'Jabra MOVE v2.3.0 - A2DP' 50%
For more advanced ALSA configuration, consult the asoundrc on-line documentation provided by the AlsaProject wiki page.

mumpitzstuff

Ich habe das Ganze auf einem Standard Debian (kein Raspbian) vor ein paar Tagen mit Pulseaudio eingerichtet. Wenn du es mit bluealsa nicht hinbekommst, dann kann ich noch mal versuchen die Steps zu rekapitulieren.

Wenn die Ausgabe bei dir nur für einen bestimmten User funktioniert, dann liegt das daran, das der entsprechende Service mit den Rechten des Users läuft. Andere User können dann nicht mehr darauf zugreifen. Deshalb muss man das so einrichten, das alle User darauf zugreifen können. Bei mir läuft Pulseaudio unter dem User pulse und fhem wurde der entsprechenden Gruppe hinzugefügt, um darauf zugreifen zu können.

call_me_driver

ok... also pulseaudio hab ich deinstalliert - und plötzlich is die qualität super. davor wars als wenn der stream langsam wäre. des is etz immerhin schon mal n pluspunkt.

ansonsten.. hab die asound.conf für root (homevz) angelegt... allerdings leider keine änderung... pi spielt, root (und vermutlich auch fhem user) nicht.

pi.
Opening audio decoder: [mpg123] MPEG 1.0/2.0/2.5 layers I, II, III
AUDIO: 44100 Hz, 2 ch, s16le, 56.0 kbit/3.97% (ratio: 7000->176400)
Selected audio codec: [mpg123] afm: mpg123 (MPEG 1.0/2.0/2.5 layers I, II, III)
==========================================================================
AO: [pulse] Init failed: Connection refused
Failed to initialize audio driver 'pulse'
AO: [alsa] 48000Hz 2ch s16le (2 bytes per sample)
Video: no video
Starting playback...
A:   2.4 (02.4) of 0.0 (unknown)  3.9% 17%


root:
Opening audio decoder: [mpg123] MPEG 1.0/2.0/2.5 layers I, II, III
AUDIO: 44100 Hz, 2 ch, s16le, 56.0 kbit/3.97% (ratio: 7000->176400)
Selected audio codec: [mpg123] afm: mpg123 (MPEG 1.0/2.0/2.5 layers I, II, III)
==========================================================================
AO: [pulse] Init failed: Connection refused
Failed to initialize audio driver 'pulse'
[AO_ALSA] alsa-lib: conf.c:1182:(parse_value) delay is not a string
[AO_ALSA] alsa-lib: conf.c:1852:(snd_config_load1) _toplevel_:5:0:Invalid argument
[AO_ALSA] alsa-lib: conf.c:3615:(config_file_open) /root/.asoundrc may be old or corrupted: consider to r                                   emove or fix it
[AO_ALSA] alsa-lib: conf.c:3537:(snd_config_hooks_call) function snd_config_hook_load returned error: Inv                                   alid argument
[AO_ALSA] alsa-lib: conf.c:3986:(snd_config_update_r) hooks failed, removing configuration
[AO_ALSA] Playback open error: Invalid argument
Failed to initialize audio driver 'alsa'
[AO SDL] Samplerate: 44100Hz Channels: Stereo Format s16le
[AO SDL] using aalib audio driver.
[AO SDL] Unable to open audio: No available audio device
Failed to initialize audio driver 'sdl:aalib'
Could not open/initialize audio device -> no sound.


call_me_driver

#10
Ha ! die .asoundrc war falsch (veraltet). ich hatte unter /etc eine asound.conf (war irgendwo ne anleitung für), die hab ich ins home von root kopiert..... läuft jetzt auch für root.

jetzt hab ich die datei auch ins home vom fhem-user kopiert /opt/fhem...

jetzt muss ich nur noch guggen  wie des streamradio läuft. momentan tuts nämlich noch nix.


EDIT: geht... allerdings nur wenn ich den stream direkt angebe... also "set play http://br-br1-franken.cast.addradio.de/br/br1/franken/mp3/56/stream.mp3"
mal guggen ob ich des elegant hinbekomm mit ner auswahl an streams...

aber schonmal danke für die hilfe...

mumpitzstuff

Poste doch falls möglich die Config Datei mal. Vielleicht hilft es ja irgendwann noch mal jemanden.

call_me_driver

gerne: asound.conf

pcm.!default {
        type plug
        slave {
                pcm {
                        type bluealsa
                        device XX:XX:XX:XX:XX:XX
                        profile "a2dp"
                }
        }
        hint {
                show on
                description "A description of the device"
        }
}
ctl.!default {
        type bluealsa
}


bräucht ggf. noch bissl hilfe. wenn ich über die fhem-oberfläche den stream einstelle spielt er.
aber über tablet-ui bekomm ichs nicht hin

<div data-type="select"
   data-device="SRadio"
   data-set="StreamURL"
   data-get="StreamURL"
   data-items='["http://br-br1-franken.cast.addradio.de/br/br1/franken/mp3/56/stream.mp3","sunshine","energy"]'
   data-alias='["Bayern 1","Sunshine Live","Energy"]'
   class="wr_liste w3x left">
</div>


mumpitzstuff

Im Wiki von StreamRadio steht das hier (vermutlich meinst du das Modul?!?):

<div data-type="select" data-device="streamradio" data-list="STREAMS" data-get="STREAM" data-set="STREAM" class="cell w3x select"></div>

Ich habe aber keine Ahnung von TabletUI. Die Frage stellst du vielleicht im richtigen Unterforum noch einmal.