fix comp_target deletion (again)
This commit is contained in:
@@ -798,8 +798,8 @@ wivrn_comp_target::~wivrn_comp_target()
|
|||||||
static void comp_wivrn_destroy(struct comp_target * ct)
|
static void comp_wivrn_destroy(struct comp_target * ct)
|
||||||
{
|
{
|
||||||
auto cn = (struct wivrn_comp_target *)ct;
|
auto cn = (struct wivrn_comp_target *)ct;
|
||||||
destroy_images(cn);
|
cn->cnx.unset_comp_target();
|
||||||
cn->self = nullptr;
|
delete cn;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void comp_wivrn_info_gpu(struct comp_target * ct, int64_t frame_id, int64_t gpu_start_ns, int64_t gpu_end_ns, int64_t when_ns)
|
static void comp_wivrn_info_gpu(struct comp_target * ct, int64_t frame_id, int64_t gpu_start_ns, int64_t gpu_end_ns, int64_t when_ns)
|
||||||
|
|||||||
@@ -78,7 +78,6 @@ struct pseudo_swapchain
|
|||||||
|
|
||||||
struct wivrn_comp_target : public comp_target
|
struct wivrn_comp_target : public comp_target
|
||||||
{
|
{
|
||||||
std::shared_ptr<wivrn_comp_target> self;
|
|
||||||
to_headset::video_stream_description desc{};
|
to_headset::video_stream_description desc{};
|
||||||
wivrn_pacer pacer;
|
wivrn_pacer pacer;
|
||||||
|
|
||||||
|
|||||||
@@ -89,9 +89,8 @@ struct wivrn_comp_target_factory : public comp_target_factory
|
|||||||
static bool create_target(const struct comp_target_factory * ctf, struct comp_compositor * c, struct comp_target ** out_ct)
|
static bool create_target(const struct comp_target_factory * ctf, struct comp_compositor * c, struct comp_target ** out_ct)
|
||||||
{
|
{
|
||||||
auto self = (wivrn_comp_target_factory *)ctf;
|
auto self = (wivrn_comp_target_factory *)ctf;
|
||||||
self->session.comp_target = std::make_shared<wivrn_comp_target>(self->session, c);
|
self->session.comp_target = new wivrn_comp_target(self->session, c);
|
||||||
self->session.comp_target->self = self->session.comp_target;
|
*out_ct = self->session.comp_target;
|
||||||
*out_ct = self->session.comp_target.get();
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
@@ -336,6 +335,12 @@ bool wivrn_session::connected()
|
|||||||
return connection->is_active();
|
return connection->is_active();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void wivrn_session::unset_comp_target()
|
||||||
|
{
|
||||||
|
std::lock_guard lock(comp_target_mutex);
|
||||||
|
comp_target = nullptr;
|
||||||
|
}
|
||||||
|
|
||||||
void wivrn_session::operator()(from_headset::headset_info_packet &&)
|
void wivrn_session::operator()(from_headset::headset_info_packet &&)
|
||||||
{
|
{
|
||||||
U_LOG_W("unexpected headset info packet, ignoring");
|
U_LOG_W("unexpected headset info packet, ignoring");
|
||||||
@@ -429,9 +434,11 @@ void wivrn_session::operator()(const from_headset::tracking & tracking)
|
|||||||
right_hand.update_tracking(tracking, offset);
|
right_hand.update_tracking(tracking, offset);
|
||||||
if (eye_tracker)
|
if (eye_tracker)
|
||||||
eye_tracker->update_tracking(tracking, offset);
|
eye_tracker->update_tracking(tracking, offset);
|
||||||
assert(comp_target);
|
{
|
||||||
assert(comp_target->foveation);
|
std::shared_lock lock(comp_target_mutex);
|
||||||
comp_target->foveation->update_tracking(tracking, offset);
|
if (comp_target)
|
||||||
|
comp_target->foveation->update_tracking(tracking, offset);
|
||||||
|
}
|
||||||
|
|
||||||
if (fb_face2_tracker)
|
if (fb_face2_tracker)
|
||||||
fb_face2_tracker->update_tracking(tracking, offset);
|
fb_face2_tracker->update_tracking(tracking, offset);
|
||||||
@@ -522,11 +529,14 @@ void wivrn_session::set_tracker_enabled(int index, bool enabled)
|
|||||||
|
|
||||||
void wivrn_session::operator()(from_headset::feedback && feedback)
|
void wivrn_session::operator()(from_headset::feedback && feedback)
|
||||||
{
|
{
|
||||||
assert(comp_target);
|
|
||||||
clock_offset o = offset_est.get_offset();
|
clock_offset o = offset_est.get_offset();
|
||||||
if (not o)
|
if (not o)
|
||||||
return;
|
return;
|
||||||
comp_target->on_feedback(feedback, o);
|
{
|
||||||
|
std::shared_lock lock(comp_target_mutex);
|
||||||
|
if (comp_target)
|
||||||
|
comp_target->on_feedback(feedback, o);
|
||||||
|
}
|
||||||
|
|
||||||
if (feedback.received_first_packet)
|
if (feedback.received_first_packet)
|
||||||
dump_time("receive_begin", feedback.frame_index, o.from_headset(feedback.received_first_packet), feedback.stream_index);
|
dump_time("receive_begin", feedback.frame_index, o.from_headset(feedback.received_first_packet), feedback.stream_index);
|
||||||
@@ -561,7 +571,11 @@ void wivrn_session::operator()(from_headset::visibility_mask_changed && mask)
|
|||||||
|
|
||||||
void wivrn_session::operator()(from_headset::refresh_rate_changed && event)
|
void wivrn_session::operator()(from_headset::refresh_rate_changed && event)
|
||||||
{
|
{
|
||||||
comp_target->set_refresh_rate(event.to);
|
{
|
||||||
|
std::shared_lock lock(comp_target_mutex);
|
||||||
|
if (comp_target)
|
||||||
|
comp_target->set_refresh_rate(event.to);
|
||||||
|
}
|
||||||
push_event(
|
push_event(
|
||||||
{
|
{
|
||||||
.display = {
|
.display = {
|
||||||
@@ -585,7 +599,9 @@ void wivrn_session::operator()(to_monado::disconnect &&)
|
|||||||
|
|
||||||
void wivrn_session::operator()(to_monado::set_bitrate && data)
|
void wivrn_session::operator()(to_monado::set_bitrate && data)
|
||||||
{
|
{
|
||||||
comp_target->set_bitrate(data.bitrate_bps);
|
std::shared_lock lock(comp_target_mutex);
|
||||||
|
if (comp_target)
|
||||||
|
comp_target->set_bitrate(data.bitrate_bps);
|
||||||
}
|
}
|
||||||
|
|
||||||
struct refresh_rate_adjuster
|
struct refresh_rate_adjuster
|
||||||
@@ -645,8 +661,14 @@ void wivrn_session::run(std::stop_token stop)
|
|||||||
{
|
{
|
||||||
offset_est.request_sample(*connection);
|
offset_est.request_sample(*connection);
|
||||||
tracking_control.send(*connection);
|
tracking_control.send(*connection);
|
||||||
if (comp_target->requested_refresh_rate == 0)
|
{
|
||||||
refresh.adjust(*connection);
|
std::shared_lock lock(comp_target_mutex);
|
||||||
|
if (comp_target)
|
||||||
|
{
|
||||||
|
if (comp_target->requested_refresh_rate == 0)
|
||||||
|
refresh.adjust(*connection);
|
||||||
|
}
|
||||||
|
}
|
||||||
connection->poll(*this, 20);
|
connection->poll(*this, 20);
|
||||||
}
|
}
|
||||||
catch (const std::exception & e)
|
catch (const std::exception & e)
|
||||||
@@ -723,7 +745,11 @@ void wivrn_session::reconnect()
|
|||||||
// const auto & info = connection->info();
|
// const auto & info = connection->info();
|
||||||
// FIXME: ensure new client is compatible
|
// FIXME: ensure new client is compatible
|
||||||
|
|
||||||
comp_target->reset_encoders();
|
{
|
||||||
|
std::shared_lock lock(comp_target_mutex);
|
||||||
|
if (comp_target)
|
||||||
|
comp_target->reset_encoders();
|
||||||
|
}
|
||||||
if (audio_handle)
|
if (audio_handle)
|
||||||
send_control(audio_handle->description());
|
send_control(audio_handle->description());
|
||||||
|
|
||||||
|
|||||||
@@ -32,8 +32,8 @@
|
|||||||
#include <fstream>
|
#include <fstream>
|
||||||
#include <memory>
|
#include <memory>
|
||||||
#include <mutex>
|
#include <mutex>
|
||||||
|
#include <shared_mutex>
|
||||||
#include <thread>
|
#include <thread>
|
||||||
#include <vector>
|
|
||||||
|
|
||||||
struct u_system;
|
struct u_system;
|
||||||
struct xrt_space_overseer;
|
struct xrt_space_overseer;
|
||||||
@@ -113,7 +113,9 @@ class wivrn_session : public xrt_system_devices
|
|||||||
uint32_t num_generic_trackers;
|
uint32_t num_generic_trackers;
|
||||||
std::array<std::unique_ptr<wivrn_generic_tracker>, from_headset::body_tracking::max_tracked_poses> generic_trackers;
|
std::array<std::unique_ptr<wivrn_generic_tracker>, from_headset::body_tracking::max_tracked_poses> generic_trackers;
|
||||||
std::array<bool, from_headset::body_tracking::max_tracked_poses> enabled_trackers;
|
std::array<bool, from_headset::body_tracking::max_tracked_poses> enabled_trackers;
|
||||||
std::shared_ptr<wivrn_comp_target> comp_target;
|
|
||||||
|
std::shared_mutex comp_target_mutex;
|
||||||
|
wivrn_comp_target * comp_target;
|
||||||
|
|
||||||
clock_offset_estimator offset_est;
|
clock_offset_estimator offset_est;
|
||||||
|
|
||||||
@@ -146,6 +148,8 @@ public:
|
|||||||
return connection->info();
|
return connection->info();
|
||||||
};
|
};
|
||||||
|
|
||||||
|
void unset_comp_target();
|
||||||
|
|
||||||
wivrn_hmd & get_hmd()
|
wivrn_hmd & get_hmd()
|
||||||
{
|
{
|
||||||
return hmd;
|
return hmd;
|
||||||
|
|||||||
Reference in New Issue
Block a user