event/Call, ...: use wait() with predicate
This commit is contained in:
@@ -805,8 +805,7 @@ AlsaOutput::Drain()
|
||||
|
||||
Activate();
|
||||
|
||||
while (drain && active)
|
||||
cond.wait(lock);
|
||||
cond.wait(lock, [this]{ return !drain || !active; });
|
||||
|
||||
if (error)
|
||||
std::rethrow_exception(error);
|
||||
|
||||
@@ -278,8 +278,7 @@ HttpdOutput::BroadcastFromEncoder()
|
||||
/* synchronize with the IOThread */
|
||||
{
|
||||
std::unique_lock<Mutex> lock(mutex);
|
||||
while (!pages.empty())
|
||||
cond.wait(lock);
|
||||
cond.wait(lock, [this]{ return pages.empty(); });
|
||||
}
|
||||
|
||||
bool empty = true;
|
||||
|
||||
@@ -321,10 +321,10 @@ SlesOutput::Play(const void *chunk, size_t size)
|
||||
|
||||
assert(filled < BUFFER_SIZE);
|
||||
|
||||
while (n_queued == N_BUFFERS) {
|
||||
cond.wait(lock, [this]{
|
||||
assert(filled == 0);
|
||||
cond.wait(lock);
|
||||
}
|
||||
return n_queued != N_BUFFERS;
|
||||
});
|
||||
|
||||
size_t nbytes = std::min(BUFFER_SIZE - filled, size);
|
||||
memcpy(buffers[next] + filled, chunk, nbytes);
|
||||
@@ -350,8 +350,7 @@ SlesOutput::Drain()
|
||||
|
||||
assert(filled < BUFFER_SIZE);
|
||||
|
||||
while (n_queued > 0)
|
||||
cond.wait(lock);
|
||||
cond.wait(lock, [this]{ return n_queued == 0; });
|
||||
}
|
||||
|
||||
void
|
||||
|
||||
Reference in New Issue
Block a user