mirror of
https://github.com/badaix/snapcast.git
synced 2025-06-12 07:41:47 +02:00
fixed deadlock in server shutdown
This commit is contained in:
parent
341466ceb5
commit
935899b0a2
5 changed files with 35 additions and 23 deletions
|
@ -88,7 +88,8 @@ void PipeStream::worker()
|
|||
if (count < 0)
|
||||
{
|
||||
setState(kIdle);
|
||||
chronos::sleep(100);
|
||||
if (!sleep(100))
|
||||
break;
|
||||
}
|
||||
else if (count == 0)
|
||||
throw SnapException("end of file");
|
||||
|
@ -97,10 +98,12 @@ void PipeStream::worker()
|
|||
}
|
||||
while ((len < toRead) && active_);
|
||||
|
||||
if (!active_)
|
||||
break;
|
||||
if (!active_) break;
|
||||
|
||||
encoder_->encode(chunk.get());
|
||||
|
||||
if (!active_) break;
|
||||
|
||||
nextTick += pcmReadMs_;
|
||||
chronos::addUs(tvChunk, pcmReadMs_ * 1000);
|
||||
long currentTick = chronos::getTickCount();
|
||||
|
@ -108,7 +111,8 @@ void PipeStream::worker()
|
|||
if (nextTick >= currentTick)
|
||||
{
|
||||
setState(kPlaying);
|
||||
chronos::sleep(nextTick - currentTick);
|
||||
if (!sleep(nextTick - currentTick))
|
||||
break;
|
||||
}
|
||||
else
|
||||
{
|
||||
|
@ -122,7 +126,8 @@ void PipeStream::worker()
|
|||
catch(const std::exception& e)
|
||||
{
|
||||
logE << "(PipeStream) Exception: " << e.what() << std::endl;
|
||||
chronos::sleep(100);
|
||||
if (!sleep(100))
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue