thread/Cond: add wait() overload which takes a unique_lock<>
Just like std::condition_variable, which however has no way to specify the std::mutex directly.
This commit is contained in:
@@ -796,7 +796,7 @@ AlsaOutput::DrainInternal()
|
||||
void
|
||||
AlsaOutput::Drain()
|
||||
{
|
||||
const std::lock_guard<Mutex> lock(mutex);
|
||||
std::unique_lock<Mutex> lock(mutex);
|
||||
|
||||
if (error)
|
||||
std::rethrow_exception(error);
|
||||
@@ -806,7 +806,7 @@ AlsaOutput::Drain()
|
||||
Activate();
|
||||
|
||||
while (drain && active)
|
||||
cond.wait(mutex);
|
||||
cond.wait(lock);
|
||||
|
||||
if (error)
|
||||
std::rethrow_exception(error);
|
||||
@@ -882,7 +882,7 @@ AlsaOutput::Play(const void *chunk, size_t size)
|
||||
been played */
|
||||
return size;
|
||||
|
||||
const std::lock_guard<Mutex> lock(mutex);
|
||||
std::unique_lock<Mutex> lock(mutex);
|
||||
|
||||
while (true) {
|
||||
if (error)
|
||||
@@ -905,7 +905,7 @@ AlsaOutput::Play(const void *chunk, size_t size)
|
||||
|
||||
/* wait for the DispatchSockets() to make room in the
|
||||
ring_buffer */
|
||||
cond.wait(mutex);
|
||||
cond.wait(lock);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -277,9 +277,9 @@ HttpdOutput::BroadcastFromEncoder()
|
||||
{
|
||||
/* synchronize with the IOThread */
|
||||
{
|
||||
const std::lock_guard<Mutex> lock(mutex);
|
||||
std::unique_lock<Mutex> lock(mutex);
|
||||
while (!pages.empty())
|
||||
cond.wait(mutex);
|
||||
cond.wait(lock);
|
||||
}
|
||||
|
||||
bool empty = true;
|
||||
|
||||
@@ -317,13 +317,13 @@ SlesOutput::Play(const void *chunk, size_t size)
|
||||
pause = false;
|
||||
}
|
||||
|
||||
const std::lock_guard<Mutex> protect(mutex);
|
||||
std::unique_lock<Mutex> lock(mutex);
|
||||
|
||||
assert(filled < BUFFER_SIZE);
|
||||
|
||||
while (n_queued == N_BUFFERS) {
|
||||
assert(filled == 0);
|
||||
cond.wait(mutex);
|
||||
cond.wait(lock);
|
||||
}
|
||||
|
||||
size_t nbytes = std::min(BUFFER_SIZE - filled, size);
|
||||
@@ -346,12 +346,12 @@ SlesOutput::Play(const void *chunk, size_t size)
|
||||
void
|
||||
SlesOutput::Drain()
|
||||
{
|
||||
const std::lock_guard<Mutex> protect(mutex);
|
||||
std::unique_lock<Mutex> lock(mutex);
|
||||
|
||||
assert(filled < BUFFER_SIZE);
|
||||
|
||||
while (n_queued > 0)
|
||||
cond.wait(mutex);
|
||||
cond.wait(lock);
|
||||
}
|
||||
|
||||
void
|
||||
|
||||
Reference in New Issue
Block a user