hzeller / gmrender-resurrect

Resource efficient UPnP/DLNA renderer, optimal for Raspberry Pi, CuBox or a general MediaServer. Fork of GMediaRenderer to add some features to make it usable.
GNU General Public License v2.0
832 stars 202 forks source link

GMrender: no sound output #205

Open gaeldoyen opened 4 years ago

gaeldoyen commented 4 years ago

Hi there,

I've been facing a strange issue with my audio setup. My music is stored on a NAS and played through the Audirvana app on my PC, which uses an RPi 4 as a bridge to stream audio to my DAC (Teac UD-503). When I connect the PC to the DAC, everything works perfectly. When I use RoPieeeXL on the RPi, everything works well as well, but it doesn't support DSD. Due to that limitation, I would like to run DietPi on the RPi but I couldn't get any sound out of it with GMrender (although the DAC is correctly detected and configured).

After further investigation, DietPi doesn't seem to be the culprit. Please see the issue and troubleshooting with @MichaIng here: https://github.com/MichaIng/DietPi/issues/3348

The following error messages might be the answer to the problem:

janv. 22 00:32:24 DietPi gmediarender[745]: ERROR [2020-01-22 00:32:24.252240 | gstreamer] sink: Error: Could not open audio device for playback. (Debug: gstalsasink.c(865): gst_alsasink_open (): /GstAlsaSink:sink: janv. 22 00:32:24 DietPi gmediarender[745]: Playback open error on device 'sysdefault': No such file or directory) janv. 22 00:32:24 DietPi gmediarender[745]: ERROR [2020-01-22 00:32:24.252310 | gstreamer] setting play state failed (2) janv. 22 00:32:24 DietPi gmediarender[745]: ERROR [2020-01-22 00:32:24.252358 | upnp] upnp_set_error: Playing failed

Does someone have any idea about what is wrong???

Thanks a lot in advance!

MichaIng commented 4 years ago

Little addition: https://github.com/MichaIng/DietPi/issues/3348#issuecomment-577945338

ctl.!default { type hw card 1 }


- The exact same setup worked fine for other users on other RPi models when testing the own build gmediarender binary that time. I sadly have no RPi4 to test.
_______
Since there was a new kernel release few days ago, @kikigarel could you verify you updated already or do it now? `apt update && apt full-upgrade`
mill1000 commented 4 years ago

This looks like it's not an issue with gmrender-resurrect but the underlying Gstreamer or ALSA libs.

Try using gst-play to play a file from the terminal like so:

 gst-play-1.0 test_file.mp3

gst-play is located in the gstreamer1.0-plugins-base-apps package so you may need to run

apt-get install gstreamer1.0-plugins-base-apps
MichaIng commented 4 years ago

gstreamer1.0-plugins-base is installed, gstreamer1.0-plugins-base-apps still needs to be. Good idea to test gstreamer independently.

gaeldoyen commented 4 years ago

Little addition: MichaIng/DietPi#3348 (comment)

  • We tried different binaries, own build based on current upstream version and current version from Raspbian Buster repo.
  • We tried running it as root, hence ruled out permission issues.
  • We verified correct asound.conf entry which works fine for local audio playback through the USB DAC:
pcm.!default {
  type hw
  card 1
  device 0
}

ctl.!default {
  type hw
  card 1
}
  • The exact same setup worked fine for other users on other RPi models when testing the own build gmediarender binary that time. I sadly have no RPi4 to test.

Since there was a new kernel release few days ago, @kikigarel could you verify you updated already or do it now? apt update && apt full-upgrade

Hi @MichaIng,

I have updated but it made no difference :-(

gaeldoyen commented 4 years ago

This looks like it's not an issue with gmrender-resurrect but the underlying Gstreamer or ALSA libs.

Try using gst-play to play a file from the terminal like so:

 gst-play-1.0 test_file.mp3

gst-play is located in the gstreamer1.0-plugins-base-apps package so you may need to run

apt-get install gstreamer1.0-plugins-base-apps

@mill1000,

Thanks for the feedback. I have run apt-get install gstreamer1.0-plugins-base-apps and then _gst-play-1.0 testfile.mp3 but I get a error messages. Please see below:

root@DietPi:~# apt-get install gstreamer1.0-plugins-base-apps Reading package lists... Done Building dependency tree Reading state information... Done The following package was automatically installed and is no longer required: libllvm8 Use 'apt autoremove' to remove it. The following additional packages will be installed: gstreamer1.0-tools The following NEW packages will be installed: gstreamer1.0-plugins-base-apps gstreamer1.0-tools 0 upgraded, 2 newly installed, 0 to remove and 0 not upgraded. Need to get 2,345 kB of archives. After this operation, 2,524 kB of additional disk space will be used. Do you want to continue? [Y/n] Y Get:1 http://ftp.igh.cnrs.fr/pub/os/linux/raspbian/raspbian buster/main armhf gstreamer1.0-tools armhf 1.14.4-1 [1,109 kB] Get:2 http://ftp.igh.cnrs.fr/pub/os/linux/raspbian/raspbian buster/main armhf gstreamer1.0-plugins-base-apps armhf 1.14.4-2 [1,236 kB] Fetched 2,345 kB in 1s (1,585 kB/s) Selecting previously unselected package gstreamer1.0-tools. (Reading database ... 28580 files and directories currently installed.) Preparing to unpack .../gstreamer1.0-tools_1.14.4-1_armhf.deb ... Unpacking gstreamer1.0-tools (1.14.4-1) ... Selecting previously unselected package gstreamer1.0-plugins-base-apps. Preparing to unpack .../gstreamer1.0-plugins-base-apps_1.14.4-2_armhf.deb ... Unpacking gstreamer1.0-plugins-base-apps (1.14.4-2) ... Setting up gstreamer1.0-tools (1.14.4-1) ... Setting up gstreamer1.0-plugins-base-apps (1.14.4-2) ... root@DietPi:~# gst-play-1.0 test_file.mp3 Press 'k' to see a list of keyboard shortcuts. Now playing /root/test_file.mp3 ERROR Resource not found. for file:///root/test_file.mp3 ERROR debug information: gstfilesrc.c(533): gst_file_src_start (): /GstPlayBin:playbin/GstURIDecodeBin:uridecodebin0/GstFileSrc:source: No such file "/root/test_file.mp3" Reached end of play list.

MichaIng commented 4 years ago

@kikigarel But the file definitely exist? The suggested command was just an example, of course it should be the path/filename of an mp3 file that really exists on our Pi.

gaeldoyen commented 4 years ago

@mill1000 @MichaIng ,

Silly me ;-) So, I have managed to play the music file I had copied onto the SDcard. At last I got some sound :-)

MichaIng commented 4 years ago

@kikigarel Great, so bare gstreamer works so far. Now lets test to apply the settings that our gmediarender systemd unit applies:

gst-play-1.0 --audiosink='alsasink device=sysdefault' --volume=-1 /path/to/test.mp3
# If the above fails, lets see which option is the culprit:
gst-play-1.0 --audiosink=alsasink --volume=-1 /path/to/test.mp3
gst-play-1.0 --volume=-1 /path/to/test.mp3
gst-play-1.0 --audiosink='alsasink device=sysdefault' /path/to/test.mp3
gaeldoyen commented 4 years ago

@kikigarel Great, so bare gstreamer works so far. Now lets test to apply the settings that our gmediarender systemd unit applies:

gst-play-1.0 --audiosink='alsasink device=sysdefault' --volume=-1 /path/to/test.mp3
# If the above fails, lets see which option is the culprit:
gst-play-1.0 --audiosink=alsasink --volume=-1 /path/to/test.mp3
gst-play-1.0 --volume=-1 /path/to/test.mp3
gst-play-1.0 --audiosink='alsasink device=sysdefault' /path/to/test.mp3
  • I hope the syntax to apply audiosink + device is correct, couldn't find it in official docs, just through search machine 😉.

So... Command #1 did not work. However, commands #2 and #3 worked and music played. Command #4 didn't work and I got this error message:

root@DietPi:~# gst-play-1.0 --audiosink='alsasink device=sysdefault' /boot/dek247.mp3 Press 'k' to see a list of keyboard shortcuts. Now playing /boot/dek247.mp3 ERROR Could not open audio device for playback. for file:///boot/dek247.mp3 ERROR debug information: gstalsasink.c(865): gst_alsasink_open (): /GstBin:bin0/GstAlsaSink:alsasink0: Playback open error on device 'sysdefault': No such file or directory Reached end of play list.

MichaIng commented 4 years ago

@kikigarel Okay there we have the exact matching error message that we saw on gmediarender. Strange since sysdefault is a pre-defined audio device which should always be available, AFAIK. Could you please paste:

grep sysdefault /usr/share/alsa/alsa.conf
gaeldoyen commented 4 years ago

@MichaIng there you go:

root@DietPi:~# grep sysdefault /usr/share/alsa/alsa.conf pcm.sysdefault cards.pcm.default ctl.sysdefault { ctl.default ctl.sysdefault

MichaIng commented 4 years ago

@kikigarel Ah, more important actually is: aplay -L

And does the following work:

gst-play-1.0 --audiosink='alsasink device=hw:1,0' --volume=-1 /path/to/test.mp3

Probably sysdefault points to hw:0,0 (card 0 device 0, RPi onboard), which is disabled on DietPi when selecting a USB DAC as sound card. From other tests I related that sysdefault points to the card + device that is defined via pcm.!default in asound.conf. Also we had this option in gmediarender for ages and never received issues with this 🤔.

Not sure if gstreamer follows asound.conf when not setting the device actively, or if it e.g. uses the first available card + device then 🤔.

gaeldoyen commented 4 years ago

Here is what aplay –L returns :

root@DietPi:~# aplay -L null Discard all samples (playback) or generate zero samples (capture) sysdefault:CARD=UD503 UD-503, USB Audio Default Audio Device front:CARD=UD503,DEV=0 UD-503, USB Audio Front speakers surround21:CARD=UD503,DEV=0 UD-503, USB Audio 2.1 Surround output to Front and Subwoofer speakers surround40:CARD=UD503,DEV=0 UD-503, USB Audio 4.0 Surround output to Front and Rear speakers surround41:CARD=UD503,DEV=0 UD-503, USB Audio 4.1 Surround output to Front, Rear and Subwoofer speakers surround50:CARD=UD503,DEV=0 UD-503, USB Audio 5.0 Surround output to Front, Center and Rear speakers surround51:CARD=UD503,DEV=0 UD-503, USB Audio 5.1 Surround output to Front, Center, Rear and Subwoofer speakers surround71:CARD=UD503,DEV=0 UD-503, USB Audio 7.1 Surround output to Front, Center, Side, Rear and Woofer speakers iec958:CARD=UD503,DEV=0 UD-503, USB Audio IEC958 (S/PDIF) Digital Audio Output dmix:CARD=UD503,DEV=0 UD-503, USB Audio Direct sample mixing device dsnoop:CARD=UD503,DEV=0 UD-503, USB Audio Direct sample snooping device hw:CARD=UD503,DEV=0 UD-503, USB Audio Direct hardware device without any conversions plughw:CARD=UD503,DEV=0 UD-503, USB Audio Hardware device with all software conversions root@DietPi:~#

De : MichaIng [mailto:notifications@github.com] Envoyé : dimanche 2 février 2020 19:40 À : hzeller/gmrender-resurrect gmrender-resurrect@noreply.github.com Cc : kikigarel gaeldoyen@hotmail.com; Mention mention@noreply.github.com Objet : Re: [hzeller/gmrender-resurrect] GMrender: no sound output (#205)

@kikigarelhttps://github.com/kikigarel Ah, more important actually is: aplay -L

And does the following work:

gst-play-1.0 --audiosink='alsasink device=hw:1,0' --volume=-1 /path/to/test.mp3

Probably sysdefault points to hw:0,0 (card 0 device 0, RPi onboard), which is disabled on DietPi when selecting a USB DAC as sound card. From other tests I related that sysdefault points to the card + device that is defined via pcm.!default in asound.conf. Also we had this option in gmediarender for ages and never received issues with this 🤔.

Not sure if gstreamer follows asound.conf when not setting the device actively, or if it e.g. uses the first available card + device then 🤔.

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHubhttps://github.com/hzeller/gmrender-resurrect/issues/205?email_source=notifications&email_token=AOKLKUGKB5YGEEVECNZBO7DRA4HPXA5CNFSM4KMSDS72YY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGOEKR5XKQ#issuecomment-581163946, or unsubscribehttps://github.com/notifications/unsubscribe-auth/AOKLKUAQ6DPDN66HWLAMIMDRA4HPXANCNFSM4KMSDS7Q.

gaeldoyen commented 4 years ago

@MichaIng

And does the following work:

gst-play-1.0 --audiosink='alsasink device=hw:1,0' --volume=-1 /path/to/test.mp3

Yes, the music plays:

root@DietPi:~# gst-play-1.0 --audiosink='alsasink device=hw:1,0' --volume=-1 /boot/dek247.mp3 Press 'k' to see a list of keyboard shortcuts. Now playing /boot/dek247.mp3 Redistribute latency... 0:00:20.0 / 0:02:40.2

MichaIng commented 4 years ago

@kikigarel Okay, so to make your gmediarender work, do the following:

sed -i 's/sysdefault/hw:1,0/' /etc/systemd/system/gmrender.service
systemctl daemon-reload
systemctl restart gmrender

If this indeed works, then we can close the issue here and continue back on DietPi repo, respectively I have to run some tests and see whether we can omit the option or need to set/adjust it based on sound device menu choice/when changing the sound device.

gaeldoyen commented 4 years ago

@MichaIng

It worked! Wow, I'm so happy :-) Thanks for your help throughout!

I have a couple more questions: the volume is set to -1,2db by default, how do you change that to 0db? Also, does DietPi support DSD audio streams?

MichaIng commented 4 years ago

@kikigarel Actually I am not sure why --volume=-1 is set. That part of code was not added by me, I just left it as it was. You can try to change it to --volume=0.

DSD support is a matter of the used audio device and drivers, hence depends on SBC model and used driver/device tree overlay for the audio device, and the latter must support it as well. I am not very experienced with this topic, please read inside this for RPi, e.g.: https://soundcheck-audio.blogspot.com/2018/01/raspberry-pi-audio-engine-part-6-dsd.html As a general rule, since DietPi for RPi is based on Raspbian, any guide for RPi/Raspbian generally works on DietPi as well.