Use cmakedefine01 instead of cmakedefine

This commit is contained in:
Guillaume Meunier
2024-10-01 21:46:41 +02:00
parent 68ddabdcdd
commit 674343c74f
6 changed files with 38 additions and 38 deletions
+8 -8
View File
@@ -19,16 +19,16 @@
#pragma once
#cmakedefine WIVRN_USE_NVENC
#cmakedefine WIVRN_USE_VAAPI
#cmakedefine WIVRN_USE_X264
#cmakedefine01 WIVRN_USE_NVENC
#cmakedefine01 WIVRN_USE_VAAPI
#cmakedefine01 WIVRN_USE_X264
#cmakedefine WIVRN_USE_SYSTEMD
#cmakedefine01 WIVRN_USE_SYSTEMD
#cmakedefine WIVRN_USE_PIPEWIRE
#cmakedefine WIVRN_USE_PULSEAUDIO
#cmakedefine01 WIVRN_USE_PIPEWIRE
#cmakedefine01 WIVRN_USE_PULSEAUDIO
#cmakedefine WIVRN_FEATURE_STEAMVR_LIGHTHOUSE
#cmakedefine WIVRN_FEATURE_SOLARXR
#cmakedefine01 WIVRN_FEATURE_STEAMVR_LIGHTHOUSE
#cmakedefine01 WIVRN_FEATURE_SOLARXR
#define WIVRN_INSTALL_PREFIX "@CMAKE_INSTALL_PREFIX@"
+4 -4
View File
@@ -22,11 +22,11 @@
#include "util/u_logging.h"
#include "wivrn_config.h"
#ifdef WIVRN_USE_PULSEAUDIO
#if WIVRN_USE_PULSEAUDIO
#include "audio_pulse.h"
#endif
#ifdef WIVRN_USE_PIPEWIRE
#if WIVRN_USE_PIPEWIRE
#include "audio_pipewire.h"
#endif
@@ -38,12 +38,12 @@ std::shared_ptr<audio_device> audio_device::create(
const xrt::drivers::wivrn::from_headset::headset_info_packet & info,
xrt::drivers::wivrn::wivrn_session & session)
{
#ifdef WIVRN_USE_PIPEWIRE
#if WIVRN_USE_PIPEWIRE
if (auto res = create_pipewire_handle(source_name, source_description, sink_name, sink_description, info, session))
return res;
#endif
#ifdef WIVRN_USE_PULSEAUDIO
#if WIVRN_USE_PULSEAUDIO
if (auto res = create_pulse_handle(source_name, source_description, sink_name, sink_description, info, session))
return res;
#endif
+4 -4
View File
@@ -47,11 +47,11 @@
#include <stdexcept>
#include <vulkan/vulkan.h>
#ifdef WIVRN_FEATURE_STEAMVR_LIGHTHOUSE
#if WIVRN_FEATURE_STEAMVR_LIGHTHOUSE
#include "steamvr_lh_interface.h"
#endif
#ifdef WIVRN_FEATURE_SOLARXR
#if WIVRN_FEATURE_SOLARXR
#include "solarxr_device.h"
#endif
@@ -189,7 +189,7 @@ xrt_result_t xrt::drivers::wivrn::wivrn_session::create_session(xrt::drivers::wi
usysds->base.base.static_roles.hand_tracking.right = self->right_hand.get();
}
#ifdef WIVRN_FEATURE_STEAMVR_LIGHTHOUSE
#if WIVRN_FEATURE_STEAMVR_LIGHTHOUSE
auto use_steamvr_lh = std::getenv("WIVRN_USE_STEAMVR_LH");
xrt_system_devices * lhdevs = NULL;
@@ -230,7 +230,7 @@ xrt_result_t xrt::drivers::wivrn::wivrn_session::create_session(xrt::drivers::wi
devices->xdevs[n++] = self->fb_face2_tracker.get();
}
#ifdef WIVRN_FEATURE_SOLARXR
#if WIVRN_FEATURE_SOLARXR
xrt_device * solar_devs[XRT_SYSTEM_MAX_DEVICES];
uint32_t solar_devs_cap = XRT_SYSTEM_MAX_DEVICES - devices->xdev_count;
uint32_t num_devs = solarxr_device_create_xdevs(self->hmd.get(), solar_devs, XRT_SYSTEM_MAX_DEVICES - devices->xdev_count);
+10 -10
View File
@@ -30,10 +30,10 @@
#include "wivrn_config.h"
#ifdef WIVRN_USE_NVENC
#if WIVRN_USE_NVENC
#include "video_encoder_nvenc.h"
#endif
#ifdef WIVRN_USE_VAAPI
#if WIVRN_USE_VAAPI
#include "ffmpeg/video_encoder_va.h"
#endif
@@ -98,7 +98,7 @@ void print_encoders(const std::vector<xrt::drivers::wivrn::encoder_settings> & e
static void check_scale(std::string_view encoder_name, video_codec codec, uint16_t width, uint16_t height, std::array<double, 2> & scale)
{
#ifdef WIVRN_USE_NVENC
#if WIVRN_USE_NVENC
if (encoder_name == encoder_nvenc)
{
auto max = VideoEncoderNvenc::get_max_size(codec);
@@ -116,7 +116,7 @@ static void check_scale(std::string_view encoder_name, video_codec codec, uint16
#endif
}
#ifdef WIVRN_USE_VAAPI
#if WIVRN_USE_VAAPI
static std::optional<xrt::drivers::wivrn::video_codec> filter_codecs_vaapi(wivrn_vk_bundle & bundle, const std::vector<xrt::drivers::wivrn::video_codec> & codecs)
{
VideoEncoderFFMPEG::mute_logs mute;
@@ -154,9 +154,9 @@ static void fill_defaults(wivrn_vk_bundle & bundle, const std::vector<xrt::drive
{
if (is_nvidia(*bundle.physical_device))
{
#ifdef WIVRN_USE_NVENC
#if WIVRN_USE_NVENC
config.name = encoder_nvenc;
#elif defined(WIVRN_USE_X264)
#elif WIVRN_USE_X264
U_LOG_W("nvidia GPU detected, but nvenc support not compiled");
config.name = encoder_x264;
config.codec = h264;
@@ -166,9 +166,9 @@ static void fill_defaults(wivrn_vk_bundle & bundle, const std::vector<xrt::drive
}
else
{
#ifdef WIVRN_USE_VAAPI
#if WIVRN_USE_VAAPI
config.name = encoder_vaapi;
#elif defined(WIVRN_USE_X264)
#elif WIVRN_USE_X264
U_LOG_W("ffmpeg support not compiled, vaapi encoder not available");
config.name = encoder_x264;
config.codec = h264;
@@ -178,7 +178,7 @@ static void fill_defaults(wivrn_vk_bundle & bundle, const std::vector<xrt::drive
}
}
#ifdef WIVRN_USE_VAAPI
#if WIVRN_USE_VAAPI
if (config.name == encoder_vaapi and not config.codec)
{
config.codec = filter_codecs_vaapi(bundle, headset_codecs);
@@ -191,7 +191,7 @@ static void fill_defaults(wivrn_vk_bundle & bundle, const std::vector<xrt::drive
}
#endif
#ifdef WIVRN_USE_X264
#if WIVRN_USE_X264
if (config.name == encoder_x264)
config.codec = h264;
#endif
+6 -6
View File
@@ -29,13 +29,13 @@
#include "wivrn_config.h"
#ifdef WIVRN_USE_NVENC
#if WIVRN_USE_NVENC
#include "video_encoder_nvenc.h"
#endif
#ifdef WIVRN_USE_VAAPI
#if WIVRN_USE_VAAPI
#include "ffmpeg/video_encoder_va.h"
#endif
#ifdef WIVRN_USE_X264
#if WIVRN_USE_X264
#include "video_encoder_x264.h"
#endif
@@ -108,7 +108,7 @@ std::unique_ptr<VideoEncoder> VideoEncoder::Create(
std::unique_ptr<VideoEncoder> res;
if (settings.encoder_name == encoder_x264)
{
#ifdef WIVRN_USE_X264
#if WIVRN_USE_X264
res = std::make_unique<VideoEncoderX264>(wivrn_vk, settings, fps);
#else
throw std::runtime_error("x264 encoder not enabled");
@@ -116,7 +116,7 @@ std::unique_ptr<VideoEncoder> VideoEncoder::Create(
}
if (settings.encoder_name == encoder_nvenc)
{
#ifdef WIVRN_USE_NVENC
#if WIVRN_USE_NVENC
res = std::make_unique<VideoEncoderNvenc>(wivrn_vk, settings, fps);
#else
throw std::runtime_error("nvenc support not enabled");
@@ -124,7 +124,7 @@ std::unique_ptr<VideoEncoder> VideoEncoder::Create(
}
if (settings.encoder_name == encoder_vaapi)
{
#ifdef WIVRN_USE_VAAPI
#if WIVRN_USE_VAAPI
res = std::make_unique<video_encoder_va>(wivrn_vk, settings, fps);
#else
throw std::runtime_error("vaapi support not enabled");
+6 -6
View File
@@ -64,7 +64,7 @@ std::filesystem::path socket_path()
return {sock_file, sock_file + size};
}
#ifdef WIVRN_USE_SYSTEMD
#if WIVRN_USE_SYSTEMD
int create_listen_socket()
{
sockaddr_un addr{};
@@ -214,7 +214,7 @@ void update_fsm();
void start_app()
{
#ifdef WIVRN_USE_SYSTEMD
#if WIVRN_USE_SYSTEMD
app_pid = use_systemd ? start_unit_file() : fork_application();
#else
app_pid = fork_application();
@@ -599,7 +599,7 @@ int inner_main(int argc, char * argv[], bool show_instructions)
std::filesystem::create_directories(socket_path().parent_path());
#ifdef WIVRN_USE_SYSTEMD
#if WIVRN_USE_SYSTEMD
create_listen_socket();
#else
assert(not use_systemd);
@@ -670,7 +670,7 @@ int inner_main(int argc, char * argv[], bool show_instructions)
avahi_glib_poll_free(glib_poll);
g_main_loop_unref(main_loop);
#ifdef WIVRN_USE_SYSTEMD
#if WIVRN_USE_SYSTEMD
std::error_code ec;
std::filesystem::remove(socket_path(), ec);
#endif
@@ -685,7 +685,7 @@ int main(int argc, char * argv[])
std::string config_file;
app.add_option("-f", config_file, "configuration file")->option_text("FILE")->check(CLI::ExistingFile);
auto no_instructions = app.add_flag("--no-instructions")->group("");
#ifdef WIVRN_USE_SYSTEMD
#if WIVRN_USE_SYSTEMD
// --application should only be used from wivrn-application unit file
auto app_flag = app.add_flag("--application")->group("");
app.add_flag("--systemd", use_systemd, "use systemd to launch user-configured application");
@@ -696,7 +696,7 @@ int main(int argc, char * argv[])
if (not config_file.empty())
configuration::set_config_file(config_file);
#ifdef WIVRN_USE_SYSTEMD
#if WIVRN_USE_SYSTEMD
if (*app_flag)
return exec_application(configuration::read_user_configuration());
#endif