mirror of
https://github.com/badaix/snapcast.git
synced 2025-05-22 13:36:18 +02:00
switch to popl v0.7.0
This commit is contained in:
parent
4670927d67
commit
16286d122a
4 changed files with 53 additions and 82 deletions
|
@ -78,38 +78,25 @@ int main (int argc, char **argv)
|
|||
size_t port(1704);
|
||||
int latency(0);
|
||||
size_t instance(1);
|
||||
int processPriority(-3);
|
||||
|
||||
Switch helpSwitch("", "help", "produce help message");
|
||||
Switch debugSwitch("", "debug", "enable debug logging");
|
||||
Switch versionSwitch("v", "version", "show version number");
|
||||
Switch listSwitch("l", "list", "list pcm devices");
|
||||
Value<string> hostValue("h", "host", "server hostname or ip address", "", &host);
|
||||
Value<size_t> portValue("p", "port", "server port", 1704, &port);
|
||||
Value<string> soundcardValue("s", "soundcard", "index or name of the soundcard", "default", &soundcard);
|
||||
Implicit<int> daemonOption("d", "daemon", "daemonize, optional process priority [-20..19]", -3, &processPriority);
|
||||
Value<int> latencyValue("", "latency", "latency of the soundcard", 0, &latency);
|
||||
Value<size_t> instanceValue("i", "instance", "instance id", 1, &instance);
|
||||
Value<string> hostIdValue("", "hostID", "unique host id", "");
|
||||
Value<string> userValue("", "user", "the user[:group] to run snapclient as when daemonized");
|
||||
|
||||
OptionParser op("Allowed options");
|
||||
op.add(helpSwitch)
|
||||
.add(debugSwitch, hidden)
|
||||
.add(versionSwitch)
|
||||
.add(hostValue)
|
||||
.add(portValue)
|
||||
auto helpSwitch = op.add<Switch>("", "help", "produce help message");
|
||||
auto debugSwitch = op.add<Switch, Attribute::hidden>("", "debug", "enable debug logging");
|
||||
auto versionSwitch = op.add<Switch>("v", "version", "show version number");
|
||||
#if defined(HAS_ALSA)
|
||||
.add(listSwitch)
|
||||
.add(soundcardValue)
|
||||
auto listSwitch = op.add<Switch>("l", "list", "list pcm devices");
|
||||
auto soundcardValue = op.add<Value<string>>("s", "soundcard", "index or name of the soundcard", "default", &soundcard);
|
||||
#endif
|
||||
auto hostValue = op.add<Value<string>>("h", "host", "server hostname or ip address", "", &host);
|
||||
auto portValue = op.add<Value<size_t>>("p", "port", "server port", 1704, &port);
|
||||
#ifdef HAS_DAEMON
|
||||
.add(daemonOption)
|
||||
.add(userValue)
|
||||
int processPriority(-3);
|
||||
auto daemonOption = op.add<Implicit<int>>("d", "daemon", "daemonize, optional process priority [-20..19]", -3, &processPriority);
|
||||
auto userValue = op.add<Value<string>>("", "user", "the user[:group] to run snapclient as when daemonized");
|
||||
#endif
|
||||
.add(latencyValue)
|
||||
.add(hostIdValue)
|
||||
.add(instanceValue);
|
||||
auto latencyValue = op.add<Value<int>>("", "latency", "latency of the soundcard", 0, &latency);
|
||||
auto instanceValue = op.add<Value<size_t>>("i", "instance", "instance id", 1, &instance);
|
||||
auto hostIdValue = op.add<Value<string>>("", "hostID", "unique host id", "");
|
||||
|
||||
try
|
||||
{
|
||||
|
@ -122,7 +109,7 @@ int main (int argc, char **argv)
|
|||
exit(EXIT_FAILURE);
|
||||
}
|
||||
|
||||
if (versionSwitch.isSet())
|
||||
if (versionSwitch->is_set())
|
||||
{
|
||||
cout << "snapclient v" << VERSION << "\n"
|
||||
<< "Copyright (C) 2014-2017 BadAix (snapcast@badaix.de).\n"
|
||||
|
@ -133,20 +120,20 @@ int main (int argc, char **argv)
|
|||
exit(EXIT_SUCCESS);
|
||||
}
|
||||
|
||||
if (listSwitch.isSet())
|
||||
{
|
||||
#ifdef HAS_ALSA
|
||||
if (listSwitch->is_set())
|
||||
{
|
||||
vector<PcmDevice> pcmDevices = AlsaPlayer::pcm_list();
|
||||
for (auto dev: pcmDevices)
|
||||
{
|
||||
cout << dev.idx << ": " << dev.name << "\n"
|
||||
<< dev.description << "\n\n";
|
||||
}
|
||||
#endif
|
||||
exit(EXIT_SUCCESS);
|
||||
}
|
||||
#endif
|
||||
|
||||
if (helpSwitch.isSet())
|
||||
if (helpSwitch->is_set())
|
||||
{
|
||||
cout << op << "\n";
|
||||
exit(EXIT_SUCCESS);
|
||||
|
@ -157,7 +144,7 @@ int main (int argc, char **argv)
|
|||
|
||||
AixLog::Log::init(
|
||||
{
|
||||
make_shared<AixLog::SinkCout>(debugSwitch.isSet()?(AixLog::Severity::trace):(AixLog::Severity::info), AixLog::Type::all, debugSwitch.isSet()?"%Y-%m-%d %H-%M-%S.#ms [#severity] (#function)":"%Y-%m-%d %H-%M-%S [#severity]"),
|
||||
make_shared<AixLog::SinkCout>(debugSwitch->is_set()?(AixLog::Severity::trace):(AixLog::Severity::info), AixLog::Type::all, debugSwitch->is_set()?"%Y-%m-%d %H-%M-%S.#ms [#severity] (#function)":"%Y-%m-%d %H-%M-%S [#severity]"),
|
||||
make_shared<AixLog::SinkNative>("snapclient", AixLog::Severity::trace, AixLog::Type::special)
|
||||
}
|
||||
);
|
||||
|
@ -168,7 +155,7 @@ int main (int argc, char **argv)
|
|||
|
||||
#ifdef HAS_DAEMON
|
||||
std::unique_ptr<Daemon> daemon;
|
||||
if (daemonOption.isSet())
|
||||
if (daemonOption->is_set())
|
||||
{
|
||||
string pidFile = "/var/run/snapclient/pid";
|
||||
if (instance != 1)
|
||||
|
@ -176,12 +163,12 @@ int main (int argc, char **argv)
|
|||
string user = "";
|
||||
string group = "";
|
||||
|
||||
if (userValue.isSet())
|
||||
if (userValue->is_set())
|
||||
{
|
||||
if (userValue.getValue().empty())
|
||||
if (userValue->value().empty())
|
||||
std::invalid_argument("user must not be empty");
|
||||
|
||||
vector<string> user_group = utils::string::split(userValue.getValue(), ':');
|
||||
vector<string> user_group = utils::string::split(userValue->value(), ':');
|
||||
user = user_group[0];
|
||||
if (user_group.size() > 1)
|
||||
group = user_group[1];
|
||||
|
@ -233,7 +220,7 @@ int main (int argc, char **argv)
|
|||
#endif
|
||||
}
|
||||
|
||||
std::unique_ptr<Controller> controller(new Controller(hostIdValue.getValue(), instance));
|
||||
std::unique_ptr<Controller> controller(new Controller(hostIdValue->value(), instance));
|
||||
if (!g_terminated)
|
||||
{
|
||||
LOG(INFO) << "Latency: " << latency << "\n";
|
||||
|
|
2
externals/aixlog
vendored
2
externals/aixlog
vendored
|
@ -1 +1 @@
|
|||
Subproject commit 85903c3718900a2acac479db60679ae1e09aab28
|
||||
Subproject commit 9c2c1419170dc07807724b8faa5bc73909aa7f57
|
2
externals/popl
vendored
2
externals/popl
vendored
|
@ -1 +1 @@
|
|||
Subproject commit 9504d8e36ca6b069ba40edced6ee9ba2dc41d5cb
|
||||
Subproject commit 5a4878df88238d7712fdf3240996f26a78e207c5
|
|
@ -59,39 +59,23 @@ int main(int argc, char* argv[])
|
|||
std::string pcmStream = "pipe:///tmp/snapfifo?name=default";
|
||||
int processPriority(0);
|
||||
|
||||
Switch helpSwitch("h", "help", "Produce help message");
|
||||
Switch debugSwitch("", "debug", "enable debug logging");
|
||||
Switch versionSwitch("v", "version", "Show version number");
|
||||
Value<size_t> portValue("p", "port", "Server port", settings.port, &settings.port);
|
||||
Value<size_t> controlPortValue("", "controlPort", "Remote control port", settings.controlPort, &settings.controlPort);
|
||||
Value<string> streamValue("s", "stream", "URI of the PCM input stream.\nFormat: TYPE://host/path?name=NAME\n[&codec=CODEC]\n[&sampleformat=SAMPLEFORMAT]", pcmStream, &pcmStream);
|
||||
|
||||
Value<string> sampleFormatValue("", "sampleformat", "Default sample format", settings.sampleFormat);
|
||||
Value<string> codecValue("c", "codec", "Default transport codec\n(flac|ogg|pcm)[:options]\nType codec:? to get codec specific options", settings.codec, &settings.codec);
|
||||
Value<size_t> streamBufferValue("", "streamBuffer", "Default stream read buffer [ms]", settings.streamReadMs, &settings.streamReadMs);
|
||||
|
||||
Value<int> bufferValue("b", "buffer", "Buffer [ms]", settings.bufferMs, &settings.bufferMs);
|
||||
Switch muteSwitch("", "sendToMuted", "Send audio to muted clients", &settings.sendAudioToMutedClients);
|
||||
Implicit<int> daemonOption("d", "daemon", "Daemonize\noptional process priority [-20..19]", 0, &processPriority);
|
||||
Value<string> userValue("", "user", "the user[:group] to run snapserver as when daemonized", "");
|
||||
|
||||
OptionParser op("Allowed options");
|
||||
op.add(helpSwitch)
|
||||
.add(debugSwitch, hidden)
|
||||
.add(versionSwitch)
|
||||
.add(portValue)
|
||||
.add(controlPortValue)
|
||||
.add(streamValue)
|
||||
.add(sampleFormatValue)
|
||||
.add(codecValue)
|
||||
.add(streamBufferValue)
|
||||
.add(bufferValue)
|
||||
.add(muteSwitch)
|
||||
auto helpSwitch = op.add<Switch>("h", "help", "Produce help message");
|
||||
auto debugSwitch = op.add<Switch, Attribute::hidden>("", "debug", "enable debug logging");
|
||||
auto versionSwitch = op.add<Switch>("v", "version", "Show version number");
|
||||
auto portValue = op.add<Value<size_t>>("p", "port", "Server port", settings.port, &settings.port);
|
||||
auto controlPortValue = op.add<Value<size_t>>("", "controlPort", "Remote control port", settings.controlPort, &settings.controlPort);
|
||||
auto streamValue = op.add<Value<string>>("s", "stream", "URI of the PCM input stream.\nFormat: TYPE://host/path?name=NAME\n[&codec=CODEC]\n[&sampleformat=SAMPLEFORMAT]", pcmStream, &pcmStream);
|
||||
|
||||
auto sampleFormatValue = op.add<Value<string>>("", "sampleformat", "Default sample format", settings.sampleFormat);
|
||||
auto codecValue = op.add<Value<string>>("c", "codec", "Default transport codec\n(flac|ogg|pcm)[:options]\nType codec:? to get codec specific options", settings.codec, &settings.codec);
|
||||
auto streamBufferValue = op.add<Value<size_t>>("", "streamBuffer", "Default stream read buffer [ms]", settings.streamReadMs, &settings.streamReadMs);
|
||||
auto bufferValue = op.add<Value<int>>("b", "buffer", "Buffer [ms]", settings.bufferMs, &settings.bufferMs);
|
||||
auto muteSwitch = op.add<Switch>("", "sendToMuted", "Send audio to muted clients", &settings.sendAudioToMutedClients);
|
||||
#ifdef HAS_DAEMON
|
||||
.add(daemonOption)
|
||||
.add(userValue)
|
||||
auto daemonOption = op.add<Implicit<int>>("d", "daemon", "Daemonize\noptional process priority [-20..19]", 0, &processPriority);
|
||||
auto userValue = op.add<Value<string>>("", "user", "the user[:group] to run snapserver as when daemonized", "");
|
||||
#endif
|
||||
;
|
||||
|
||||
try
|
||||
{
|
||||
|
@ -104,7 +88,7 @@ int main(int argc, char* argv[])
|
|||
exit(EXIT_FAILURE);
|
||||
}
|
||||
|
||||
if (versionSwitch.isSet())
|
||||
if (versionSwitch->is_set())
|
||||
{
|
||||
cout << "snapserver v" << VERSION << "\n"
|
||||
<< "Copyright (C) 2014-2017 BadAix (snapcast@badaix.de).\n"
|
||||
|
@ -115,19 +99,19 @@ int main(int argc, char* argv[])
|
|||
exit(EXIT_SUCCESS);
|
||||
}
|
||||
|
||||
if (helpSwitch.isSet())
|
||||
if (helpSwitch->is_set())
|
||||
{
|
||||
cout << op << "\n";
|
||||
exit(EXIT_SUCCESS);
|
||||
}
|
||||
|
||||
if (!streamValue.isSet())
|
||||
settings.pcmStreams.push_back(streamValue.getValue());
|
||||
if (!streamValue->is_set())
|
||||
settings.pcmStreams.push_back(streamValue->value());
|
||||
|
||||
for (size_t n=0; n<streamValue.count(); ++n)
|
||||
for (size_t n=0; n<streamValue->count(); ++n)
|
||||
{
|
||||
cout << streamValue.getValue(n) << "\n";
|
||||
settings.pcmStreams.push_back(streamValue.getValue(n));
|
||||
cout << streamValue->value(n) << "\n";
|
||||
settings.pcmStreams.push_back(streamValue->value(n));
|
||||
}
|
||||
|
||||
if (settings.codec.find(":?") != string::npos)
|
||||
|
@ -145,7 +129,7 @@ int main(int argc, char* argv[])
|
|||
|
||||
AixLog::Log::init(
|
||||
{
|
||||
make_shared<AixLog::SinkCout>(debugSwitch.isSet()?(AixLog::Severity::trace):(AixLog::Severity::info), AixLog::Type::all, debugSwitch.isSet()?"%Y-%m-%d %H-%M-%S.#ms [#severity] (#tag)":"%Y-%m-%d %H-%M-%S [#severity]"),
|
||||
make_shared<AixLog::SinkCout>(debugSwitch->is_set()?(AixLog::Severity::trace):(AixLog::Severity::info), AixLog::Type::all, debugSwitch->is_set()?"%Y-%m-%d %H-%M-%S.#ms [#severity] (#tag)":"%Y-%m-%d %H-%M-%S [#severity]"),
|
||||
make_shared<AixLog::SinkNative>("snapserver", AixLog::Severity::trace, AixLog::Type::special)
|
||||
}
|
||||
);
|
||||
|
@ -156,17 +140,17 @@ int main(int argc, char* argv[])
|
|||
|
||||
#ifdef HAS_DAEMON
|
||||
std::unique_ptr<Daemon> daemon;
|
||||
if (daemonOption.isSet())
|
||||
if (daemonOption->is_set())
|
||||
{
|
||||
string user = "";
|
||||
string group = "";
|
||||
|
||||
if (userValue.isSet())
|
||||
if (userValue->is_set())
|
||||
{
|
||||
if (userValue.getValue().empty())
|
||||
if (userValue->value().empty())
|
||||
std::invalid_argument("user must not be empty");
|
||||
|
||||
vector<string> user_group = utils::string::split(userValue.getValue(), ':');
|
||||
vector<string> user_group = utils::string::split(userValue->value(), ':');
|
||||
user = user_group[0];
|
||||
if (user_group.size() > 1)
|
||||
group = user_group[1];
|
||||
|
@ -193,7 +177,7 @@ int main(int argc, char* argv[])
|
|||
|
||||
if (settings.bufferMs < 400)
|
||||
settings.bufferMs = 400;
|
||||
settings.sampleFormat = sampleFormatValue.getValue();
|
||||
settings.sampleFormat = sampleFormatValue->value();
|
||||
|
||||
asio::io_service io_service;
|
||||
std::unique_ptr<StreamServer> streamServer(new StreamServer(&io_service, settings));
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue