Deactivate connection on socket error

This commit is contained in:
Patrick Nicolas
2024-06-03 20:59:06 +02:00
parent 5d9d39eee5
commit 1266a46947
4 changed files with 33 additions and 9 deletions
+3
View File
@@ -260,6 +260,9 @@ static bool comp_wivrn_init_post_vulkan(struct comp_target * ct, uint32_t prefer
static bool comp_wivrn_check_ready(struct comp_target * ct)
{
struct wivrn_comp_target * cn = (struct wivrn_comp_target *)ct;
if (not cn->cnx->connected())
return false;
// This function is called before on each frame before reprojection
// hijack it so that we can dynamically change ATW
cn->c->debug.atw_off = true;
+24 -8
View File
@@ -39,25 +39,41 @@ public:
wivrn_connection(const wivrn_connection &) = delete;
wivrn_connection & operator=(const wivrn_connection &) = delete;
void deactivate()
bool is_active()
{
active = false;
return active;
}
void reset(TCP && tcp);
template <typename T>
void send_control(T && packet)
{
if (active)
control.send(std::forward<T>(packet));
try
{
if (active)
control.send(std::forward<T>(packet));
}
catch (...)
{
active = false;
throw;
}
}
template <typename T>
void send_stream(T && packet)
{
if (active and stream)
stream.send(std::forward<T>(packet));
else
control.send(std::forward<T>(packet));
try
{
if (active and stream)
stream.send(std::forward<T>(packet));
else
control.send(std::forward<T>(packet));
}
catch (...)
{
active = false;
throw;
}
}
std::optional<from_headset::packets> poll_control(int timeout);
+5 -1
View File
@@ -192,6 +192,11 @@ clock_offset wivrn_session::get_offset()
return offset_est.get_offset();
}
bool wivrn_session::connected()
{
return connection.is_active();
}
void wivrn_session::operator()(from_headset::headset_info_packet &&)
{
U_LOG_W("unexpected headset info packet, ignoring");
@@ -281,7 +286,6 @@ void wivrn_session::run(std::weak_ptr<wivrn_session> weak_self)
auto self = weak_self.lock();
if (self)
{
self->connection.deactivate();
xrt_session_event event{
.state = {
.type = XRT_SESSION_EVENT_STATE_CHANGE,
+1
View File
@@ -97,6 +97,7 @@ public:
xrt_system_compositor ** out_xsysc);
clock_offset get_offset();
bool connected();
void add_predict_offset(std::chrono::nanoseconds off)
{