xrt: Pass down broadcast sink to prober and builder when creating system

This commit is contained in:
Jakob Bornecrantz 2023-12-12 13:17:17 +00:00
parent 7017e5ed2d
commit 21f7ce976e
10 changed files with 46 additions and 8 deletions

View file

@ -186,6 +186,7 @@ xrt_result_t
u_builder_roles_helper_open_system(struct xrt_builder *xb,
cJSON *config,
struct xrt_prober *xp,
struct xrt_session_event_sink *broadcast,
struct xrt_system_devices **out_xsysd,
struct xrt_space_overseer **out_xso,
u_builder_open_system_fn fn)
@ -246,6 +247,7 @@ xrt_result_t
u_builder_open_system_static_roles(struct xrt_builder *xb,
cJSON *config,
struct xrt_prober *xp,
struct xrt_session_event_sink *broadcast,
struct xrt_system_devices **out_xsysd,
struct xrt_space_overseer **out_xso)
{
@ -255,6 +257,7 @@ u_builder_open_system_static_roles(struct xrt_builder *xb,
xb, //
config, //
xp, //
broadcast, //
out_xsysd, //
out_xso, //
ub->open_system_static_roles); //

View file

@ -189,6 +189,7 @@ xrt_result_t
u_builder_roles_helper_open_system(struct xrt_builder *xb,
cJSON *config,
struct xrt_prober *xp,
struct xrt_session_event_sink *broadcast,
struct xrt_system_devices **out_xsysd,
struct xrt_space_overseer **out_xso,
u_builder_open_system_fn fn);
@ -208,6 +209,7 @@ xrt_result_t
u_builder_open_system_static_roles(struct xrt_builder *xb,
cJSON *config,
struct xrt_prober *xp,
struct xrt_session_event_sink *broadcast,
struct xrt_system_devices **out_xsysd,
struct xrt_space_overseer **out_xso);

View file

@ -151,6 +151,7 @@ u_system_devices_static_finalize(struct u_system_devices_static *usysds,
xrt_result_t
u_system_devices_create_from_prober(struct xrt_instance *xinst,
struct xrt_session_event_sink *broadcast,
struct xrt_system_devices **out_xsysd,
struct xrt_space_overseer **out_xso)
{
@ -175,7 +176,7 @@ u_system_devices_create_from_prober(struct xrt_instance *xinst,
return xret;
}
return xrt_prober_create_system(xp, out_xsysd, out_xso);
return xrt_prober_create_system(xp, broadcast, out_xsysd, out_xso);
}
struct xrt_device *

View file

@ -20,6 +20,8 @@
extern "C" {
#endif
struct xrt_session_event_sink;
/*!
* Helper struct to manage devices by implementing the @ref xrt_system_devices.
@ -160,6 +162,7 @@ u_system_devices_static_finalize(struct u_system_devices_static *usysds,
*/
xrt_result_t
u_system_devices_create_from_prober(struct xrt_instance *xinst,
struct xrt_session_event_sink *broadcast,
struct xrt_system_devices **out_xsysd,
struct xrt_space_overseer **out_xso);

View file

@ -36,6 +36,7 @@ struct xrt_tracking_factory;
struct xrt_builder;
struct xrt_system_devices;
struct xrt_space_overseer;
struct xrt_session_event_sink;
struct os_hid_device;
/*!
@ -181,12 +182,14 @@ struct xrt_prober
* Create system devices.
*
* @param[in] xp Prober self parameter.
* @param[in] broadcast Event sink that broadcasts events to all sessions.
* @param[out] out_xsysd Return of system devices, the pointed pointer must be NULL.
* @param[out] out_xso Return of the @ref xrt_space_overseer, the pointed pointer must be NULL.
*
* @note Code consuming this interface should use xrt_prober_create_system()
*/
xrt_result_t (*create_system)(struct xrt_prober *xp,
struct xrt_session_event_sink *broadcast,
struct xrt_system_devices **out_xsysd,
struct xrt_space_overseer **out_xso);
@ -369,10 +372,11 @@ xrt_prober_dump(struct xrt_prober *xp)
*/
static inline xrt_result_t
xrt_prober_create_system(struct xrt_prober *xp,
struct xrt_session_event_sink *broadcast,
struct xrt_system_devices **out_xsysd,
struct xrt_space_overseer **out_xso)
{
return xp->create_system(xp, out_xsysd, out_xso);
return xp->create_system(xp, broadcast, out_xsysd, out_xso);
}
/*!
@ -582,6 +586,7 @@ struct xrt_builder
* @param[in] xb Builder self parameter.
* @param[in] xp Prober
* @param[in] config JSON config object if found for this setter upper.
* @param[in] broadcast Event sink that broadcasts events to all sessions.
* @param[out] out_xsysd Return of system devices, the pointed pointer must be NULL.
* @param[out] out_xso Return of the @ref xrt_space_overseer, the pointed pointer must be NULL.
*
@ -590,6 +595,7 @@ struct xrt_builder
xrt_result_t (*open_system)(struct xrt_builder *xb,
cJSON *config,
struct xrt_prober *xp,
struct xrt_session_event_sink *broadcast,
struct xrt_system_devices **out_xsysd,
struct xrt_space_overseer **out_xso);
@ -628,10 +634,11 @@ static inline xrt_result_t
xrt_builder_open_system(struct xrt_builder *xb,
cJSON *config,
struct xrt_prober *xp,
struct xrt_session_event_sink *broadcast,
struct xrt_system_devices **out_xsysd,
struct xrt_space_overseer **out_xso)
{
return xb->open_system(xb, config, xp, out_xsysd, out_xso);
return xb->open_system(xb, config, xp, broadcast, out_xsysd, out_xso);
}
/*!

View file

@ -89,7 +89,10 @@ static int
p_dump(struct xrt_prober *xp);
static xrt_result_t
p_create_system(struct xrt_prober *xp, struct xrt_system_devices **out_xsysd, struct xrt_space_overseer **out_xso);
p_create_system(struct xrt_prober *xp,
struct xrt_session_event_sink *broadcast,
struct xrt_system_devices **out_xsysd,
struct xrt_space_overseer **out_xso);
static int
p_select_device(struct xrt_prober *xp, struct xrt_device **xdevs, size_t xdev_count);
@ -972,7 +975,10 @@ p_dump(struct xrt_prober *xp)
}
static xrt_result_t
p_create_system(struct xrt_prober *xp, struct xrt_system_devices **out_xsysd, struct xrt_space_overseer **out_xso)
p_create_system(struct xrt_prober *xp,
struct xrt_session_event_sink *broadcast,
struct xrt_system_devices **out_xsysd,
struct xrt_space_overseer **out_xso)
{
XRT_TRACE_MARKER();
@ -1070,7 +1076,13 @@ p_create_system(struct xrt_prober *xp, struct xrt_system_devices **out_xsysd, st
if (select != NULL) {
u_pp(dg, "\n\tUsing builder %s: %s", select->identifier, select->name);
xret = xrt_builder_open_system(select, p->json.root, xp, out_xsysd, out_xso);
xret = xrt_builder_open_system( //
select, //
p->json.root, //
xp, //
broadcast, //
out_xsysd, //
out_xso); //
if (xret == XRT_SUCCESS) {
print_system_devices(dg, *out_xsysd);

View file

@ -75,6 +75,7 @@ static xrt_result_t
remote_open_system(struct xrt_builder *xb,
cJSON *config,
struct xrt_prober *xp,
struct xrt_session_event_sink *broadcast,
struct xrt_system_devices **out_xsysd,
struct xrt_space_overseer **out_xso)
{

View file

@ -97,6 +97,7 @@ static xrt_result_t
steamvr_open_system(struct xrt_builder *xb,
cJSON *config,
struct xrt_prober *xp,
struct xrt_session_event_sink *broadcast,
struct xrt_system_devices **out_xsysd,
struct xrt_space_overseer **out_xso)
{

View file

@ -71,7 +71,11 @@ t_instance_create_system(struct xrt_instance *xinst,
usys = u_system_create();
assert(usys != NULL); // Should never fail.
xret = u_system_devices_create_from_prober(xinst, &xsysd, &xso);
xret = u_system_devices_create_from_prober( //
xinst, // xinst
&usys->broadcast, // broadcast
&xsysd, // out_xsysd
&xso); // out_xso
if (xret != XRT_SUCCESS) {
return xret;
}

View file

@ -46,7 +46,11 @@ t_instance_create_system(struct xrt_instance *xinst,
usys = u_system_create();
assert(usys != NULL); // Should never fail.
xret = u_system_devices_create_from_prober(xinst, &xsysd, &xso);
xret = u_system_devices_create_from_prober( //
xinst, //
&usys->broadcast, //
&xsysd, //
&xso); //
if (xret != XRT_SUCCESS) {
u_system_destroy(&usys);
return xret;