new package: snapcast-server

This commit is contained in:
Tee KOBAYASHI 2021-12-22 11:41:30 +09:00 committed by Leonid Pliushch
parent 70074799d2
commit b23ddf49b6
11 changed files with 248 additions and 0 deletions

View File

@ -0,0 +1,53 @@
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -91,11 +91,6 @@
if (BUILD_CLIENT)
message(FATAL_ERROR "Snapclient not yet supported for FreeBSD, use \"-DBUILD_CLIENT=OFF\"")
endif()
-elseif (${CMAKE_SYSTEM_NAME} MATCHES "Android")
- set (ANDROID TRUE)
- if (BUILD_SERVER)
- message(FATAL_ERROR "Snapserver not yet supported for Android, use \"-DBUILD_SERVER=OFF\"")
- endif()
endif()
# Configure paths
@@ -120,7 +115,7 @@
set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} "${CMAKE_SOURCE_DIR}/cmake/")
add_definitions(-DVERSION="${PROJECT_VERSION}")
-if(NOT ANDROID)
+if(TRUE)
set(CMAKE_ARCHIVE_OUTPUT_DIRECTORY ${CMAKE_SOURCE_DIR}/bin)
set(CMAKE_LIBRARY_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR})
set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CMAKE_SOURCE_DIR}/bin)
@@ -165,7 +160,7 @@
endif()
-if(NOT WIN32 AND NOT ANDROID)
+if(NOT WIN32)
if(MACOSX)
set(BONJOUR_FOUND true)
@@ -178,11 +173,6 @@
list(APPEND INCLUDE_DIRS "/usr/local/include")
else()
- pkg_search_module(ALSA REQUIRED alsa)
- if (ALSA_FOUND)
- add_definitions(-DHAS_ALSA)
- endif (ALSA_FOUND)
-
if(BUILD_WITH_PULSE)
pkg_search_module(PULSE libpulse)
if (PULSE_FOUND)
@@ -279,7 +269,7 @@
endif()
endif()
-if(NOT ANDROID)
+if(TRUE)
find_package(Boost 1.70 REQUIRED)
else()
find_package(oboe REQUIRED CONFIG)

View File

@ -0,0 +1,14 @@
TERMUX_PKG_HOMEPAGE=https://github.com/badaix/snapcast
TERMUX_PKG_DESCRIPTION="A multiroom client-server audio player"
TERMUX_PKG_LICENSE="GPL-3.0"
TERMUX_PKG_MAINTAINER="@termux"
TERMUX_PKG_VERSION=0.25.0
TERMUX_PKG_SRCURL=https://github.com/badaix/snapcast/archive/v${TERMUX_PKG_VERSION}.tar.gz
TERMUX_PKG_SHA256=c4e449cb693e091261727421f4965492be049632537e034fa9c59c92d091a846
TERMUX_PKG_DEPENDS="libc++, libexpat, libflac, libopus, libsoxr, libvorbis"
TERMUX_PKG_BUILD_DEPENDS="boost"
TERMUX_PKG_EXTRA_CONFIGURE_ARGS="-DBUILD_CLIENT=OFF -DBUILD_TESTS=OFF"
termux_step_pre_configure() {
LDFLAGS+=" -llog"
}

View File

@ -0,0 +1,20 @@
--- a/common/CMakeLists.txt
+++ b/common/CMakeLists.txt
@@ -2,7 +2,7 @@
resampler.cpp
sample_format.cpp)
-if(NOT WIN32 AND NOT ANDROID)
+if(NOT WIN32)
list(APPEND SOURCES daemon.cpp)
endif()
@@ -12,7 +12,7 @@
add_library(common STATIC ${SOURCES})
-if (ANDROID)
+if (FALSE)
target_link_libraries(common soxr::soxr)
elseif(SOXR_FOUND)
target_link_libraries(common ${SOXR_LIBRARIES})

View File

@ -0,0 +1,11 @@
--- a/server/config.cpp
+++ b/server/config.cpp
@@ -43,7 +43,7 @@
if (!root_directory.empty())
dir = root_directory;
else if (getenv("HOME") == nullptr)
- dir = "/var/lib/snapserver/";
+ dir = "@TERMUX_PREFIX@/var/lib/snapserver/";
else
dir = string(getenv("HOME")) + "/.config/snapserver/";

View File

@ -0,0 +1,34 @@
--- a/server/control_session_http.cpp
+++ b/server/control_session_http.cpp
@@ -41,11 +41,11 @@
" This webserver is a websocket endpoint for control clients (ws://<i>host</i>:1780/jsonrpc) and streaming clients"
" (ws://<i>host</i>:1780/stream), but it can also host simple web pages. To serve a web page, you must configure the"
" document root in the snapserver configuration file <b>snapserver.conf</b>, usually located in"
- " <b>/etc/snapserver.conf</b>"
+ " <b>@TERMUX_PREFIX@/etc/snapserver.conf</b>"
" </p>"
" <p>"
" The Snapserver installation should include a copy of <a href=\"https://github.com/badaix/snapweb\">Snapweb</a>,"
- " located in <b>/usr/share/snapserver/snapweb/</b><br>"
+ " located in <b>@TERMUX_PREFIX@/share/snapserver/snapweb/</b><br>"
" To activate it, please configure the <b>doc_root</b> as follows, and restart Snapserver to activate the changes:"
" </p>"
" <pre>"
@@ -56,7 +56,7 @@
"...\n"
"\n"
"# serve a website from the doc_root location\n"
- "doc_root = /usr/share/snapserver/snapweb/\n"
+ "doc_root = @TERMUX_PREFIX@/share/snapserver/snapweb/\n"
"\n"
"#\n"
"################################################</pre>"
@@ -241,7 +241,7 @@
if (settings_.doc_root.empty())
{
- std::string default_page = "/usr/share/snapserver/index.html";
+ std::string default_page = "@TERMUX_PREFIX@/share/snapserver/index.html";
struct stat buffer;
if (stat(default_page.c_str(), &buffer) == 0)
path = default_page;

View File

@ -0,0 +1,38 @@
--- a/server/etc/snapserver.conf
+++ b/server/etc/snapserver.conf
@@ -30,7 +30,7 @@
#threads = -1
# the pid file when running as daemon
-#pidfile = /var/run/snapserver/pid
+#pidfile = @TERMUX_PREFIX@/var/run/snapserver/pid
# the user to run as when daemonized
#user = snapserver
@@ -39,7 +39,7 @@
# directory where persistent data is stored (server.json)
# if empty, data dir will be
-# - "/var/lib/snapserver/" when running as daemon
+# - "@TERMUX_PREFIX@/var/lib/snapserver/" when running as daemon
# - "$HOME/.config/snapserver/" when not running as daemon
#datadir =
@@ -65,7 +65,7 @@
# serve a website from the doc_root location
# disabled if commented or empty
-doc_root = /usr/share/snapserver/snapweb
+doc_root = @TERMUX_PREFIX@/share/snapserver/snapweb
#
###############################################################################
@@ -127,7 +127,7 @@
# tcp client: tcp://<server IP, e.g. 127.0.0.1>:<port>?name=<name>&mode=client
# alsa: alsa://?name=<name>&device=<alsa device>[&send_silence=false][&idle_threshold=100][&silence_threshold_percent=0.0]
# meta: meta:///<name of source#1>/<name of source#2>/.../<name of source#N>?name=<name>
-source = pipe:///tmp/snapfifo?name=default
+source = pipe://@TERMUX_PREFIX@/tmp/snapfifo?name=default
#source = tcp://127.0.0.1?name=mopidy_tcp
# Default sample format

View File

@ -0,0 +1,11 @@
--- a/server/server_settings.hpp
+++ b/server/server_settings.hpp
@@ -27,7 +27,7 @@
struct Server
{
int threads{-1};
- std::string pid_file{"/var/run/snapserver/pid"};
+ std::string pid_file{"@TERMUX_PREFIX@/var/run/snapserver/pid"};
std::string user{"snapserver"};
std::string group{""};
std::string data_dir{""};

View File

@ -0,0 +1,20 @@
--- a/server/snapserver.1
+++ b/server/snapserver.1
@@ -9,7 +9,7 @@
standalone player, but an extension that turns your existing audio player into
a Sonos-like multiroom solution.
.br
-The server's audio input is a named pipe `/tmp/snapfifo`. All data that is fed
+The server's audio input is a named pipe `@TERMUX_PREFIX@/tmp/snapfifo`. All data that is fed
into this file will be send to the connected clients. One of the most generic
ways to use Snapcast is in conjunction with the music player daemon or Mopidy,
which can be configured to use a named pipe as audio output.
@@ -29,7 +29,7 @@
path to the configuration file
.SH FILES
.TP
-\fI/tmp/snapfifo\fR
+\fI@TERMUX_PREFIX@/tmp/snapfifo\fR
PCM input fifo file
.TP
\fI/etc/default/snapserver\fR

View File

@ -0,0 +1,22 @@
--- a/server/snapserver.cpp
+++ b/server/snapserver.cpp
@@ -56,8 +56,8 @@
try
{
ServerSettings settings;
- std::string pcmSource = "pipe:///tmp/snapfifo?name=default";
- std::string config_file = "/etc/snapserver.conf";
+ std::string pcmSource = "pipe://@TERMUX_PREFIX@/tmp/snapfifo?name=default";
+ std::string config_file = "@TERMUX_PREFIX@/etc/snapserver.conf";
OptionParser op("Allowed options");
auto helpSwitch = op.add<Switch>("h", "help", "Produce help message, use -hh to show options from config file");
@@ -250,7 +250,7 @@
throw std::invalid_argument("user must not be empty");
if (settings.server.data_dir.empty())
- settings.server.data_dir = "/var/lib/snapserver";
+ settings.server.data_dir = "@TERMUX_PREFIX@/var/lib/snapserver";
Config::instance().init(settings.server.data_dir, settings.server.user, settings.server.group);
daemon = std::make_unique<Daemon>(settings.server.user, settings.server.group, settings.server.pid_file);

View File

@ -0,0 +1,11 @@
--- a/server/streamreader/airplay_stream.cpp
+++ b/server/streamreader/airplay_stream.cpp
@@ -204,7 +204,7 @@
void AirplayStream::setParamsAndPipePathFromPort()
{
- pipePath_ = "/tmp/shairmeta." + cpt::to_string(getpid()) + "." + cpt::to_string(port_);
+ pipePath_ = "@TERMUX_PREFIX@/tmp/shairmeta." + cpt::to_string(getpid()) + "." + cpt::to_string(port_);
params_ = params_wo_port_ + " \"--metadata-pipename=" + pipePath_ + "\" --port=" + cpt::to_string(port_);
}

View File

@ -0,0 +1,14 @@
--- a/test/test_main.cpp
+++ b/test/test_main.cpp
@@ -36,9 +36,9 @@
{
AixLog::Log::init<AixLog::SinkCout>(AixLog::Severity::debug);
using namespace streamreader;
- StreamUri uri("pipe:///tmp/snapfifo?name=default&codec=flac");
+ StreamUri uri("pipe://@TERMUX_PREFIX@/tmp/snapfifo?name=default&codec=flac");
REQUIRE(uri.scheme == "pipe");
- REQUIRE(uri.path == "/tmp/snapfifo");
+ REQUIRE(uri.path == "@TERMUX_PREFIX@/tmp/snapfifo");
REQUIRE(uri.host.empty());
// uri = StreamUri("scheme:[//host[:port]][/]path[?query=none][#fragment]");