mirror of
https://github.com/badaix/snapcast.git
synced 2025-07-26 12:58:47 +02:00
cleaned up locking
This commit is contained in:
parent
3819fb2355
commit
bc1d96ef89
6 changed files with 44 additions and 37 deletions
|
@ -76,19 +76,13 @@ void Stream::addChunk(msg::PcmChunk* chunk)
|
|||
while (chunks_.size() * chunk->duration<cs::msec>().count() > 10000)
|
||||
chunks_.pop();
|
||||
chunks_.push(shared_ptr<msg::PcmChunk>(chunk));
|
||||
std::unique_lock<std::mutex> lck(cvMutex_);
|
||||
cv_.notify_one();
|
||||
// logD << "new chunk: " << chunk->duration<cs::msec>().count() << ", Chunks: " << chunks_.size() << "\n";
|
||||
}
|
||||
|
||||
|
||||
bool Stream::waitForChunk(size_t ms) const
|
||||
{
|
||||
if (!chunks_.empty())
|
||||
return true;
|
||||
|
||||
std::unique_lock<std::mutex> lck(cvMutex_);
|
||||
return (cv_.wait_for(lck, std::chrono::milliseconds(ms), [this] { return !chunks_.empty(); }));
|
||||
return chunks_.wait_for(std::chrono::milliseconds(ms));
|
||||
}
|
||||
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue