mirror of
https://github.com/badaix/snapcast.git
synced 2025-04-29 18:27:12 +02:00
Terminate script
This commit is contained in:
parent
c01ba2bdde
commit
63de108800
2 changed files with 9 additions and 2 deletions
|
@ -257,8 +257,8 @@ void PcmStream::setState(ReaderState newState)
|
||||||
void PcmStream::chunkEncoded(const encoder::Encoder& encoder, std::shared_ptr<msg::PcmChunk> chunk, double duration)
|
void PcmStream::chunkEncoded(const encoder::Encoder& encoder, std::shared_ptr<msg::PcmChunk> chunk, double duration)
|
||||||
{
|
{
|
||||||
std::ignore = encoder;
|
std::ignore = encoder;
|
||||||
// LOG(TRACE, LOG_TAG) << "onChunkEncoded: " << getName() << ", duration: " << duration << " ms, compression ratio: " << 100 - ceil(100 *
|
// LOG(TRACE, LOG_TAG) << "onChunkEncoded: " << getName() << ", duration: " << duration
|
||||||
// (chunk->durationMs() / duration)) << "%\n";
|
// << " ms, compression ratio: " << 100 - ceil(100 * (chunk->durationMs() / duration)) << "%\n";
|
||||||
if (duration <= 0)
|
if (duration <= 0)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
|
|
|
@ -253,7 +253,14 @@ void ScriptStreamControl::stop()
|
||||||
{
|
{
|
||||||
if (process_.running())
|
if (process_.running())
|
||||||
{
|
{
|
||||||
|
LOG(INFO, LOG_TAG) << "Stopping script '" << script_ << "'\n";
|
||||||
::kill(-process_.native_handle(), SIGINT);
|
::kill(-process_.native_handle(), SIGINT);
|
||||||
|
auto timeout = 500ms;
|
||||||
|
if (!process_.wait_for(timeout))
|
||||||
|
{
|
||||||
|
LOG(INFO, LOG_TAG) << "Script did not terminate after " << timeout.count() << " ms, terminating.\n";
|
||||||
|
process_.terminate();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Add table
Reference in a new issue