geekuillaume / soundsync

Virtual cables between any audio source and any speaker in your home
https://soundsync.app
Other
841 stars 36 forks source link

Headless install on non-Raspbian SBC #35

Open LostSoulfly opened 4 years ago

LostSoulfly commented 4 years ago

I've been trying to figure this one out. I've installed multiple times, verified dependencies, etc.

/opt/Soundsync/soundsync_electron: error while loading shared libraries: libX11-xcb.so.1: cannot open shared object file: No such file or directory

This shows up in journalctl as well: image

edit: Armbian 20.08.5 Focal with Linux 5.8.12-rockchip64

geekuillaume commented 4 years ago

I have only tested Raspbian with the provided ARM package. It's possible your distribution doesn't include some packages that are included by default with Raspbian. If you already checked the deps with sudo apt-get install -f you can try to install the Chrome or Chromium package for your distribution. These packages have the majority of the same deps than what Electron (which Soundsync uses) requires.

LostSoulfly commented 4 years ago

I've tried multiple distributions for my SBC (Rock64): Ubuntu, debian, Armbian, DietPi as well as headless AND desktop versions of many of them, and am never able to get past this same error. I've installed all the recommended chromium libs (and Chromium opens fine..) Audio works in general both over HDMI and spdif, as well as through a USB DAC I have, but I can't ever get SoundSync to start. I've even tried compiling/running it with node unsuccessfully.

Any chance you could update the readme with some compiling instructions?

geekuillaume commented 4 years ago

To start Soundsync manually you need NodeJS and Git installed then clone this repo git clone https://github.com/geekuillaume/soundsync, install the deps npm install, build npm run build than start it npm run start. If you still have the problem, can you send me the logs generated by this command?

LostSoulfly commented 4 years ago

Thanks for the quick rundown!

I'm getting closer, slowly but surely..

installed nodejs..

curl -sL https://deb.nodesource.com/setup_14.x | bash -
apt-get install -y nodejs

Had to manually install yarn

curl -sS https://dl.yarnpkg.com/debian/pubkey.gpg | sudo apt-key add -
echo "deb https://dl.yarnpkg.com/debian/ stable main" | sudo tee /etc/apt/sources.list.d/yarn.list
sudo apt update && sudo apt install yarn

autoworklet errors:

0 info it worked if it ends with ok
1 verbose cli [ '/usr/bin/node', '/usr/bin/npm', 'run', 'build' ]
2 info using npm@6.14.8
3 info using node@v14.13.1
4 verbose run-script [ 'prebuild', 'build', 'postbuild' ]
5 info lifecycle audioworklet@5.0.2~prebuild: audioworklet@5.0.2
6 info lifecycle audioworklet@5.0.2~build: audioworklet@5.0.2
7 verbose lifecycle audioworklet@5.0.2~build: unsafe-perm in lifecycle true
8 verbose lifecycle audioworklet@5.0.2~build: PATH: /usr/lib/node_modules/npm/node_modules/npm-lifecycle/node-gyp-bin:/home/dietpi/Desktop/soundsync/app/node_modules/audioworklet/node_modules/.bin:/home/dietpi/Desktop/soundsync/app/node$9 verbose lifecycle audioworklet@5.0.2~build: CWD: /home/dietpi/Desktop/soundsync/app/node_modules/audioworklet
10 silly lifecycle audioworklet@5.0.2~build: Args: [ '-c', 'run-script-os' ]
11 info lifecycle audioworklet@5.0.2~build: Failed to exec build script
12 verbose stack Error: audioworklet@5.0.2 build: `run-script-os`
12 verbose stack spawn ENOENT
12 verbose stack     at ChildProcess.<anonymous> (/usr/lib/node_modules/npm/node_modules/npm-lifecycle/lib/spawn.js:48:18)
12 verbose stack     at ChildProcess.emit (events.js:314:20)
12 verbose stack     at maybeClose (internal/child_process.js:1047:16)
12 verbose stack     at Process.ChildProcess._handle.onexit (internal/child_process.js:287:5)
13 verbose pkgid audioworklet@5.0.2
14 verbose cwd /home/dietpi/Desktop/soundsync/app/node_modules/audioworklet
15 verbose Linux 5.8.13-rockchip64
16 verbose argv "/usr/bin/node" "/usr/bin/npm" "run" "build"
17 verbose node v14.13.1
18 verbose npm  v6.14.8
19 error code ELIFECYCLE
20 error syscall spawn
21 error file sh
22 error errno ENOENT
23 error audioworklet@5.0.2 build: `run-script-os`
23 error spawn ENOENT
24 error Failed at the audioworklet@5.0.2 build script.
24 error This is probably not a problem with npm. There is likely additional logging output above.
25 verbose exit [ 1, true ]

And here's the tail of the log:

45 silly build soundsync@0.4.2-dev
46 info linkStuff soundsync@0.4.2-dev
47 silly linkStuff soundsync@0.4.2-dev has /home/dietpi/Desktop as its parent node_modules
48 silly install soundsync@0.4.2-dev
49 info lifecycle soundsync@0.4.2-dev~install: soundsync@0.4.2-dev
50 silly postinstall soundsync@0.4.2-dev                                                                                                                                                                                                     51 info lifecycle soundsync@0.4.2-dev~postinstall: soundsync@0.4.2-dev
52 verbose lifecycle soundsync@0.4.2-dev~postinstall: unsafe-perm in lifecycle true
53 verbose lifecycle soundsync@0.4.2-dev~postinstall: PATH: /usr/lib/node_modules/npm/node_modules/npm-lifecycle/node-gyp-bin:/home/dietpi/Desktop/soundsync/node_modules/.bin:/usr/local/bin:/usr/bin:/bin:/usr/local/games:/usr/games
54 verbose lifecycle soundsync@0.4.2-dev~postinstall: CWD: /home/dietpi/Desktop/soundsync
55 silly lifecycle soundsync@0.4.2-dev~postinstall: Args: [ '-c', 'cd app && (yarn || npm install)' ]
56 timing audit submit Completed in 636ms
57 http fetch POST 200 https://registry.npmjs.org/-/npm/v1/security/audits/quick 638ms
58 timing audit body Completed in 9ms
59 silly lifecycle soundsync@0.4.2-dev~postinstall: Returned: code: 1  signal: null
60 info lifecycle soundsync@0.4.2-dev~postinstall: Failed to exec postinstall script
61 verbose stack Error: soundsync@0.4.2-dev postinstall: `cd app && (yarn || npm install)`
61 verbose stack Exit status 1
61 verbose stack     at EventEmitter.<anonymous> (/usr/lib/node_modules/npm/node_modules/npm-lifecycle/index.js:332:16)
61 verbose stack     at EventEmitter.emit (events.js:314:20)
61 verbose stack     at ChildProcess.<anonymous> (/usr/lib/node_modules/npm/node_modules/npm-lifecycle/lib/spawn.js:55:14)
61 verbose stack     at ChildProcess.emit (events.js:314:20)
61 verbose stack     at maybeClose (internal/child_process.js:1047:16)
61 verbose stack     at Process.ChildProcess._handle.onexit (internal/child_process.js:287:5)
62 verbose pkgid soundsync@0.4.2-dev
63 verbose cwd /home/dietpi/Desktop/soundsync
64 verbose Linux 5.8.13-rockchip64
65 verbose argv "/usr/bin/node" "/usr/bin/npm" "install"
66 verbose node v14.13.1
67 verbose npm  v6.14.8
68 error code ELIFECYCLE
69 error errno 1
70 error soundsync@0.4.2-dev postinstall: `cd app && (yarn || npm install)`
70 error Exit status 1
geekuillaume commented 4 years ago

The install process is failing because I didn't include a Arm64 version of audioworklet. I've just released a new version with this arch enabled. Can you try pulling and reinstalling the deps with yarn ?

LostSoulfly commented 4 years ago

It took some more work, but I got it to run!

I did another clone, installed typescript, manually installed webpack and the newest audioworklet, manually installed pulseaudio, did some other stuff.. image

LostSoulfly commented 4 years ago

Finally got around to testing it and I'm not able to send any audio to or receive from it. Looks like everything is sent/received out of order and is dropped. I never hear anything. image

geekuillaume commented 4 years ago

It seems that the audio is not processed quickly enough to be sent to the audio device in the configured latency. I've implemented some optimizations today. Can you test it with the latest commit (https://github.com/geekuillaume/soundsync/commit/bec36ff5914ad321a44c61038185e64681829076)?

LostSoulfly commented 4 years ago

Did a git pull then yarn then npm run build then npm run start. Sound source is my Windows 10 desktop with a Ryzen 3700X. This SBC is actually faster than a Pi 3, which is why this is so strange. I've also pulled up htop to show CPU and memory usage.

image

geekuillaume commented 4 years ago

I've found a bug related to the audio synchronization that could lead in silence. Can you again test the last commit ? Sorry for all this but I cannot reproduce the bug and it's way harder to pinpoint the source of the problem.

LostSoulfly commented 4 years ago

Just saw the commits and new version, already on it!

LostSoulfly commented 4 years ago

It works! You nailed it with that bug fix. I also tried to install the previous version from the deb package with the same x11 error, but at least I can build and run it manually.

Thanks and great work!

image

Here's the SBC I'm using: https://www.amazon.com/Iconikal-Rockchip-Computer-Processor-1866MHz/dp/B0868WSTXH

geekuillaume commented 4 years ago

Nice :) Does this work with electron (yarn run start:electron) ?

LostSoulfly commented 4 years ago

Yes, it does appear to work.

image

I can get you terminal access if you want to troubleshoot the deb package, just let me know.

edit: I also tried the auto-start option but it just launched an generic Electron window instead of SoundSync. I was able to get SoundSync to run at startup by changing the command in the .desktop file to yarn --cwd /path/to/soundsync run start:electron and it launched like a charm.

LostSoulfly commented 4 years ago

This needs more testing and it's probably got some redundant commands but I was able to get SoundSync running with some or all of this. I'm not sure if it will work all in one copy+paste, but it's definitely something for others to go off of when trying to run this on a headless install.

This was used on Armbian_20.08.1_Rock64_focal_legacy_4.4.213.img headless/server install. If anyone has any input or additional commands to run please let me know! (I'd run each set of commands at a time -- this is not a bash script)

sudo apt-get update
sudo apt-get -y upgrade

#install alsa
sudo apt-get install libasound2 libasound2-plugins alsa-utils alsa-oss

#install pulseaudio
sudo apt-get install pulseaudio pulseaudio-utils

#set group memberships. Change username to yours
#may not be necessary
sudo usermod -aG pulse,pulse-access,audio <username>

#unmute all sound devices, probably not necessary
for x in `amixer controls  | grep layback` ; do amixer cset "${x}" on ; done

#Set pulseaudio to auto-run when needed otherwise it may not be running at boot
#sudo nano /etc/pulse/client.conf
#remove the ; next to 
#; autospawn = yes
#and save it

#install nodejs
curl -sL https://deb.nodesource.com/setup_14.x | sudo bash -
sudo apt-get install -y nodejs

#Install yarn
curl -sS https://dl.yarnpkg.com/debian/pubkey.gpg | sudo apt-key add -
echo "deb https://dl.yarnpkg.com/debian/ stable main" | sudo tee /etc/apt/sources.list.d/yarn.list
sudo apt update && sudo apt -y install yarn

#install git
sudo apt-get install -y git

#install npm
sudo apt-get -y install npm

#if you get "you have held broken packages" error you can try and run this:
#sudo apt install aptitude
#sudo aptitude install npm

#clone repo to /opt/soundsync
cd /opt
sudo git clone https://github.com/geekuillaume/soundsync

#easy permissions, feel free to lock yours down stronger
sudo chmod -R 777 soundsync
cd soundsync

#install dependencies
npm install

#install webpack if it doesn't install?
#npm install webpack

#install typescript
npm install typescript --save-dev

#run yarn. I guess it's another package manager?
yarn

#run soundsync build script
npm run build

#run soundsync start script
npm run start

#if everything worked, SoundSync should be running!
#ctrl+c to stop it

#can use pm2 to auto-run soundsync
sudo npm install -g pm2

#don't run these as root, but rather your user
#and be sure to still be in /opt/soundsync working dir
pm2 --name SoundSync start npm -- start

#SoundSync should now be running in a daemon.
#To run at startup use this and do as it says.
pm2 startup

#then run this to save the list of running npm processes
pm2 save