event/Call, ...: use wait() with predicate

This commit is contained in:
Max Kellermann
2019-05-07 20:01:45 +02:00
parent 72fc117393
commit 973c87b351
12 changed files with 20 additions and 35 deletions
+1 -2
View File
@@ -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;
+4 -5
View File
@@ -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