Saiyato / volumio-snapcast-plugin

Volumio 2 SnapCast plugin, to easily manage SnapCast functionality
115 stars 25 forks source link

Can't start service #51

Closed Fosphatic closed 5 years ago

Fosphatic commented 6 years ago

Hey there, would like to test your plugin. I did installed on both devices as you wrote in the installation manual of this plugin. Well on my mail volumio player raspberry pi3 with allo boss DAC it worked to start the service and i can configure in the backed, but i fail to do same with raspberry pi zero w. Even plugin was installed successfully i get following error when i try to start the service:

Sep 03 17:47:23 volumio-arbeitszimmer systemd[1]: snapclient.service: control process exited, code=exited status=127 Sep 03 17:47:23 volumio-arbeitszimmer systemd[1]: Failed to start Snapcast client. Sep 03 17:47:23 volumio-arbeitszimmer systemd[1]: Unit snapclient.service entered failed state. Sep 03 17:47:24 volumio-arbeitszimmer systemd[1]: snapclient.service holdoff time over, scheduling restart. Sep 03 17:47:24 volumio-arbeitszimmer systemd[1]: Stopping Snapcast client... Sep 03 17:47:24 volumio-arbeitszimmer systemd[1]: Starting Snapcast client... Sep 03 17:47:24 volumio-arbeitszimmer systemd[1]: snapclient.service start request repeated too quickly, refusing to start. Sep 03 17:47:24 volumio-arbeitszimmer systemd[1]: Failed to start Snapcast client. Sep 03 17:47:24 volumio-arbeitszimmer systemd[1]: Unit snapclient.service entered failed state.

Reboot of both units don't help somehow. Do you have an idea what i could check?

p.s. after i did apt-get update and apt-get upgrade the system warned me that a package

libatomic1

is needed for you plugin as depency but it is not installed.

edit2:

Okay i figured it out that i need to start manually from console in the directory /etc/default/

if i do start there snapserver then it works. How to get it running without console?

edit3:

I guess something is wrong with system.d snapserver as when i stop and start it then look with status it says:

● snapserver.service - Snapcast server Loaded: loaded (/lib/systemd/system/snapserver.service; enabled) Active: failed (Result: start-limit) since Mon 2018-09-03 22:53:48 UTC; 7s ago Process: 10660 ExecStart=/usr/bin/snapserver -d $USER_OPTS $SNAPSERVER_OPTS (code=exited, status=0/SUCCESS) Main PID: 10661 (code=exited, status=1/FAILURE)

but when i start from /usr/bin/snapserver or /etc/default/snapserver then it works fine, weird.

Beside that it runs very good with 16 bit and 48khz, everything runs from youtube, local mp3 or flac as any radio streams till now this is just awesome! Probably you can tell me how to fix the issue that after reboot the server is not started right somehow, the client service works fine, even i don't see the config anymore in the backend. I see that if click on settings of the plugin from the client it tries to connect to: 169.254.185.103 but that's not my ip range that's why i guess no backend settings.

Saiyato commented 6 years ago

I'm going to have to check how things work on a Zero W, for this I actually need a Zero for testing purposes. At this time I don't have a Zero W, so debugging this is hard, I only have the B members of the family lying around.

Fosphatic commented 6 years ago

Hey well the main service is on raspberry pi 3 b model and unfortunately the the service was getting very unstable after few days. Would love to see this project one day to he stable enough for a daily use, but actually I have up to try it out as I had always to restart the both devices and then services again from ssh console. This is not really satisfying but when it worked then it worked at least for few days always. Thanks for your effort anyway, keep the good work, regards 👍

Saiyato commented 6 years ago

@Fosphatic can you elaborate on the 'very unstable' part please? I'm running snapcast as default, since I have extra speakers (and a Pi2 and HifiBerry AMP+) in the garden and the garage (Pi1B+ and HifiBerry DIGI).

For example what is problematic after a few days of use? No sound, distortion, other problems? Also which version of Volumio and snap are you using? I believe badaix released 0.15 of snap lastly.

Fosphatic commented 6 years ago

Well it worked for me well for exactly 5 days. After that i wasn't able to play synced anymore. It was running in living room but not in my work room. I restarted the unit and did again manualy started the service in "server" service through ssh console session in the living room. It worked again pretty well for 5 days. I don't mean 5 days playing 24/7 just few hours on each evening. Well after few days it stoped again working. I repeated it one or two times more and then gave up as it was a bit unhandy to do reboot the both pies. If this worked it was fine enough. Why it stopping working i do not understand as i did no config changes or anything at all. Always only play some songs or internet radio.

Saiyato commented 6 years ago

Hi @Fosphatic , what do you mean by 'play synced anymore' and 'stopped working'? Was there no more sound, or was it no longer in sync? And what the problem at the host, the client, or both?

What does the log tell you about the problems you are experiencing? Are you seeing chunk errors, connection errors or different errors? And are you seeing these errors at the host, client or both?

The point is, are we talking about a Volumio, plugin or SnapCast issue. You logged this at the plugin, but the plugin only caters for easy configuration and the starting/stopping of the service. If the problem is of a different nature, I might not be able to assist properly.

Fosphatic commented 6 years ago

Sorry for have beeing unclear, yes on the client no sound was coming out. On "server" pie sound was playing always fine. Well enabling the snapcast servcer service on main pie in living room from gui don't worked for me. I had no sound on client then at all, even in the living room it was playing fine.

Only the ssh console command with two && at the end was doing the trick. On client side the plugin was running without issues from the gui i had only to follow your instructions from github.

Saiyato commented 6 years ago

Can you post the content of the /etc/default/snapserver?

For example, my settings are:

volumio@volumiomain:~$ cat /etc/default/snapserver
# defaults file for snapserver

# start snapserver automatically?
START_SNAPSERVER=true

# Allowed options:
#   -h, --help                          Produce help message
#   -v, --version                       Show version number
#   -p, --port arg (=1704)              Server port
#   --controlPort arg (=1705)           Remote control port
#   -s, --stream arg (=pipe:///tmp/snapfifo?name=default)
#                                       URI of the PCM input stream.
#                                       Format: TYPE://host/path?name=NAME
#                                       [&codec=CODEC]
#                                       [&sampleformat=SAMPLEFORMAT]
#   --sampleformat arg (=48000:16:2)    Default sample format
#   -c, --codec arg (=flac)             Default transport codec
#                                       (flac|ogg|pcm)[:options]
#                                       Type codec:? to get codec specific options
#   --streamBuffer arg (=20)            Default stream read buffer [ms]
#   -b, --buffer arg (=1000)            Buffer [ms]
#   --sendToMuted                       Send audio to muted clients
#   -d, --daemon [=arg(=0)]             Daemonize
#                                       optional process priority [-20..19]
#   --user arg                          the user[:group] to run snapserver as when daemonized

USER_OPTS="--user snapserver:snapserver"

SNAPSERVER_OPTS="-d -s pipe:///tmp/snapfifo?name=VolumioMain&mode=read&sampleformat=44100:16:2 "

As said, I have had no problems whatsoever playing YouTube, webradio, HD audio from my server and Spotify (most used). This applies to the server, the client in the garden is shutdown regularly and in the garage it also showing no signs of trouble. Volumio version is 2.413, SnapCast/SnapClient v0.15 and plugin version 2.2.3 (I see I'm behind, will update the main instance this week) for all instances.

Saiyato commented 6 years ago

Hi @Fosphatic any news on the above maybe? Also, I've found v0.15 to expose some problems on x86, when compiled locally. I'm in the process of figuring out whether or not I built correctly.

Fosphatic commented 6 years ago

@Saiyato sorry lad, i had a busy week and not much time at the weekend, i will provide the information you wanted in the evening today. I wanted to do that yesterday check everything and post you, but unfortinately one usb hub i used on the client with ethernet card and 3 ports died. So i could not test the function at all, but i can post you the settings from living room pi3 b+. Even it should be default as i did only followed the instructions on github. However i had to realize yesterday as well that this plugin makes the volumio installation not upgradeable anymore. Well i guess it is because of this plugin, as this is the only extra i have on this unit.

I'm sorry again and promise to provide you the information you need for make some progress. X86 units i don't have at home with volumio only 1 pi3 b+ and two pi zero w.

Regards

Fossy

Saiyato commented 6 years ago

Awesome, thanks! The info will help a lot, I will continue working on the x86 project which might provide more insight. I will get back if I found that additional information might help more.

Cheers

Fosphatic commented 6 years ago

Fair enough, and thank you for your patience as effort. It's not most common nowadays, i appreciate that very much.

Fosphatic commented 6 years ago

@saiyato this was my output on main pi in living room:

start snapserver automatically?

START_SNAPSERVER=true

Allowed options:

-h, --help Produce help message

-v, --version Show version number

-p, --port arg (=1704) Server port

--controlPort arg (=1705) Remote control port

-s, --stream arg (=pipe:///tmp/snapfifo?name=default)

URI of the PCM input stream.

Format: TYPE://host/path?name=NAME

[&codec=CODEC]

[&sampleformat=SAMPLEFORMAT]

--sampleformat arg (=48000:16:2) Default sample format

-c, --codec arg (=flac) Default transport codec

(flac|ogg|pcm)[:options]

Type codec:? to get codec specific options

--streamBuffer arg (=20) Default stream read buffer [ms]

-b, --buffer arg (=1000) Buffer [ms]

--sendToMuted Send audio to muted clients

-d, --daemon [=arg(=0)] Daemonize

optional process priority [-20..19]

--user arg the user[:group] to run snapserver as when daemonized

USER_OPTS="--user snapserver:snapserver"

SNAPSERVER_OPTS="-d -s pipe:///tmp/snapfifo?name=Snapcast&mode=read&sampleformat=48000:32:2 -s pipe:///tmp/spotififo?name=undefined&mode=read" volumio@volumio-wohnzimmer:~$

Saiyato commented 6 years ago

Ok, this helps, so you have two streams:

  1. /tmp/snapfifo -> used for MPD
  2. /tmp/spotififo -> used for the Spotify implementations (volspotconnect1/2 and/or librespot)

If this is not what you want, you can switch off "dedicated stream for Spotify", unless you don't use Spotify, then you can just ignore it.

What do you mean with Volumio being not upgradeable anymore? You can open the install.sh file, it only writes an asound.conf and modifies mpd.conf + any Spotify template found. Apart from that it obviously installs the snap-components and creates the files to control them.

But back to playback, can you post the section in mpd.conf you configured? It looks like this:

audio_output {
    type            "fifo"
    enabled         "yes"
    name            "multiroom"
    path            "/tmp/snapfifo"
    format          "44100:16:2"
}

Oh and I obviously disabled output for ALSA.

As you can see I use 44100:16:2 for both MPD and SnapCast, I found those settings to work best. Somehow the restore commands don't seem to always work for me, so after changing mpd.conf/asound.conf I always reboot.

I just dawned on me, maybe your sound is not working after a few days because Volumio reverts back to previous settings... One other config file which is important needs to be checked -> asound.conf

volumio@volumiomain:~$ cat /etc/asound.conf
pcm.spotoutf
{
type dmix
slave {
pcm hw:1
rate 44100
        }
ipc_key 1024
}
pcm.spotout
{
type plug
#slave.pcm spotoutf
slave.pcm writeFile
}

defaults.pcm.rate_converter "speexrate_high"
#SNAPCAST
pcm.!snapcast {
        type plug
        slave.pcm snapConverter
}

pcm.snapConverter {
        type rate
        slave {
                pcm writeFile # Direct to the plugin which will write to a file
                format S16_LE
                rate 44100
        }
}

pcm.writeFile {
        type file
        slave.pcm null
        file "/tmp/snapfifo"
        format "raw"
}
#ENDOFSNAPCAST

So what I did, the Spotify imp uses pcm.spotout, which I then redirected to writeFile (= write to fifo). I don't use the conversion anymore, because I found that to create distortion instead. So basically everything I output for multiroom is 44.1kHz, 16 bits and 2 channels. I know this limits quality, but I haven't had the time to verify each configuration and determine which sounds best. ;)

I also must admit, I've settled for the 'lesser' quality for snapcast and I'm exploring other options which don't require resampling.

Fosphatic commented 5 years ago

@Saiyato hey lad, sorry i had to wait till today for my new adapter to get usb soundcard as ethernet running again on the client. The content of asound.conf here is following:

SNAPCAST

pcm.!snapcast { type plug slave.pcm snapConverter }

pcm.snapConverter { type rate slave { pcm writeFile # Direct to the plugin which will write to a file format S16_LE rate 48000 } }

pcm.writeFile { type file slave.pcm null file "/tmp/spotififo" format "raw" }

ENDOFSNAPCAST

Fosphatic commented 5 years ago

With not upgradeable i mean that volumio says me that too much modification were made to the system if i click on firmware upgrade button in volumio web interface.

Fosphatic commented 5 years ago

@Saiyato Hey there, well i did reflashed my pi zero and installed the client from the scratch as your plugin. It works now like a charm. I see there a new options at web interface config site of your plugin is it a newer version now? I guess this one can be closed at least. Thank you for your effor mate, this plugin is just awesome! I hope one day it will work with bluetooth speaker plugin too. This would be just <3

Saiyato commented 5 years ago

Thanks for the update! Good to hear it's working now, there have been some updates in the past to improve configuration yes. :)

Fosphatic commented 5 years ago

@Saiyato this probably solved the starting problems too. I don't know but it is working for me now since 2 days of testing well so far. I was able to force volumio to upgrade to latest version through cli too and all went fine seems to be. Because you extension patch the .conf file i guess it wasnt allowing me to upgrade through web interface.

However I'm very satisfied with this extension it's just awesome. Thank you very much!

I hope the guy who is working on the bluetooth plugin will add support for your extension as it would help me so much to add pretty cheap a bluetooth speakers in each room this would be just <3 <3 <3

Saiyato commented 5 years ago

Awesome, thanks for the feedback.