sentriz / gonic

music streaming server / free-software subsonic server API implementation
ircs://irc.libera.chat/#gonic
GNU General Public License v3.0
1.49k stars 105 forks source link

Jukebox not working correctly #495

Closed Butterblume511 closed 1 week ago

Butterblume511 commented 2 months ago

gonic version: 0.16.4

installed with systemd

Hi, I just installed gonic on a Raspberry Pi 5 with a HiFiberry DAC + Pro Hat attached, which is configured as the only Playback Device and was playing fine when I tested it with volumio a few days ago. Playing files remotely with the DSub app from my android smartphone works great. But when I try streaming to "Subsonic Jukebox" no music is being played and journalctl shows: Apr 11 20:11:21 moode2 gonic[2256]: 2024/04/11 20:11:21 response 200 GET /jukeboxControl?u=admin&s=n131ms7mdmhfph14lh4qso620m&t=d9e49b4b579674436e36a193316e9afc&v=1.2.0&c=DSub&action=start Apr 11 20:11:26 moode2 gonic[2256]: 2024/04/11 20:11:26 response 200 GET /jukeboxControl?u=admin&s=n131ms7mdmhfph14lh4qso620m&t=d9e49b4b579674436e36a193316e9afc&v=1.2.0&c=DSub&action=status

with lines 3-4 repeating every 5 seconds. In gonic's config "jukebox-enabled" is "true", but no extra arguments are being passed to mpv as I wouldn't know which.

Could anybody please help me with this? Am I doing something wrong here?

sentriz commented 2 months ago

can you try list the audio devices in the container? maybe docker compose exec gonic mpv --audio-device=help

Butterblume511 commented 2 months ago

oh sorry, I just realized I installed gonic with systemd not with docker. I'm not well versed in linux. But mpv --audio-device=help gives this: 'auto' (Autoselect device) 'pipewire' (Default (pipewire)) 'pipewire/alsa_output.platform-soc_sound.stereo-fallback' (Built-in Audio Stereo) 'pulse/alsa_output.platform-soc_sound.stereo-fallback' (Built-in Audio Stereo) 'alsa' (Default (alsa)) 'alsa/lavrate' (Rate Converter Plugin Using Libav/FFmpeg Library) 'alsa/samplerate' (Rate Converter Plugin Using Samplerate Library) 'alsa/speexrate' (Rate Converter Plugin Using Speex Resampler) 'alsa/jack' (JACK Audio Connection Kit) 'alsa/oss' (Open Sound System) 'alsa/speex' (Plugin using Speex DSP (resample, agc, denoise, echo, dereverb)) 'alsa/upmix' (Plugin for channel upmix (4,6,8)) 'alsa/vdownmix' (Plugin for channel downmix (stereo) with a simple spacialization) 'alsa/plughw:CARD=sndrpihifiberry,DEV=0' (snd_rpi_hifiberry_dacplus, HiFiBerry DAC+ Pro HiFi pcm512x-hifi-0/Hardware device with all software conversions) 'alsa/sysdefault:CARD=sndrpihifiberry' (snd_rpi_hifiberry_dacplus, HiFiBerry DAC+ Pro HiFi pcm512x-hifi-0/Default Audio Dev ice) 'alsa/dmix:CARD=sndrpihifiberry,DEV=0' (snd_rpi_hifiberry_dacplus, HiFiBerry DAC+ Pro HiFi pcm512x-hifi-0/Direct sample mix ing device) 'alsa/usbstream:CARD=sndrpihifiberry' (snd_rpi_hifiberry_dacplus/USB Stream Output) 'jack' (Default (jack)) 'sdl' (Default (sdl))

Butterblume511 commented 2 months ago

Do you have any idea what might cause that?

sentriz commented 2 months ago

are you able to play audio normally from the command line with mpv? is the jukebox volume definitely playing / volume up?

Butterblume511 commented 2 months ago

I just started a file with "mpv folder/filename" and it plays just fine. If I have a file already playing in DSub on my Smartphone and switch to "Subsonic Jukebox", the file stops playing and is set to time 0:00. If no file is playing and I switch to Jukebox the following song in the folder is selected but nothing is being played. It also stays at 0:00. And I just tested it with the Subsonic app which shows the exact same problem.

sentriz commented 2 months ago

hmm do you see anything in the logs like /jukeboxControl ... &action=set ...? that's the one where dsub tells gonic what tracks should be in the jukebox

Butterblume511 commented 2 months ago

I had to realize you meant journalctl... There is an entry with the "set" command before "start" and then "status" every 5 seconds. When the start command is issued for the first time the timer in DSub goes to 0:03 seconds but without sound before returning to 0:00 and issuing the "status" command. Do you know if it works for anyone? Can you test it yourself? And what does the "status" command do? Does it ask about where the file is playing at the moment?

sentriz commented 2 months ago

yeah the status command is how dsub gets the current progress. can you try do - GONIC_JUKEBOX_MPV_EXTRA_ARGS="--log-file=/tmp/mpv_logs" to see if mpv is givin any errors?

Butterblume511 commented 2 months ago

After finding the correct syntax jukebox-mpv-extra-args "--log-file=/tmp/mpv_logs" it seems that mpv can't find an audio driver to use. It tried pipewire: Host is down pulse alsa: opening device 'default' Playback open error: No such file or directory jack: cannot open server sdl: could not open audio: ALSA: Couldn't open audio device: No such file or directory and then cplayer Could not open/initialize audio device -> no sound

When I play an audio file from the command line it uses pipewire but when gonic tries to use it, this is the output for pipewire: [ 8.939][v][ao] Trying audio driver 'pipewire' [ 8.939][v][ao/pipewire] requested format: 44100 Hz, stereo channels, floatp [ 8.940][v][ao/pipewire] Headers version: 0.3.65 [ 8.940][v][ao/pipewire] Library version: 0.3.65 [ 8.944][w][ao/pipewire] Could not connect to context '(null)': Host is down

Butterblume511 commented 2 months ago

I found a way to play the files through ALSA: I created /etc/asound.conf with pcm.!default { type hw card 0 } ctl.!default { type hw
card 0 } and set user gonic to be in group audio to access the soundcard which wasn't permitted before. Now it works :) But is there a way to control the volume? The equalizer master slider in DSub has no effect on it sadly. I could just change the default volume in alsamixer. Which driver does sonic usually use? Is there a way to control the equalizer through DSub?

Ke1i commented 2 months ago

Volume control in jukebox mode does work for me so it should theoretically work for you. I set my sound output to alsa via the mpv extra arguments variable. Mine is set to --audio-device=alsa/default:CARD=PCH so maybe something like --audio-device=alsa/sysdefault:CARD=sndrpihifiberry for you. I'm using podman though but I don't think it matters.

Butterblume511 commented 2 months ago

Sadly, it does not work here. Added alsamixer to group audio as well but no change. And in journalctl there is no indication that gonic received any command for volume change. Maybe I'll try it through pulseaudio some other day.

Butterblume511 commented 2 months ago

I can change the volume through the smartphones volume control but not through the equalizer still. Is it alsamixer you are using? Could you maybe give me an idea how the command to change pitch/volume is used or give me an idea where to look to solve this?

Ke1i commented 2 months ago

Which equalizer are you talking about? Volume control is supposed to work on your device using your phone as the remote control. The equalizer in Dsub is for local playback on your phone and not on the computer acting as a jukebox. Some soundcards have equalizer settings that can be accessed via alsamixer.

Butterblume511 commented 2 months ago

Oh sorry, I then misunderstood you, I thought the equalizer works as well for you. Yes, I found alsamixer's equalizer and set them for the gonic and my local account but it had no effect at all.

Ke1i commented 2 months ago

Alsamixer settings get applied immediately. It's strange that they didn't work. Maybe a different soundcard is selected as default? When in alsamixer, press F6 to select the desired card.

Butterblume511 commented 2 months ago

I made the same mistake again. I changed the alsaequal settings under my local user but after I set it with sudo for the global equalizer it worked :) Thank you very much for your help.

Butterblume511 commented 2 months ago

After some testing I'm sure the equalizer has no effect whether I use it with root or with my normal user. I tried running alsamixer under the user "gonic" but it says "this account is not available". Do you any hints of what else I could do? When I use su it asks for the password for user gonic. Which one would that be? It's not the one set in the web-interface, nor "admin".