Fix logic error in encoder wait_idle

This commit is contained in:
Patrick Nicolas
2024-09-07 18:17:27 +02:00
parent 28c93c3fb8
commit d68bbb4e72
+9 -10
View File
@@ -46,22 +46,21 @@ VideoEncoder::sender::sender() :
thread([this](std::stop_token t) {
while (not t.stop_requested())
{
data d;
data * d = nullptr;
{
std::unique_lock lock(mutex);
if (pending.empty())
{
cv.wait_for(lock, std::chrono::milliseconds(100));
}
else
{
d = std::move(pending.front());
pending.pop_front();
cv.notify_all();
}
d = &pending.front();
}
if (d and not d->span.empty())
{
d->encoder->SendData(d->span, true);
std::unique_lock lock(mutex);
pending.pop_front();
cv.notify_all();
}
if (not d.span.empty())
d.encoder->SendData(d.span, true);
}
std::unique_lock lock(mutex);
pending.clear();