| 982 | } |
| 983 | |
| 984 | std::unique_ptr<deinit_t> init() { |
| 985 | // enable low latency mode for AMD |
| 986 | // https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/30039 |
| 987 | set_env("AMD_DEBUG", "lowlatencyenc"); |
| 988 | |
| 989 | // These are allowed to fail. |
| 990 | gbm::init(); |
| 991 | |
| 992 | window_system = window_system_e::NONE; |
| 993 | #ifdef SUNSHINE_BUILD_WAYLAND |
| 994 | if (std::getenv("WAYLAND_DISPLAY")) { |
| 995 | window_system = window_system_e::WAYLAND; |
| 996 | } |
| 997 | #endif |
| 998 | #if defined(SUNSHINE_BUILD_X11) || defined(SUNSHINE_BUILD_CUDA) |
| 999 | if (std::getenv("DISPLAY") && window_system != window_system_e::WAYLAND) { |
| 1000 | if (std::getenv("WAYLAND_DISPLAY")) { |
| 1001 | BOOST_LOG(warning) << "Wayland detected, yet sunshine will use X11 for screencasting, screencasting will only work on XWayland applications"sv; |
| 1002 | } |
| 1003 | |
| 1004 | window_system = window_system_e::X11; |
| 1005 | } |
| 1006 | #endif |
| 1007 | |
| 1008 | #ifdef SUNSHINE_BUILD_CUDA |
| 1009 | if ((config::video.capture.empty() && sources.none()) || config::video.capture == "nvfbc") { |
| 1010 | if (verify_nvfbc()) { |
| 1011 | sources[source::NVFBC] = true; |
| 1012 | } |
| 1013 | } |
| 1014 | #endif |
| 1015 | #ifdef SUNSHINE_BUILD_WAYLAND |
| 1016 | if ((config::video.capture.empty() && sources.none()) || config::video.capture == "wlr") { |
| 1017 | if (verify_wl()) { |
| 1018 | sources[source::WAYLAND] = true; |
| 1019 | } |
| 1020 | } |
| 1021 | #endif |
| 1022 | #ifdef SUNSHINE_BUILD_DRM |
| 1023 | if ((config::video.capture.empty() && sources.none()) || config::video.capture == "kms") { |
| 1024 | if (verify_kms()) { |
| 1025 | sources[source::KMS] = true; |
| 1026 | } |
| 1027 | } |
| 1028 | #endif |
| 1029 | #ifdef SUNSHINE_BUILD_X11 |
| 1030 | // We enumerate this capture backend regardless of other suitable sources, |
| 1031 | // since it may be needed as a NvFBC fallback for software encoding on X11. |
| 1032 | if (config::video.capture.empty() || config::video.capture == "x11") { |
| 1033 | if (verify_x11()) { |
| 1034 | sources[source::X11] = true; |
| 1035 | } |
| 1036 | } |
| 1037 | #endif |
| 1038 | |
| 1039 | if (sources.none()) { |
| 1040 | BOOST_LOG(error) << "Unable to initialize capture method"sv; |
| 1041 | return nullptr; |
nothing calls this directly
no test coverage detected