Fix encoders waiting on other's network send
This commit is contained in:
@@ -57,8 +57,7 @@ VideoEncoder::sender::sender() :
|
|||||||
{
|
{
|
||||||
d = std::move(pending.front());
|
d = std::move(pending.front());
|
||||||
pending.pop_front();
|
pending.pop_front();
|
||||||
if (pending.empty())
|
cv.notify_all();
|
||||||
cv.notify_all();
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (not d.span.empty())
|
if (not d.span.empty())
|
||||||
@@ -78,10 +77,10 @@ void VideoEncoder::sender::push(data && d)
|
|||||||
cv.notify_all();
|
cv.notify_all();
|
||||||
}
|
}
|
||||||
|
|
||||||
void VideoEncoder::sender::wait_idle()
|
void VideoEncoder::sender::wait_idle(VideoEncoder * encoder)
|
||||||
{
|
{
|
||||||
std::unique_lock lock(mutex);
|
std::unique_lock lock(mutex);
|
||||||
while (not pending.empty())
|
while (std::ranges::any_of(pending, [=](auto & data) { return data.encoder == encoder; }))
|
||||||
cv.wait_for(lock, std::chrono::milliseconds(100));
|
cv.wait_for(lock, std::chrono::milliseconds(100));
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -159,7 +158,7 @@ VideoEncoder::VideoEncoder(bool async_send) :
|
|||||||
VideoEncoder::~VideoEncoder()
|
VideoEncoder::~VideoEncoder()
|
||||||
{
|
{
|
||||||
if (shared_sender)
|
if (shared_sender)
|
||||||
shared_sender->wait_idle();
|
shared_sender->wait_idle(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
void VideoEncoder::SyncNeeded()
|
void VideoEncoder::SyncNeeded()
|
||||||
@@ -172,7 +171,7 @@ void VideoEncoder::Encode(wivrn_session & cnx,
|
|||||||
uint64_t frame_index)
|
uint64_t frame_index)
|
||||||
{
|
{
|
||||||
if (shared_sender)
|
if (shared_sender)
|
||||||
shared_sender->wait_idle();
|
shared_sender->wait_idle(this);
|
||||||
this->cnx = &cnx;
|
this->cnx = &cnx;
|
||||||
auto target_timestamp = std::chrono::steady_clock::time_point(std::chrono::nanoseconds(view_info.display_time));
|
auto target_timestamp = std::chrono::steady_clock::time_point(std::chrono::nanoseconds(view_info.display_time));
|
||||||
bool idr = sync_needed.exchange(false);
|
bool idr = sync_needed.exchange(false);
|
||||||
|
|||||||
@@ -68,7 +68,7 @@ private:
|
|||||||
public:
|
public:
|
||||||
void push(data &&);
|
void push(data &&);
|
||||||
static std::shared_ptr<sender> get();
|
static std::shared_ptr<sender> get();
|
||||||
void wait_idle();
|
void wait_idle(VideoEncoder *);
|
||||||
};
|
};
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
|
|||||||
Reference in New Issue
Block a user