mirror of
https://github.com/badaix/snapcast.git
synced 2025-07-19 01:18:17 +02:00
configurable number of threads
This commit is contained in:
parent
c58f66a87a
commit
4022e59018
1 changed files with 8 additions and 2 deletions
|
@ -80,6 +80,8 @@ int main(int argc, char* argv[])
|
||||||
auto streamValue = conf.add<Value<string>>(
|
auto streamValue = conf.add<Value<string>>(
|
||||||
"s", "stream.stream", "URI of the PCM input stream.\nFormat: TYPE://host/path?name=NAME\n[&codec=CODEC]\n[&sampleformat=SAMPLEFORMAT]", pcmStream,
|
"s", "stream.stream", "URI of the PCM input stream.\nFormat: TYPE://host/path?name=NAME\n[&codec=CODEC]\n[&sampleformat=SAMPLEFORMAT]", pcmStream,
|
||||||
&pcmStream);
|
&pcmStream);
|
||||||
|
size_t num_threads = 2;
|
||||||
|
conf.add<Value<size_t>>("", "stream.threads", "number of streaming threads", num_threads, &num_threads);
|
||||||
|
|
||||||
conf.add<Value<string>>("", "stream.sampleformat", "Default sample format", settings.stream.sampleFormat, &settings.stream.sampleFormat);
|
conf.add<Value<string>>("", "stream.sampleformat", "Default sample format", settings.stream.sampleFormat, &settings.stream.sampleFormat);
|
||||||
conf.add<Value<string>>("c", "stream.codec", "Default transport codec\n(flac|ogg|pcm)[:options]\nType codec:? to get codec specific options",
|
conf.add<Value<string>>("c", "stream.codec", "Default transport codec\n(flac|ogg|pcm)[:options]\nType codec:? to get codec specific options",
|
||||||
|
@ -261,11 +263,15 @@ int main(int argc, char* argv[])
|
||||||
std::unique_ptr<StreamServer> streamServer(new StreamServer(io_context, settings));
|
std::unique_ptr<StreamServer> streamServer(new StreamServer(io_context, settings));
|
||||||
streamServer->start();
|
streamServer->start();
|
||||||
|
|
||||||
std::thread t([&] { io_context.run(); });
|
LOG(DEBUG) << "number of threads: " << num_threads << ", hw threads: " << std::thread::hardware_concurrency() << "\n";
|
||||||
|
std::vector<std::thread> threads;
|
||||||
|
for (auto n = 0; n < num_threads; ++n)
|
||||||
|
threads.emplace_back([&] { io_context.run(); });
|
||||||
|
|
||||||
auto sig = install_signal_handler({SIGHUP, SIGTERM, SIGINT}).get();
|
auto sig = install_signal_handler({SIGHUP, SIGTERM, SIGINT}).get();
|
||||||
SLOG(INFO) << "Received signal " << sig << ": " << strsignal(sig) << "\n";
|
SLOG(INFO) << "Received signal " << sig << ": " << strsignal(sig) << "\n";
|
||||||
io_context.stop();
|
io_context.stop();
|
||||||
|
for (auto& t : threads)
|
||||||
t.join();
|
t.join();
|
||||||
|
|
||||||
LOG(INFO) << "Stopping streamServer" << endl;
|
LOG(INFO) << "Stopping streamServer" << endl;
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue