Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

compile snapcast server #46

Open
moritzkreemke opened this issue Oct 13, 2021 · 7 comments
Open

compile snapcast server #46

moritzkreemke opened this issue Oct 13, 2021 · 7 comments

Comments

@moritzkreemke
Copy link

Hello,

thank you for this nice project. I would love, if it would be possible, to compile snapcast server for android.

Idea/Background:
For University, I have to build an open source android project which uses Wifi-Direct/Bluetooth. My Idea:

Create an app, where you can connect multiple phones together (using Wifi Direct) and play music together.

How it works:
Phone A receives audio via a TCP Stream and acting as a server. Phone A is at the same time a client and connect to itself. Phone B (connected via Wifi) should work fine with snapdroid as it is now.

Problem:
When compiling snapdroid with BUILD_SERVER=ON. I get the Info: snapserver not yet supported for Android.

Question:
Is snapserver not supported because this app current does not make use of them? Or does snapcast in general not supported/compile on android?

If snapcast can be compiled for android, build instructions would be great. In the snapcast build documentation, it's only linked to this project. Therefore, I hope it correct asking here.

Thank you for any help.

@guerman5
Copy link

guerman5 commented Nov 5, 2021

+1
I'm also interested.
I dug the issues and found an old post from Sir Pohl (when snapcast was only v13)
badaix/snapcast#271 (comment)

Then, I tried to cross compile v13 snapcast client/server for android on Arch, got the NDK, compiled the tools and the submodules (had to find myself). but i get stuck with the boost submodule, probably is not exactly as it was prepared for snapcast use. I downloaded boost_asio_1_10_8.zip from sourceforge and boost_1_63_0.zip from boost . org trying to get 2016 code, and tried to stitch all the hpp that compiler was asking. But get errors like:
client
./clientConnection.h:34:7: error: use of undeclared identifier 'asio'; did you mean 'boost::asio'?

server
controlSession.h:34:7: error: 'asio' has not been declared
snapServer.cpp:65:51: error: expected primary-expression before '>' token /*auto portValue =*/ op.add<Value<size_t>>("p", "port", "Server port", settings.port, &settings.port);

among others errors and warnings, but i guess they originate from same mistake.

I'm doing something wrong, definitely obvious for the experienced eye, but I cant see it. Its because I'm learning how to compile with snapcast xD, never done this before.

I'm writing this to bring the topic into motion once more, and show that I'm trying as best as I can.
Snapcast is v25 now, many things have changed, i assume the compilation method will be totally different.

Yes, that good is snapcast, and that bad I want to be able to run snapserver from android. I've taken the jump into compiling.

Thanks for reading.

@badaix
Copy link
Owner

badaix commented Nov 6, 2021

The develop branch can compile the server for Android. To build the App, I recommend to use the latest Android Studio with the latest NDK and SDK and copy the required libraries to Snapcast/libs as described in readme.txt. To build the server, BUILD_SERVER must be set to ON in build.gradle.
You can test the server in a root shell of your emulator:

johannes@Laptop:~/Develop/snapdroid$ ~/Develop/Android/Sdk/platform-tools/adb shell
generic_x86:/ $ su
generic_x86:/ # find /data -name "libsnapserver.so"
/data/app/~~eKwnv13JzR3hJVqyZWj3wQ==/de.badaix.snapcast-YFPjscovXwt_pmCMncsb6A==/lib/x86/libsnapserver.so
generic_x86:/ # /data/app/~~eKwnv13JzR3hJVqyZWj3wQ==/de.badaix.snapcast-YFPjscovXwt_pmCMncsb6A==/lib/x86/libsnapserver.so
2021-11-06 12-11-30.566 [Info] (Snapserver) Version 0.25.0
2021-11-06 12-11-30.579 [Error] (Snapserver) Exception: failed to create settings directory: "//.config/snapserver/": 30
terminating with uncaught exception of type SnapException: failed to create settings directory: "//.config/snapserver/": 30
/buildbot/src/android/ndk-release-r23/toolchain/llvm-project/libcxx/../../../toolchain/llvm-project/libcxxabi/src/abort_message.cpp:72: abort_message: assertion "terminating with uncaught exception of type SnapException: failed to create settings directory: "//.config/snapserver/": 30" failed
Aborted 
134|generic_x86:/ # 

As you can see, this server will fail to create a directory for it's settings and exit.

@badaix
Copy link
Owner

badaix commented Nov 6, 2021

The settings directory is now configurable. You can start the server from the App in a similar way as the client is started and configure a data dir and a stream source like this:
libsnapserver.so --server.datadir=getCacheDir().toString() --stream.source=tcp://127.0.0.1?name=android

@guerman5
Copy link

guerman5 commented Nov 8, 2021

Thanks a lot, I will work on it and update. Sweet!

@guerman5
Copy link

guerman5 commented Nov 8, 2021

The build was successful, apk installed ok. Configured settings and took off
Im testing it now, very smooth

/data/app/de.badaix.snapcast-1/lib/arm64/./libsnapserver.so --server.datadir=/storage/emulated/0 --stream.source=pipe:///data/data/com.termux/files/usr/var/run/mpd.fifo?name=Radio&sampleformat=48000:16:2&codec=flac

What a great satisfaction it feels, its alive!

Muchas gracias Johannes

@pvi-github
Copy link

Hello there,

Do we still need to have the device rooted to run the Snapcast server on android ?

Kind regards,

@pvi-github
Copy link

And bonus question : wouldn't it be nice to have an APK published for Snapcast server ?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants