Add dbus server
This commit is contained in:
@@ -56,6 +56,11 @@ void configuration::set_config_file(const std::filesystem::path & path)
|
||||
config_file = path;
|
||||
}
|
||||
|
||||
const std::filesystem::path & configuration::get_config_file()
|
||||
{
|
||||
return config_file;
|
||||
}
|
||||
|
||||
configuration configuration::read_user_configuration()
|
||||
{
|
||||
configuration result;
|
||||
|
||||
@@ -49,6 +49,7 @@ struct configuration
|
||||
bool tcp_only = false;
|
||||
|
||||
static void set_config_file(const std::filesystem::path &);
|
||||
static const std::filesystem::path & get_config_file();
|
||||
static configuration read_user_configuration();
|
||||
};
|
||||
|
||||
|
||||
@@ -20,11 +20,17 @@
|
||||
#include "wivrn_connection.h"
|
||||
#include "configuration.h"
|
||||
#include "util/u_logging.h"
|
||||
#include "wivrn_ipc.h"
|
||||
#include <arpa/inet.h>
|
||||
#include <poll.h>
|
||||
|
||||
using namespace std::chrono_literals;
|
||||
|
||||
static void handle_event_from_main_loop(to_monado::disconnect)
|
||||
{
|
||||
// Ignore disconnect request when no headset is connected
|
||||
}
|
||||
|
||||
wivrn_connection::wivrn_connection(TCP && tcp) :
|
||||
control(std::move(tcp)), stream(-1)
|
||||
{
|
||||
@@ -68,11 +74,13 @@ void wivrn_connection::init()
|
||||
|
||||
while (true)
|
||||
{
|
||||
pollfd fds[2] = {};
|
||||
pollfd fds[3] = {};
|
||||
fds[0].events = POLLIN;
|
||||
fds[0].fd = stream.get_fd();
|
||||
fds[1].events = POLLIN;
|
||||
fds[1].fd = control.get_fd();
|
||||
fds[2].fd = wivrn_ipc_socket_monado->get_fd();
|
||||
fds[2].events = POLLIN;
|
||||
|
||||
int r = ::poll(fds, std::size(fds), 1000);
|
||||
if (r < 0)
|
||||
@@ -84,6 +92,9 @@ void wivrn_connection::init()
|
||||
if (fds[1].revents & (POLLHUP | POLLERR))
|
||||
throw std::runtime_error("Error on control socket");
|
||||
|
||||
if (fds[2].revents & (POLLHUP | POLLERR))
|
||||
throw std::runtime_error("Error on IPC socket");
|
||||
|
||||
if (fds[0].revents & POLLIN)
|
||||
{
|
||||
auto [packet, peer_addr] = stream.receive_from_raw();
|
||||
@@ -116,6 +127,13 @@ void wivrn_connection::init()
|
||||
}
|
||||
}
|
||||
|
||||
if (fds[2].revents & POLLIN)
|
||||
{
|
||||
auto packet = receive_from_main();
|
||||
if (packet)
|
||||
std::visit([](auto && x) { handle_event_from_main_loop(x); }, *packet);
|
||||
}
|
||||
|
||||
if (std::chrono::steady_clock::now() > timeout)
|
||||
{
|
||||
throw std::runtime_error("No handshake received from client");
|
||||
|
||||
@@ -19,6 +19,7 @@
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "wivrn_ipc.h"
|
||||
#include "wivrn_packets.h"
|
||||
#include "wivrn_sockets.h"
|
||||
#include <optional>
|
||||
@@ -81,11 +82,13 @@ public:
|
||||
template <typename T>
|
||||
int poll(T && visitor, int timeout)
|
||||
{
|
||||
pollfd fds[2] = {};
|
||||
pollfd fds[3] = {};
|
||||
fds[0].events = POLLIN;
|
||||
fds[0].fd = stream.get_fd();
|
||||
fds[1].events = POLLIN;
|
||||
fds[1].fd = control.get_fd();
|
||||
fds[2].fd = wivrn_ipc_socket_monado->get_fd();
|
||||
fds[2].events = POLLIN;
|
||||
|
||||
while (auto packet = stream.receive_pending())
|
||||
std::visit(std::forward<T>(visitor), std::move(*packet));
|
||||
@@ -102,6 +105,9 @@ public:
|
||||
if (fds[1].revents & (POLLHUP | POLLERR))
|
||||
throw std::runtime_error("Error on control socket");
|
||||
|
||||
if (fds[2].revents & (POLLHUP | POLLERR))
|
||||
throw std::runtime_error("Error on IPC socket");
|
||||
|
||||
if (fds[0].revents & POLLIN)
|
||||
{
|
||||
auto packet = stream.receive();
|
||||
@@ -115,6 +121,13 @@ public:
|
||||
if (packet)
|
||||
std::visit(std::forward<T>(visitor), std::move(*packet));
|
||||
}
|
||||
|
||||
if (fds[2].revents & POLLIN)
|
||||
{
|
||||
auto packet = receive_from_main();
|
||||
if (packet)
|
||||
std::visit(std::forward<T>(visitor), std::move(*packet));
|
||||
}
|
||||
return r;
|
||||
}
|
||||
};
|
||||
|
||||
@@ -33,16 +33,17 @@
|
||||
|
||||
#include "audio/audio_setup.h"
|
||||
#include "wivrn_comp_target.h"
|
||||
#include "wivrn_config.h"
|
||||
#include "wivrn_controller.h"
|
||||
#include "wivrn_eye_tracker.h"
|
||||
#include "wivrn_fb_face2_tracker.h"
|
||||
#include "wivrn_foveation.h"
|
||||
#include "wivrn_hmd.h"
|
||||
#include "wivrn_ipc.h"
|
||||
|
||||
#include "xrt/xrt_session.h"
|
||||
#include <cmath>
|
||||
#include <magic_enum.hpp>
|
||||
#include <stdexcept>
|
||||
#include <vulkan/vulkan.h>
|
||||
|
||||
#ifdef WIVRN_FEATURE_STEAMVR_LIGHTHOUSE
|
||||
@@ -134,6 +135,7 @@ xrt_result_t xrt::drivers::wivrn::wivrn_session::create_session(xrt::drivers::wi
|
||||
}
|
||||
|
||||
self->info = std::get<from_headset::headset_info_packet>(*control);
|
||||
send_to_main(self->info);
|
||||
|
||||
try
|
||||
{
|
||||
@@ -407,6 +409,11 @@ void wivrn_session::operator()(audio_data && data)
|
||||
audio_handle->process_mic_data(std::move(data));
|
||||
}
|
||||
|
||||
void wivrn_session::operator()(to_monado::disconnect &&)
|
||||
{
|
||||
throw std::runtime_error("Disconnecting as requested by main loop");
|
||||
}
|
||||
|
||||
void wivrn_session::run(std::weak_ptr<wivrn_session> weak_self)
|
||||
{
|
||||
while (true)
|
||||
|
||||
@@ -21,6 +21,7 @@
|
||||
|
||||
#include "clock_offset.h"
|
||||
#include "wivrn_connection.h"
|
||||
#include "wivrn_ipc.h"
|
||||
#include "wivrn_packets.h"
|
||||
#include "xrt/xrt_defines.h"
|
||||
#include "xrt/xrt_results.h"
|
||||
@@ -145,6 +146,8 @@ public:
|
||||
void operator()(from_headset::battery &&);
|
||||
void operator()(audio_data &&);
|
||||
|
||||
void operator()(to_monado::disconnect &&);
|
||||
|
||||
template <typename T>
|
||||
void send_stream(T && packet)
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user