diff --git a/.clang-format b/.clang-format index 97bdef1e..e72a1e27 100644 --- a/.clang-format +++ b/.clang-format @@ -52,7 +52,7 @@ NamespaceIndentation: All ObjCSpaceAfterProperty: true ObjCSpaceBeforeProtocolList: true PointerAlignment: Right -ReflowComments: false +ReflowComments: true SpaceAfterCStyleCast: true SpaceAfterLogicalNot: false SpaceAfterTemplateKeyword: true diff --git a/.readthedocs.yaml b/.readthedocs.yaml index 3316c40e..3a0f2433 100644 --- a/.readthedocs.yaml +++ b/.readthedocs.yaml @@ -8,16 +8,16 @@ version: 2 # Set the version of Python build: - os: ubuntu-20.04 + os: ubuntu-22.04 tools: - python: "3.10" + python: "3.11" apt_packages: - graphviz -## Include the submodules, required for cmake -# submodules: -# include: all -# recursive: true +# submodules required for include statements +submodules: + include: all + recursive: true # Build documentation in the docs/ directory with Sphinx sphinx: diff --git a/docs/Doxyfile b/docs/Doxyfile index 728c246f..5d909b53 100644 --- a/docs/Doxyfile +++ b/docs/Doxyfile @@ -878,6 +878,7 @@ WARN_IF_UNDOC_ENUM_VAL = NO # The default value is: NO. WARN_AS_ERROR = NO +# todo - ideally this will eventually become FAIL_ON_WARNINGS # The WARN_FORMAT tag determines the format of the warning messages that doxygen # can produce. The string should contain the $file, $line, and $text tags, which @@ -2354,7 +2355,7 @@ SEARCH_INCLUDES = YES # RECURSIVE has no effect here. # This tag requires that the tag SEARCH_INCLUDES is set to YES. -INCLUDE_PATH = +INCLUDE_PATH = ../third-party/ffmpeg-linux-x86_64/include/ # You can use the INCLUDE_FILE_PATTERNS tag to specify one or more wildcard # patterns (like *.h and *.hpp) to filter out the header-files in the diff --git a/docs/source/conf.py b/docs/source/conf.py index dd417ce4..e5817838 100644 --- a/docs/source/conf.py +++ b/docs/source/conf.py @@ -95,8 +95,16 @@ breathe_projects = dict( ) todo_include_todos = True -subprocess.run('doxygen', shell=True, cwd=source_dir) - # disable epub mimetype warnings # https://github.com/readthedocs/readthedocs.org/blob/eadf6ac6dc6abc760a91e1cb147cc3c5f37d1ea8/docs/conf.py#L235-L236 suppress_warnings = ["epub.unknown_project_files"] + +# get doxygen version +doxy_proc = subprocess.run('doxygen --version', shell=True, cwd=source_dir, capture_output=True) +doxy_version = doxy_proc.stdout.decode('utf-8').strip() +print('doxygen version: ' + doxy_version) + +# run doxygen +doxy_proc = subprocess.run('doxygen Doxyfile', shell=True, cwd=source_dir) +if doxy_proc.returncode != 0: + raise RuntimeError('doxygen failed with return code ' + str(doxy_proc.returncode)) diff --git a/src/audio.h b/src/audio.h index 09a99b03..64c293d5 100644 --- a/src/audio.h +++ b/src/audio.h @@ -1,5 +1,4 @@ -#ifndef SUNSHINE_AUDIO_H -#define SUNSHINE_AUDIO_H +#pragma once #include "thread_safe.h" #include "utility.h" @@ -44,5 +43,3 @@ namespace audio { void capture(safe::mail_t mail, config_t config, void *channel_data); } // namespace audio - -#endif diff --git a/src/cbs.cpp b/src/cbs.cpp index eedaaff0..4976f595 100644 --- a/src/cbs.cpp +++ b/src/cbs.cpp @@ -87,9 +87,9 @@ namespace cbs { make_sps_h264(const AVCodecContext *ctx) { H264RawSPS sps {}; - /* b_per_p == ctx->max_b_frames for h264 */ - /* desired_b_depth == avoption("b_depth") == 1 */ - /* max_b_depth == std::min(av_log2(ctx->b_per_p) + 1, desired_b_depth) ==> 1 */ + // b_per_p == ctx->max_b_frames for h264 + // desired_b_depth == avoption("b_depth") == 1 + // max_b_depth == std::min(av_log2(ctx->b_per_p) + 1, desired_b_depth) ==> 1 auto max_b_depth = 1; auto dpb_frame = ctx->gop_size == 1 ? 0 : 1 + max_b_depth; auto mb_width = (FFALIGN(ctx->width, 16) / 16) * 16; diff --git a/src/cbs.h b/src/cbs.h index fe532b98..2086305f 100644 --- a/src/cbs.h +++ b/src/cbs.h @@ -1,5 +1,4 @@ -#ifndef SUNSHINE_CBS_H -#define SUNSHINE_CBS_H +#pragma once #include "utility.h" @@ -28,10 +27,8 @@ namespace cbs { make_sps_h264(const AVCodecContext *ctx, const AVPacket *packet); /** - * Check if SPS->VUI is present - */ + * Check if SPS->VUI is present + */ bool validate_sps(const AVPacket *packet, int codec_id); } // namespace cbs - -#endif diff --git a/src/config.h b/src/config.h index 90b3fbee..3abf6c3b 100644 --- a/src/config.h +++ b/src/config.h @@ -1,5 +1,4 @@ -#ifndef SUNSHINE_CONFIG_H -#define SUNSHINE_CONFIG_H +#pragma once #include #include @@ -162,4 +161,3 @@ namespace config { std::unordered_map parse_config(const std::string_view &file_content); } // namespace config -#endif diff --git a/src/confighttp.cpp b/src/confighttp.cpp index 62fe6800..209b6a17 100644 --- a/src/confighttp.cpp +++ b/src/confighttp.cpp @@ -1,4 +1,3 @@ -// Created by TheElixZammuto on 2021-05-09. // TODO: Authentication, better handling of routes common to nvhttp, cleanup #define BOOST_BIND_GLOBAL_PLACEHOLDERS diff --git a/src/confighttp.h b/src/confighttp.h index f5fe158a..48251ba0 100644 --- a/src/confighttp.h +++ b/src/confighttp.h @@ -1,7 +1,4 @@ -// Created by loki on 6/3/19. - -#ifndef SUNSHINE_CONFIGHTTP_H -#define SUNSHINE_CONFIGHTTP_H +#pragma once #include #include @@ -34,5 +31,3 @@ const std::map mime_types = { { "woff2", "font/woff2" }, { "xml", "text/xml" }, }; - -#endif // SUNSHINE_CONFIGHTTP_H diff --git a/src/crypto.cpp b/src/crypto.cpp index f50c536c..a9927fc6 100644 --- a/src/crypto.cpp +++ b/src/crypto.cpp @@ -1,5 +1,3 @@ -// Created by loki on 5/31/19. - #include "crypto.h" #include @@ -35,13 +33,13 @@ namespace crypto { } } - /* - * When certificates from two or more instances of Moonlight have been added to x509_store_t, - * only one of them will be verified by X509_verify_cert, resulting in only a single instance of - * Moonlight to be able to use Sunshine - * - * To circumvent this, x509_store_t instance will be created for each instance of the certificates. - */ + /** + * When certificates from two or more instances of Moonlight have been added to x509_store_t, + * only one of them will be verified by X509_verify_cert, resulting in only a single instance of + * Moonlight to be able to use Sunshine + * + * To circumvent this, x509_store_t instance will be created for each instance of the certificates. + */ const char * cert_chain_t::verify(x509_t::element_type *cert) { int err_code = 0; diff --git a/src/crypto.h b/src/crypto.h index 2de5bafa..97250fda 100644 --- a/src/crypto.h +++ b/src/crypto.h @@ -1,7 +1,4 @@ -// Created by loki on 6/1/19. - -#ifndef SUNSHINE_CRYPTO_H -#define SUNSHINE_CRYPTO_H +#pragma once #include #include @@ -123,11 +120,11 @@ namespace crypto { gcm_t(const crypto::aes_t &key, bool padding = true); /** - * length of cipher must be at least: round_to_pkcs7_padded(plaintext.size()) + crypto::cipher::tag_size - * - * return -1 on error - * return bytes written on success - */ + * length of cipher must be at least: round_to_pkcs7_padded(plaintext.size()) + crypto::cipher::tag_size + * + * return -1 on error + * return bytes written on success + */ int encrypt(const std::string_view &plaintext, std::uint8_t *tagged_cipher, aes_t *iv); @@ -145,15 +142,13 @@ namespace crypto { cbc_t(const crypto::aes_t &key, bool padding = true); /** - * length of cipher must be at least: round_to_pkcs7_padded(plaintext.size()) - * - * return -1 on error - * return bytes written on success - */ + * length of cipher must be at least: round_to_pkcs7_padded(plaintext.size()) + * + * return -1 on error + * return bytes written on success + */ int encrypt(const std::string_view &plaintext, std::uint8_t *cipher, aes_t *iv); }; } // namespace cipher } // namespace crypto - -#endif //SUNSHINE_CRYPTO_H diff --git a/src/httpcommon.h b/src/httpcommon.h index 4deecd14..3aaeed02 100644 --- a/src/httpcommon.h +++ b/src/httpcommon.h @@ -1,3 +1,5 @@ +#pragma once + #include "network.h" #include "thread_safe.h" diff --git a/src/input.cpp b/src/input.cpp index a957b89b..bec9accc 100644 --- a/src/input.cpp +++ b/src/input.cpp @@ -1,5 +1,3 @@ -// Created by loki on 6/20/19. - // define uint32_t for #include extern "C" { @@ -147,12 +145,12 @@ namespace input { }; /** - * Apply shortcut based on VKEY - * On success - * return > 0 - * On nothing - * return 0 - */ + * Apply shortcut based on VKEY + * On success + * return > 0 + * On nothing + * return 0 + */ inline int apply_shortcut(short keyCode) { constexpr auto VK_F1 = 0x70; @@ -366,21 +364,20 @@ namespace input { mouse_press[button] = !release; } - /////////////////////////////////// - /*/ - * When Moonlight sends mouse input through absolute coordinates, - * it's possible that BUTTON_RIGHT is pressed down immediately after releasing BUTTON_LEFT. - * As a result, Sunshine will left-click on hyperlinks in the browser before right-clicking - * - * This can be solved by delaying BUTTON_LEFT, however, any delay on input is undesirable during gaming - * As a compromise, Sunshine will only put delays on BUTTON_LEFT when - * absolute mouse coordinates have been sent. - * - * Try to make sure BUTTON_RIGHT gets called before BUTTON_LEFT is released. - * - * input->mouse_left_button_timeout can only be nullptr - * when the last mouse coordinates were absolute - /*/ + /** + * When Moonlight sends mouse input through absolute coordinates, + * it's possible that BUTTON_RIGHT is pressed down immediately after releasing BUTTON_LEFT. + * As a result, Sunshine will left-click on hyperlinks in the browser before right-clicking + * + * This can be solved by delaying BUTTON_LEFT, however, any delay on input is undesirable during gaming + * As a compromise, Sunshine will only put delays on BUTTON_LEFT when + * absolute mouse coordinates have been sent. + * + * Try to make sure BUTTON_RIGHT gets called before BUTTON_LEFT is released. + * + * input->mouse_left_button_timeout can only be nullptr + * when the last mouse coordinates were absolute + */ if (button == BUTTON_LEFT && release && !input->mouse_left_button_timeout) { auto f = [=]() { auto left_released = mouse_press[BUTTON_LEFT]; @@ -408,7 +405,6 @@ namespace input { return; } - /////////////////////////////////// platf::button_mouse(platf_input, button, release); } @@ -424,8 +420,8 @@ namespace input { } /** - * Update flags for keyboard shortcut combo's - */ + * Update flags for keyboard shortcut combo's + */ inline void update_shortcutFlags(int *flags, short keyCode, bool release) { switch (keyCode) { diff --git a/src/input.h b/src/input.h index 2001fb9e..1253face 100644 --- a/src/input.h +++ b/src/input.h @@ -1,7 +1,4 @@ -// Created by loki on 6/20/19. - -#ifndef SUNSHINE_INPUT_H -#define SUNSHINE_INPUT_H +#pragma once #include @@ -33,5 +30,3 @@ namespace input { float scalar_inv; }; } // namespace input - -#endif // SUNSHINE_INPUT_H diff --git a/src/main.h b/src/main.h index e046acb9..a0609df8 100644 --- a/src/main.h +++ b/src/main.h @@ -3,8 +3,7 @@ */ // macros -#ifndef SUNSHINE_MAIN_H -#define SUNSHINE_MAIN_H +#pragma once // standard includes #include @@ -87,5 +86,3 @@ namespace service_ctrl { wait_for_ui_ready(); } // namespace service_ctrl #endif - -#endif // SUNSHINE_MAIN_H diff --git a/src/move_by_copy.h b/src/move_by_copy.h index 3c2bda12..5932e838 100644 --- a/src/move_by_copy.h +++ b/src/move_by_copy.h @@ -1,12 +1,11 @@ -#ifndef DOSSIER_MOVE_BY_COPY_H -#define DOSSIER_MOVE_BY_COPY_H +#pragma once #include namespace move_by_copy_util { - /* - * When a copy is made, it moves the object - * This allows you to move an object when a move can't be done. - */ + /** + * When a copy is made, it moves the object + * This allows you to move an object when a move can't be done. + */ template class MoveByCopy { public: @@ -53,4 +52,3 @@ namespace move_by_copy_util { return MoveByCopy(std::move(const_cast(movable))); } } // namespace move_by_copy_util -#endif diff --git a/src/network.cpp b/src/network.cpp index b658a06f..d180654b 100644 --- a/src/network.cpp +++ b/src/network.cpp @@ -1,5 +1,3 @@ -// Created by loki on 12/27/19. - #include "network.h" #include "utility.h" #include diff --git a/src/network.h b/src/network.h index ffed2fe6..c9837aed 100644 --- a/src/network.h +++ b/src/network.h @@ -1,7 +1,4 @@ -// Created by loki on 12/27/19. - -#ifndef SUNSHINE_NETWORK_H -#define SUNSHINE_NETWORK_H +#pragma once #include @@ -34,5 +31,3 @@ namespace net { host_t host_create(ENetAddress &addr, std::size_t peers, std::uint16_t port); } // namespace net - -#endif // SUNSHINE_NETWORK_H diff --git a/src/nvhttp.cpp b/src/nvhttp.cpp index eff9743b..286299fe 100644 --- a/src/nvhttp.cpp +++ b/src/nvhttp.cpp @@ -1,6 +1,6 @@ /** -* @file nvhttp.h -*/ + * @file nvhttp.h + */ // macros #define BOOST_BIND_GLOBAL_PLACEHOLDERS @@ -522,15 +522,15 @@ namespace nvhttp { } /** - * @brief Compare the user supplied pin to the Moonlight pin. - * @param pin The user supplied pin. - * @return `true` if the pin is correct, `false` otherwise. - * - * EXAMPLES: - * ```cpp - * bool pin_status = nvhttp::pin("1234"); - * ``` - */ + * @brief Compare the user supplied pin to the Moonlight pin. + * @param pin The user supplied pin. + * @return `true` if the pin is correct, `false` otherwise. + * + * EXAMPLES: + * ```cpp + * bool pin_status = nvhttp::pin("1234"); + * ``` + */ bool pin(std::string pin) { pt::ptree tree; @@ -889,13 +889,13 @@ namespace nvhttp { } /** - * @brief Start the nvhttp server. - * - * EXAMPLES: - * ```cpp - * nvhttp::start(); - * ``` - */ + * @brief Start the nvhttp server. + * + * EXAMPLES: + * ```cpp + * nvhttp::start(); + * ``` + */ void start() { auto shutdown_event = mail::man->event(mail::shutdown); @@ -1035,13 +1035,13 @@ namespace nvhttp { } /** - * @brief Remove all paired clients. - * - * EXAMPLES: - * ```cpp - * nvhttp::erase_all_clients(); - * ``` - */ + * @brief Remove all paired clients. + * + * EXAMPLES: + * ```cpp + * nvhttp::erase_all_clients(); + * ``` + */ void erase_all_clients() { map_id_client.clear(); diff --git a/src/nvhttp.h b/src/nvhttp.h index eccf9d34..b57d05e7 100644 --- a/src/nvhttp.h +++ b/src/nvhttp.h @@ -1,10 +1,9 @@ /** -* @file nvhttp.h -*/ + * @file nvhttp.h + */ // macros -#ifndef SUNSHINE_NVHTTP_H -#define SUNSHINE_NVHTTP_H +#pragma once // standard includes #include @@ -18,24 +17,24 @@ namespace nvhttp { /** - * @brief The protocol version. - */ + * @brief The protocol version. + */ constexpr auto VERSION = "7.1.431.-1"; // The negative 4th version number tells Moonlight that this is Sunshine /** - * @brief The GFE version we are replicating. - */ + * @brief The GFE version we are replicating. + */ constexpr auto GFE_VERSION = "3.23.0.74"; /** - * @brief The HTTP port, as a difference from the config port. - */ + * @brief The HTTP port, as a difference from the config port. + */ constexpr auto PORT_HTTP = 0; /** - * @brief The HTTPS port, as a difference from the config port. - */ + * @brief The HTTPS port, as a difference from the config port. + */ constexpr auto PORT_HTTPS = -5; // functions @@ -46,5 +45,3 @@ namespace nvhttp { void erase_all_clients(); } // namespace nvhttp - -#endif // SUNSHINE_NVHTTP_H diff --git a/src/platform/common.h b/src/platform/common.h index d626f9b3..114f2119 100644 --- a/src/platform/common.h +++ b/src/platform/common.h @@ -1,9 +1,4 @@ -// -// Created by loki on 6/21/19. -// - -#ifndef SUNSHINE_COMMON_H -#define SUNSHINE_COMMON_H +#pragma once #include #include @@ -215,8 +210,8 @@ namespace platf { } /** - * implementations must take ownership of 'frame' - */ + * implementations must take ownership of 'frame' + */ virtual int set_frame(AVFrame *frame, AVBufferRef *hw_frames_ctx) { BOOST_LOG(error) << "Illegal call to hwdevice_t::set_frame(). Did you forget to override it?"; @@ -227,14 +222,14 @@ namespace platf { set_colorspace(std::uint32_t colorspace, std::uint32_t color_range) {}; /** - * Implementations may set parameters during initialization of the hwframes context - */ + * Implementations may set parameters during initialization of the hwframes context + */ virtual void init_hwframes(AVHWFramesContext *frames) {}; /** - * Implementations may make modifications required before context derivation - */ + * Implementations may make modifications required before context derivation + */ virtual int prepare_to_derive_context(int hw_device_type) { return 0; @@ -254,44 +249,44 @@ namespace platf { class display_t { public: /** - * When display has a new image ready or a timeout occurs, this callback will be called with the image. - * If a frame was captured, frame_captured will be true. If a timeout occurred, it will be false. - * - * On Break Request --> - * Returns false - * - * On Success --> - * Returns true - */ + * When display has a new image ready or a timeout occurs, this callback will be called with the image. + * If a frame was captured, frame_captured will be true. If a timeout occurred, it will be false. + * + * On Break Request --> + * Returns false + * + * On Success --> + * Returns true + */ using push_captured_image_cb_t = std::function &&img, bool frame_captured)>; /** - * Use to get free image from the pool. Calls must be synchronized. - * Blocks until there is free image in the pool or capture is interrupted. - * - * Returns: - * 'true' on success, img_out contains free image - * 'false' when capture has been interrupted, img_out contains nullptr - */ + * Use to get free image from the pool. Calls must be synchronized. + * Blocks until there is free image in the pool or capture is interrupted. + * + * Returns: + * 'true' on success, img_out contains free image + * 'false' when capture has been interrupted, img_out contains nullptr + */ using pull_free_image_cb_t = std::function &img_out)>; display_t() noexcept: offset_x { 0 }, offset_y { 0 } {} /** - * push_captured_image_cb --> The callback that is called with captured image, - * must be called from the same thread as capture() - * pull_free_image_cb --> Capture backends call this callback to get empty image - * from the pool. If backend uses multiple threads, calls to this - * callback must be synchronized. Calls to this callback and - * push_captured_image_cb must be synchronized as well. - * bool *cursor --> A pointer to the flag that indicates wether the cursor should be captured as well - * - * Returns either: - * capture_e::ok when stopping - * capture_e::error on error - * capture_e::reinit when need of reinitialization - */ + * push_captured_image_cb --> The callback that is called with captured image, + * must be called from the same thread as capture() + * pull_free_image_cb --> Capture backends call this callback to get empty image + * from the pool. If backend uses multiple threads, calls to this + * callback must be synchronized. Calls to this callback and + * push_captured_image_cb must be synchronized as well. + * bool *cursor --> A pointer to the flag that indicates wether the cursor should be captured as well + * + * Returns either: + * capture_e::ok when stopping + * capture_e::error on error + * capture_e::reinit when need of reinitialization + */ virtual capture_e capture(const push_captured_image_cb_t &push_captured_image_cb, const pull_free_image_cb_t &pull_free_image_cb, bool *cursor) = 0; @@ -368,14 +363,14 @@ namespace platf { audio_control(); /** - * display_name --> The name of the monitor that SHOULD be displayed - * If display_name is empty --> Use the first monitor that's compatible you can find - * If you require to use this parameter in a seperate thread --> make a copy of it. - * - * config --> Stream configuration - * - * Returns display_t based on hwdevice_type - */ + * display_name --> The name of the monitor that SHOULD be displayed + * If display_name is empty --> Use the first monitor that's compatible you can find + * If you require to use this parameter in a seperate thread --> make a copy of it. + * + * config --> Stream configuration + * + * Returns display_t based on hwdevice_type + */ std::shared_ptr display(mem_type_e hwdevice_type, const std::string &display_name, const video::config_t &config); @@ -468,5 +463,3 @@ namespace platf { std::vector & supported_gamepads(); } // namespace platf - -#endif //SUNSHINE_COMMON_H diff --git a/src/platform/linux/audio.cpp b/src/platform/linux/audio.cpp index 0b68fc01..9e865374 100644 --- a/src/platform/linux/audio.cpp +++ b/src/platform/linux/audio.cpp @@ -1,6 +1,3 @@ -// -// Created by loki on 5/16/21. -// #include #include diff --git a/src/platform/linux/cuda.cu b/src/platform/linux/cuda.cu index 85f9ee4a..2955118a 100644 --- a/src/platform/linux/cuda.cu +++ b/src/platform/linux/cuda.cu @@ -30,7 +30,7 @@ using namespace std::literals; using namespace std::literals; -//////////////////// Special desclarations +// Special declarations /** * NVCC tends to have problems with standard headers. * Don't include common.h, instead use bare minimum @@ -78,7 +78,7 @@ static_assert(sizeof(video::color_t) == sizeof(video::color_extern_t), "color ma extern color_t colors[6]; } // namespace video -//////////////////// End special declarations +// End special declarations namespace cuda { auto constexpr INVALID_TEXTURE = std::numeric_limits::max(); diff --git a/src/platform/linux/cuda.h b/src/platform/linux/cuda.h index 0885368e..1bc991e4 100644 --- a/src/platform/linux/cuda.h +++ b/src/platform/linux/cuda.h @@ -1,5 +1,6 @@ -#if !defined(SUNSHINE_PLATFORM_CUDA_H) && defined(SUNSHINE_BUILD_CUDA) - #define SUNSHINE_PLATFORM_CUDA_H +#pragma once + +#if defined(SUNSHINE_BUILD_CUDA) #include #include @@ -89,11 +90,11 @@ namespace cuda { sws_t(int in_width, int in_height, int out_width, int out_height, int pitch, int threadsPerBlock, ptr_t &&color_matrix); /** - * in_width, in_height -- The width and height of the captured image in pixels - * out_width, out_height -- the width and height of the NV12 image in pixels - * - * pitch -- The size of a single row of pixels in bytes - */ + * in_width, in_height -- The width and height of the captured image in pixels + * out_width, out_height -- the width and height of the NV12 image in pixels + * + * pitch -- The size of a single row of pixels in bytes + */ static std::optional make(int in_width, int in_height, int out_width, int out_height, int pitch); diff --git a/src/platform/linux/graphics.h b/src/platform/linux/graphics.h index 01fc5304..548bd8f6 100644 --- a/src/platform/linux/graphics.h +++ b/src/platform/linux/graphics.h @@ -1,5 +1,4 @@ -#ifndef SUNSHINE_PLATFORM_LINUX_OPENGL_H -#define SUNSHINE_PLATFORM_LINUX_OPENGL_H +#pragma once #include #include @@ -94,8 +93,8 @@ namespace gl { } /** - * Copies a part of the framebuffer to texture - */ + * Copies a part of the framebuffer to texture + */ void copy(int id, int texture, int offset_x, int offset_y, int width, int height); }; @@ -352,5 +351,3 @@ namespace egl { bool fail(); } // namespace egl - -#endif diff --git a/src/platform/linux/input.cpp b/src/platform/linux/input.cpp index 9f277987..6dbd46c9 100644 --- a/src/platform/linux/input.cpp +++ b/src/platform/linux/input.cpp @@ -143,9 +143,9 @@ namespace platf { constexpr auto UNKNOWN = 0; /** - * @brief Initializes the keycode constants for translating - * moonlight keycodes to linux/X11 keycodes - */ + * @brief Initializes the keycode constants for translating + * moonlight keycodes to linux/X11 keycodes. + */ static constexpr std::array init_keycodes() { std::array keycodes {}; @@ -1047,16 +1047,16 @@ namespace platf { } /** - * @brief XTest absolute mouse move. - * @param input The input_t instance to use. - * @param x Absolute x position. - * @param y Absolute y position. - * - * EXAMPLES: - * ```cpp - * x_abs_mouse(input, 0, 0); - * ``` - */ + * @brief XTest absolute mouse move. + * @param input The input_t instance to use. + * @param x Absolute x position. + * @param y Absolute y position. + * + * EXAMPLES: + * ```cpp + * x_abs_mouse(input, 0, 0); + * ``` + */ static void x_abs_mouse(input_t &input, float x, float y) { #ifdef SUNSHINE_BUILD_X11 @@ -1070,17 +1070,17 @@ namespace platf { } /** - * @brief Absolute mouse move. - * @param input The input_t instance to use. - * @param touch_port The touch_port instance to use. - * @param x Absolute x position. - * @param y Absolute y position. - * - * EXAMPLES: - * ```cpp - * abs_mouse(input, touch_port, 0, 0); - * ``` - */ + * @brief Absolute mouse move. + * @param input The input_t instance to use. + * @param touch_port The touch_port instance to use. + * @param x Absolute x position. + * @param y Absolute y position. + * + * EXAMPLES: + * ```cpp + * abs_mouse(input, touch_port, 0, 0); + * ``` + */ void abs_mouse(input_t &input, const touch_port_t &touch_port, float x, float y) { auto touchscreen = ((input_raw_t *) input.get())->touch_input.get(); @@ -1101,16 +1101,16 @@ namespace platf { } /** - * @brief XTest relative mouse move. - * @param input The input_t instance to use. - * @param deltaX Relative x position. - * @param deltaY Relative y position. - * - * EXAMPLES: - * ```cpp - * x_move_mouse(input, 10, 10); // Move mouse 10 pixels down and right - * ``` - */ + * @brief XTest relative mouse move. + * @param input The input_t instance to use. + * @param deltaX Relative x position. + * @param deltaY Relative y position. + * + * EXAMPLES: + * ```cpp + * x_move_mouse(input, 10, 10); // Move mouse 10 pixels down and right + * ``` + */ static void x_move_mouse(input_t &input, int deltaX, int deltaY) { #ifdef SUNSHINE_BUILD_X11 @@ -1124,16 +1124,16 @@ namespace platf { } /** - * @brief Relative mouse move. - * @param input The input_t instance to use. - * @param deltaX Relative x position. - * @param deltaY Relative y position. - * - * EXAMPLES: - * ```cpp - * move_mouse(input, 10, 10); // Move mouse 10 pixels down and right - * ``` - */ + * @brief Relative mouse move. + * @param input The input_t instance to use. + * @param deltaX Relative x position. + * @param deltaY Relative y position. + * + * EXAMPLES: + * ```cpp + * move_mouse(input, 10, 10); // Move mouse 10 pixels down and right + * ``` + */ void move_mouse(input_t &input, int deltaX, int deltaY) { auto mouse = ((input_raw_t *) input.get())->mouse_input.get(); @@ -1154,16 +1154,16 @@ namespace platf { } /** - * @brief XTest mouse button press/release. - * @param input The input_t instance to use. - * @param button Which mouse button to emulate. - * @param release Whether the event was a press (false) or a release (true) - * - * EXAMPLES: - * ```cpp - * x_button_mouse(input, 1, false); // Press left mouse button - * ``` - */ + * @brief XTest mouse button press/release. + * @param input The input_t instance to use. + * @param button Which mouse button to emulate. + * @param release Whether the event was a press (false) or a release (true) + * + * EXAMPLES: + * ```cpp + * x_button_mouse(input, 1, false); // Press left mouse button + * ``` + */ static void x_button_mouse(input_t &input, int button, bool release) { #ifdef SUNSHINE_BUILD_X11 @@ -1197,16 +1197,16 @@ namespace platf { } /** - * @brief Mouse button press/release. - * @param input The input_t instance to use. - * @param button Which mouse button to emulate. - * @param release Whether the event was a press (false) or a release (true) - * - * EXAMPLES: - * ```cpp - * button_mouse(input, 1, false); // Press left mouse button - * ``` - */ + * @brief Mouse button press/release. + * @param input The input_t instance to use. + * @param button Which mouse button to emulate. + * @param release Whether the event was a press (false) or a release (true) + * + * EXAMPLES: + * ```cpp + * button_mouse(input, 1, false); // Press left mouse button + * ``` + */ void button_mouse(input_t &input, int button, bool release) { auto mouse = ((input_raw_t *) input.get())->mouse_input.get(); @@ -1245,17 +1245,17 @@ namespace platf { } /** - * @brief XTest mouse scroll. - * @param input The input_t instance to use. - * @param distance How far to scroll - * @param button_pos Which mouse button to emulate for positive scroll. - * @param button_neg Which mouse button to emulate for negative scroll. - * - * EXAMPLES: - * ```cpp - * x_scroll(input, 10, 4, 5); - * ``` - */ + * @brief XTest mouse scroll. + * @param input The input_t instance to use. + * @param distance How far to scroll. + * @param button_pos Which mouse button to emulate for positive scroll. + * @param button_neg Which mouse button to emulate for negative scroll. + * + * EXAMPLES: + * ```cpp + * x_scroll(input, 10, 4, 5); + * ``` + */ static void x_scroll(input_t &input, int distance, int button_pos, int button_neg) { #ifdef SUNSHINE_BUILD_X11 @@ -1274,15 +1274,15 @@ namespace platf { } /** - * @brief Vertical mouse scroll. - * @param input The input_t instance to use. - * @param high_res_distance How far to scroll - * - * EXAMPLES: - * ```cpp - * scroll(input, 1200); - * ``` - */ + * @brief Vertical mouse scroll. + * @param input The input_t instance to use. + * @param high_res_distance How far to scroll. + * + * EXAMPLES: + * ```cpp + * scroll(input, 1200); + * ``` + */ void scroll(input_t &input, int high_res_distance) { int distance = high_res_distance / 120; @@ -1299,15 +1299,15 @@ namespace platf { } /** - * @brief Horizontal mouse scroll. - * @param input The input_t instance to use. - * @param high_res_distance How far to scroll - * - * EXAMPLES: - * ```cpp - * hscroll(input, 1200); - * ``` - */ + * @brief Horizontal mouse scroll. + * @param input The input_t instance to use. + * @param high_res_distance How far to scroll. + * + * EXAMPLES: + * ```cpp + * hscroll(input, 1200); + * ``` + */ void hscroll(input_t &input, int high_res_distance) { int distance = high_res_distance / 120; @@ -1333,17 +1333,17 @@ namespace platf { } /** - * @brief XTest keyboard emulation. - * @param input The input_t instance to use. - * @param modcode The moonlight key code. - * @param release Whether the event was a press (false) or a release (true) - * @param flags SS_KBE_FLAG_* values - * - * EXAMPLES: - * ```cpp - * x_keyboard(input, 0x5A, false, 0); // Press Z - * ``` - */ + * @brief XTest keyboard emulation. + * @param input The input_t instance to use. + * @param modcode The moonlight key code. + * @param release Whether the event was a press (false) or a release (true) + * @param flags SS_KBE_FLAG_* values + * + * EXAMPLES: + * ```cpp + * x_keyboard(input, 0x5A, false, 0); // Press Z + * ``` + */ static void x_keyboard(input_t &input, uint16_t modcode, bool release, uint8_t flags) { #ifdef SUNSHINE_BUILD_X11 @@ -1368,17 +1368,17 @@ namespace platf { } /** - * @brief Keyboard emulation. - * @param input The input_t instance to use. - * @param modcode The moonlight key code. - * @param release Whether the event was a press (false) or a release (true) - * @param flags SS_KBE_FLAG_* values - * - * EXAMPLES: - * ```cpp - * keyboard(input, 0x5A, false, 0); // Press Z - * ``` - */ + * @brief Keyboard emulation. + * @param input The input_t instance to use. + * @param modcode The moonlight key code. + * @param release Whether the event was a press (false) or a release (true) + * @param flags SS_KBE_FLAG_* values + * + * EXAMPLES: + * ```cpp + * keyboard(input, 0x5A, false, 0); // Press Z + * ``` + */ void keyboard(input_t &input, uint16_t modcode, bool release, uint8_t flags) { auto keyboard = ((input_raw_t *) input.get())->keyboard_input.get(); @@ -1407,12 +1407,12 @@ namespace platf { } /** - * Takes an UTF-32 encoded string and returns a hex string representation of the bytes (uppercase) - * - * ex: ['👱'] = "1F471" // see UTF encoding at https://www.compart.com/en/unicode/U+1F471 - * - * adapted from: https://stackoverflow.com/a/7639754 - */ + * Takes an UTF-32 encoded string and returns a hex string representation of the bytes (uppercase) + * + * ex: ['👱'] = "1F471" // see UTF encoding at https://www.compart.com/en/unicode/U+1F471 + * + * adapted from: https://stackoverflow.com/a/7639754 + */ std::string to_hex(const std::basic_string &str) { std::stringstream ss; @@ -1427,16 +1427,16 @@ namespace platf { } /** - * Here we receive a single UTF-8 encoded char at a time, - * the trick is to convert it to UTF-32 then send CTRL+SHIFT+U+ in order to produce any - * unicode character, see: https://en.wikipedia.org/wiki/Unicode_input - * - * ex: - * - when receiving UTF-8 [0xF0 0x9F 0x91 0xB1] (which is '👱') - * - we'll convert it to UTF-32 [0x1F471] - * - then type: CTRL+SHIFT+U+1F471 - * see the conversion at: https://www.compart.com/en/unicode/U+1F471 - */ + * Here we receive a single UTF-8 encoded char at a time, + * the trick is to convert it to UTF-32 then send CTRL+SHIFT+U+{HEXCODE} in order to produce any + * unicode character, see: https://en.wikipedia.org/wiki/Unicode_input + * + * ex: + * - when receiving UTF-8 [0xF0 0x9F 0x91 0xB1] (which is '👱') + * - we'll convert it to UTF-32 [0x1F471] + * - then type: CTRL+SHIFT+U+1F471 + * see the conversion at: https://www.compart.com/en/unicode/U+1F471 + */ void unicode(input_t &input, char *utf8, int size) { auto kb = ((input_raw_t *) input.get())->keyboard_input.get(); @@ -1549,13 +1549,13 @@ namespace platf { } /** - * @brief Initalize a new keyboard and return it. - * - * EXAMPLES: - * ```cpp - * auto my_keyboard = keyboard(); - * ``` - */ + * @brief Initialize a new keyboard and return it. + * + * EXAMPLES: + * ```cpp + * auto my_keyboard = keyboard(); + * ``` + */ evdev_t keyboard() { evdev_t dev { libevdev_new() }; @@ -1578,13 +1578,13 @@ namespace platf { } /** - * @brief Initalize a new uinput virtual mouse and return it. - * - * EXAMPLES: - * ```cpp - * auto my_mouse = mouse(); - * ``` - */ + * @brief Initialize a new `uinput` virtual mouse and return it. + * + * EXAMPLES: + * ```cpp + * auto my_mouse = mouse(); + * ``` + */ evdev_t mouse() { evdev_t dev { libevdev_new() }; @@ -1629,13 +1629,13 @@ namespace platf { } /** - * @brief Initalize a new uinput virtual touchscreen and return it. - * - * EXAMPLES: - * ```cpp - * auto my_touchscreen = touchscreen(); - * ``` - */ + * @brief Initialize a new `uinput` virtual touchscreen and return it. + * + * EXAMPLES: + * ```cpp + * auto my_touchscreen = touchscreen(); + * ``` + */ evdev_t touchscreen() { evdev_t dev { libevdev_new() }; @@ -1679,13 +1679,13 @@ namespace platf { } /** - * @brief Initalize a new uinput virtual X360 gamepad and return it. - * - * EXAMPLES: - * ```cpp - * auto my_x360 = x360(); - * ``` - */ + * @brief Initialize a new `uinput` virtual X360 gamepad and return it. + * + * EXAMPLES: + * ```cpp + * auto my_x360 = x360(); + * ``` + */ evdev_t x360() { evdev_t dev { libevdev_new() }; @@ -1756,13 +1756,13 @@ namespace platf { } /** - * @brief Initalize the input system and return it. - * - * EXAMPLES: - * ```cpp - * auto my_input = input(); - * ``` - */ + * @brief Initialize the input system and return it. + * + * EXAMPLES: + * ```cpp + * auto my_input = input(); + * ``` + */ input_t input() { input_t result { new input_raw_t() }; diff --git a/src/platform/linux/kmsgrab.cpp b/src/platform/linux/kmsgrab.cpp index cffa98c0..090451d8 100644 --- a/src/platform/linux/kmsgrab.cpp +++ b/src/platform/linux/kmsgrab.cpp @@ -552,7 +552,7 @@ namespace platf { return -1; } - //TODO: surf_sd = fb->to_sd(); + // TODO: surf_sd = fb->to_sd(); auto crct = card.crtc(plane->crtc_id); kms::print(plane.get(), fb.get(), crct.get()); @@ -999,15 +999,15 @@ namespace platf { } /** - * On Wayland, it's not possible to determine the position of the monitor on the desktop with KMS. - * Wayland does allow applications to query attached monitors on the desktop, - * however, the naming scheme is not standardized across implementations. - * - * As a result, correlating the KMS output to the wayland outputs is guess work at best. - * But, it's necessary for absolute mouse coordinates to work. - * - * This is an ugly hack :( - */ + * On Wayland, it's not possible to determine the position of the monitor on the desktop with KMS. + * Wayland does allow applications to query attached monitors on the desktop, + * however, the naming scheme is not standardized across implementations. + * + * As a result, correlating the KMS output to the wayland outputs is guess work at best. + * But, it's necessary for absolute mouse coordinates to work. + * + * This is an ugly hack :( + */ void correlate_to_wayland(std::vector &cds) { auto monitors = wl::monitors(); diff --git a/src/platform/linux/misc.h b/src/platform/linux/misc.h index e4a59f67..bcecc1ec 100644 --- a/src/platform/linux/misc.h +++ b/src/platform/linux/misc.h @@ -1,5 +1,4 @@ -#ifndef SUNSHINE_PLATFORM_MISC_H -#define SUNSHINE_PLATFORM_MISC_H +#pragma once #include #include @@ -29,5 +28,3 @@ namespace dyn { handle(const std::vector &libs); } // namespace dyn - -#endif \ No newline at end of file diff --git a/src/platform/linux/publish.cpp b/src/platform/linux/publish.cpp index 6c6d7ede..ea97b114 100644 --- a/src/platform/linux/publish.cpp +++ b/src/platform/linux/publish.cpp @@ -12,7 +12,9 @@ using namespace std::literals; namespace avahi { - /** Error codes used by avahi */ + /** + * @brief Error codes used by avahi + */ enum err_e { OK = 0, /**< OK */ ERR_FAILURE = -1, /**< Generic error code */ @@ -113,7 +115,9 @@ namespace avahi { CLIENT_NO_FAIL = 2 /**< Don't fail if the daemon is not available when avahi_client_new() is called, instead enter CLIENT_CONNECTING state and wait for the daemon to appear */ }; - /** Some flags for publishing functions */ + /** + * @brief Some flags for publishing functions + */ enum PublishFlags { PUBLISH_UNIQUE = 1, /**< For raw records: The RRset is intended to be unique */ PUBLISH_NO_PROBE = 2, /**< For raw records: Though the RRset is intended to be unique no probes shall be sent */ @@ -434,4 +438,4 @@ namespace platf::publish { return std::make_unique(std::thread { avahi::simple_poll_loop, poll.get() }); } -} // namespace platf::publish \ No newline at end of file +} // namespace platf::publish diff --git a/src/platform/linux/vaapi.cpp b/src/platform/linux/vaapi.cpp index 8f3c3705..00881aae 100644 --- a/src/platform/linux/vaapi.cpp +++ b/src/platform/linux/vaapi.cpp @@ -7,8 +7,7 @@ extern "C" { #include #include #if !VA_CHECK_VERSION(1, 9, 0) -/* vaSyncBuffer stub allows Sunshine built against libva <2.9.0 - to link against ffmpeg on libva 2.9.0 or later */ +// vaSyncBuffer stub allows Sunshine built against libva <2.9.0 to link against ffmpeg on libva 2.9.0 or later VAStatus vaSyncBuffer( VADisplay dpy, @@ -56,10 +55,7 @@ namespace va { // Needs to be closed manually int fd; - /* - * Total size of this object (may include regions which are - * not part of the surface). - */ + // Total size of this object (may include regions which are not part of the surface) uint32_t size; // Format modifier applied to this object, not sure what that means uint64_t drm_format_modifier; @@ -85,7 +81,9 @@ namespace va { } layers[4]; }; - /** Currently defined profiles */ + /** + * @brief Currently defined profiles + */ enum class profile_e { // Profile ID used for video processing. ProfileNone = -1, @@ -135,9 +133,9 @@ namespace va { IDCT = 3, MoComp = 4, Deblocking = 5, - EncSlice = 6, /* slice level encode */ - EncPicture = 7, /* pictuer encode, JPEG, etc */ - /* + EncSlice = 6, /** slice level encode */ + EncPicture = 7, /** picture encode, JPEG, etc */ + /** * For an implementation that supports a low power/high performance variant * for slice level encode, it can choose to expose the * VAEntrypointEncSliceLP entrypoint. Certain encoding tools may not be @@ -148,7 +146,7 @@ namespace va { EncSliceLP = 8, VideoProc = 10, /**< Video pre/post-processing. */ /** - * \brief FEI + * @brief FEI * * The purpose of FEI (Flexible Encoding Infrastructure) is to allow applications to * have more controls and trade off quality for speed with their own IPs. @@ -162,10 +160,10 @@ namespace va { * and VAEncFEIDistortionBufferType) for FEI entry function. * If separate PAK is set, two extra input buffers * (VAEncFEIMVBufferType, VAEncFEIMBModeBufferType) are needed for PAK input. - **/ + */ FEI = 11, /** - * \brief Stats + * @brief Stats * * A pre-processing function for getting some statistics and motion vectors is added, * and some extra controls for Encode pipeline are provided. The application can @@ -179,19 +177,19 @@ namespace va { * (VAStatsStatisticsParameterBufferType) and one or two output buffers * (VAStatsStatisticsBufferType, VAStatsStatisticsBottomFieldBufferType (for interlace only) * and VAStatsMVBufferType) are needed for this entry point. - **/ + */ Stats = 12, /** - * \brief ProtectedTEEComm + * @brief ProtectedTEEComm * * A function for communicating with TEE (Trusted Execution Environment). - **/ + */ ProtectedTEEComm = 13, /** - * \brief ProtectedContent + * @brief ProtectedContent * * A function for protected content to decrypt encrypted content. - **/ + */ ProtectedContent = 14, }; @@ -475,11 +473,11 @@ namespace va { }; /** - * This is a private structure of FFmpeg, I need this to manually create - * a VAAPI hardware context - * - * xdisplay will not be used internally by FFmpeg - */ + * This is a private structure of FFmpeg, I need this to manually create + * a VAAPI hardware context + * + * xdisplay will not be used internally by FFmpeg + */ typedef struct VAAPIDevicePriv { union { void *xdisplay; @@ -489,22 +487,22 @@ namespace va { } VAAPIDevicePriv; /** - * VAAPI connection details. - * - * Allocated as AVHWDeviceContext.hwctx - */ + * VAAPI connection details. + * + * Allocated as AVHWDeviceContext.hwctx + */ typedef struct AVVAAPIDeviceContext { /** - * The VADisplay handle, to be filled by the user. - */ + * The VADisplay handle, to be filled by the user. + */ va::VADisplay display; /** - * Driver quirks to apply - this is filled by av_hwdevice_ctx_init(), - * with reference to a table of known drivers, unless the - * AV_VAAPI_DRIVER_QUIRK_USER_SET bit is already present. The user - * may need to refer to this field when performing any later - * operations using VAAPI with the same VADisplay. - */ + * Driver quirks to apply - this is filled by av_hwdevice_ctx_init(), + * with reference to a table of known drivers, unless the + * AV_VAAPI_DRIVER_QUIRK_USER_SET bit is already present. The user + * may need to refer to this field when performing any later + * operations using VAAPI with the same VADisplay. + */ unsigned int driver_quirks; } AVVAAPIDeviceContext; diff --git a/src/platform/linux/vaapi.h b/src/platform/linux/vaapi.h index 7f03c5a7..ab59bce9 100644 --- a/src/platform/linux/vaapi.h +++ b/src/platform/linux/vaapi.h @@ -1,5 +1,4 @@ -#ifndef SUNSHINE_VAAPI_H -#define SUNSHINE_VAAPI_H +#pragma once #include "misc.h" #include "src/platform/common.h" @@ -9,12 +8,12 @@ namespace egl { } namespace va { /** - * Width --> Width of the image - * Height --> Height of the image - * offset_x --> Horizontal offset of the image in the texture - * offset_y --> Vertical offset of the image in the texture - * file_t card --> The file descriptor of the render device used for encoding - */ + * Width --> Width of the image + * Height --> Height of the image + * offset_x --> Horizontal offset of the image in the texture + * offset_y --> Vertical offset of the image in the texture + * file_t card --> The file descriptor of the render device used for encoding + */ std::shared_ptr make_hwdevice(int width, int height, bool vram); std::shared_ptr @@ -29,4 +28,3 @@ namespace va { int init(); } // namespace va -#endif \ No newline at end of file diff --git a/src/platform/linux/wayland.h b/src/platform/linux/wayland.h index 18caf990..a49c8d86 100644 --- a/src/platform/linux/wayland.h +++ b/src/platform/linux/wayland.h @@ -1,5 +1,4 @@ -#ifndef SUNSHINE_WAYLAND_H -#define SUNSHINE_WAYLAND_H +#pragma once #include @@ -180,9 +179,9 @@ namespace wl { class display_t { public: /** - * Initialize display with display_name - * If display_name == nullptr -> display_name = std::getenv("WAYLAND_DISPLAY") - */ + * Initialize display with display_name + * If display_name == nullptr -> display_name = std::getenv("WAYLAND_DISPLAY") + */ int init(const char *display_name = nullptr); @@ -246,5 +245,3 @@ namespace wl { init() { return -1; } } // namespace wl #endif - -#endif \ No newline at end of file diff --git a/src/platform/linux/x11grab.cpp b/src/platform/linux/x11grab.cpp index 9a46afff..9d6b08c9 100644 --- a/src/platform/linux/x11grab.cpp +++ b/src/platform/linux/x11grab.cpp @@ -1,7 +1,3 @@ -// -// Created by loki on 6/21/19. -// - #include "src/platform/common.h" #include @@ -389,10 +385,10 @@ namespace platf { mem_type_e mem_type; - /* - * Last X (NOT the streamed monitor!) size. - * This way we can trigger reinitialization if the dimensions changed while streaming - */ + /** + * Last X (NOT the streamed monitor!) size. + * This way we can trigger reinitialization if the dimensions changed while streaming + */ // int env_width, env_height; x11_attr_t(mem_type_e mem_type): @@ -468,11 +464,11 @@ namespace platf { } /** - * Called when the display attributes should change. - */ + * Called when the display attributes should change. + */ void refresh() { - x11::GetWindowAttributes(xdisplay.get(), xwindow, &xattr); //Update xattr's + x11::GetWindowAttributes(xdisplay.get(), xwindow, &xattr); // Update xattr's } capture_e @@ -521,7 +517,7 @@ namespace platf { snapshot(const pull_free_image_cb_t &pull_free_image_cb, std::shared_ptr &img_out, std::chrono::milliseconds timeout, bool cursor) { refresh(); - //The whole X server changed, so we must reinit everything + // The whole X server changed, so we must reinit everything if (xattr.width != env_width || xattr.height != env_height) { BOOST_LOG(warning) << "X dimensions changed in non-SHM mode, request reinit"sv; return capture_e::reinit; @@ -657,7 +653,7 @@ namespace platf { capture_e snapshot(const pull_free_image_cb_t &pull_free_image_cb, std::shared_ptr &img_out, std::chrono::milliseconds timeout, bool cursor) { - //The whole X server changed, so we must reinit everything + // The whole X server changed, so we must reinit everything if (xattr.width != env_width || xattr.height != env_height) { BOOST_LOG(warning) << "X dimensions changed in SHM mode, request reinit"sv; return capture_e::reinit; diff --git a/src/platform/linux/x11grab.h b/src/platform/linux/x11grab.h index 89428a49..c01b0bb7 100644 --- a/src/platform/linux/x11grab.h +++ b/src/platform/linux/x11grab.h @@ -1,5 +1,4 @@ -#ifndef SUNSHINE_X11_GRAB -#define SUNSHINE_X11_GRAB +#pragma once #include @@ -34,11 +33,11 @@ namespace platf::x11 { capture(egl::cursor_t &img); /** - * Capture and blend the cursor into the image - * - * img <-- destination image - * offsetX, offsetY <--- Top left corner of the virtual screen - */ + * Capture and blend the cursor into the image + * + * img <-- destination image + * offsetX, offsetY <--- Top left corner of the virtual screen + */ void blend(img_t &img, int offsetX, int offsetY); @@ -66,5 +65,3 @@ namespace platf::x11 { make_display() { return nullptr; } #endif } // namespace platf::x11 - -#endif \ No newline at end of file diff --git a/src/platform/macos/av_audio.h b/src/platform/macos/av_audio.h index 48a83ac4..a31458f5 100644 --- a/src/platform/macos/av_audio.h +++ b/src/platform/macos/av_audio.h @@ -1,5 +1,4 @@ -#ifndef SUNSHINE_PLATFORM_AV_AUDIO_H -#define SUNSHINE_PLATFORM_AV_AUDIO_H +#pragma once #import @@ -22,5 +21,3 @@ - (int)setupMicrophone:(AVCaptureDevice *)device sampleRate:(UInt32)sampleRate frameSize:(UInt32)frameSize channels:(UInt8)channels; @end - -#endif //SUNSHINE_PLATFORM_AV_AUDIO_H diff --git a/src/platform/macos/av_audio.m b/src/platform/macos/av_audio.m index ef1ce294..5e336d77 100644 --- a/src/platform/macos/av_audio.m +++ b/src/platform/macos/av_audio.m @@ -126,7 +126,7 @@ CMSampleBufferGetAudioBufferListWithRetainedBlockBuffer(sampleBuffer, NULL, &audioBufferList, sizeof(audioBufferList), NULL, NULL, 0, &blockBuffer); - //NSAssert(audioBufferList.mNumberBuffers == 1, @"Expected interlveaved PCM format but buffer contained %u streams", audioBufferList.mNumberBuffers); + // NSAssert(audioBufferList.mNumberBuffers == 1, @"Expected interlveaved PCM format but buffer contained %u streams", audioBufferList.mNumberBuffers); // this is safe, because an interleaved PCM stream has exactly one buffer // and we don't want to do sanity checks in a performance critical exec path diff --git a/src/platform/macos/av_img_t.h b/src/platform/macos/av_img_t.h index f946c6d5..1ed60914 100644 --- a/src/platform/macos/av_img_t.h +++ b/src/platform/macos/av_img_t.h @@ -1,5 +1,4 @@ -#ifndef av_img_t_h -#define av_img_t_h +#pragma once #include "src/platform/common.h" @@ -14,5 +13,3 @@ namespace platf { ~av_img_t(); }; } // namespace platf - -#endif /* av_img_t_h */ diff --git a/src/platform/macos/av_video.h b/src/platform/macos/av_video.h index d654ff67..a6a0d9ce 100644 --- a/src/platform/macos/av_video.h +++ b/src/platform/macos/av_video.h @@ -1,5 +1,4 @@ -#ifndef SUNSHINE_PLATFORM_AV_VIDEO_H -#define SUNSHINE_PLATFORM_AV_VIDEO_H +#pragma once #import @@ -38,5 +37,3 @@ typedef bool (^FrameCallbackBlock)(CMSampleBufferRef); - (dispatch_semaphore_t)capture:(FrameCallbackBlock)frameCallback; @end - -#endif //SUNSHINE_PLATFORM_AV_VIDEO_H diff --git a/src/platform/macos/display.mm b/src/platform/macos/display.mm index a09dad19..45b98f54 100644 --- a/src/platform/macos/display.mm +++ b/src/platform/macos/display.mm @@ -150,12 +150,12 @@ namespace platf { } /** - * A bridge from the pure C++ code of the hwdevice_t class to the pure Objective C code. - * - * display --> an opaque pointer to an object of this class - * width --> the intended capture width - * height --> the intended capture height - */ + * A bridge from the pure C++ code of the hwdevice_t class to the pure Objective C code. + * + * display --> an opaque pointer to an object of this class + * width --> the intended capture width + * height --> the intended capture height + */ static void setResolution(void *display, int width, int height) { [static_cast(display) setFrameWidth:width frameHeight:height]; diff --git a/src/platform/macos/misc.h b/src/platform/macos/misc.h index 10b89bf4..942f2701 100644 --- a/src/platform/macos/misc.h +++ b/src/platform/macos/misc.h @@ -1,5 +1,4 @@ -#ifndef SUNSHINE_PLATFORM_MISC_H -#define SUNSHINE_PLATFORM_MISC_H +#pragma once #include @@ -14,5 +13,3 @@ namespace dyn { handle(const std::vector &libs); } // namespace dyn - -#endif diff --git a/src/platform/macos/nv12_zero_device.h b/src/platform/macos/nv12_zero_device.h index 53b6eff1..6ff1abec 100644 --- a/src/platform/macos/nv12_zero_device.h +++ b/src/platform/macos/nv12_zero_device.h @@ -1,5 +1,4 @@ -#ifndef vtdevice_h -#define vtdevice_h +#pragma once #include "src/platform/common.h" @@ -29,5 +28,3 @@ namespace platf { }; } // namespace platf - -#endif /* vtdevice_h */ diff --git a/src/platform/macos/publish.cpp b/src/platform/macos/publish.cpp index c22d991d..57a35e22 100644 --- a/src/platform/macos/publish.cpp +++ b/src/platform/macos/publish.cpp @@ -12,7 +12,9 @@ using namespace std::literals; namespace avahi { - /** Error codes used by avahi */ + /** + * @brief Error codes used by avahi + */ enum err_e { OK = 0, /**< OK */ ERR_FAILURE = -1, /**< Generic error code */ @@ -113,7 +115,9 @@ namespace avahi { CLIENT_NO_FAIL = 2 /**< Don't fail if the daemon is not available when avahi_client_new() is called, instead enter CLIENT_CONNECTING state and wait for the daemon to appear */ }; - /** Some flags for publishing functions */ + /** + * @brief Some flags for publishing functions + */ enum PublishFlags { PUBLISH_UNIQUE = 1, /**< For raw records: The RRset is intended to be unique */ PUBLISH_NO_PROBE = 2, /**< For raw records: Though the RRset is intended to be unique no probes shall be sent */ @@ -434,4 +438,4 @@ namespace platf::publish { return std::make_unique(std::thread { avahi::simple_poll_loop, poll.get() }); } -}; // namespace platf::publish +} // namespace platf::publish diff --git a/src/platform/windows/audio.cpp b/src/platform/windows/audio.cpp index 7da6b9a7..fe4df13a 100644 --- a/src/platform/windows/audio.cpp +++ b/src/platform/windows/audio.cpp @@ -1,7 +1,3 @@ -// -// Created by loki on 1/12/20. -// - #include #include #include @@ -589,13 +585,13 @@ namespace platf::audio { } /** - * If the requested sink is a virtual sink, meaning no speakers attached to - * the host, then we can seamlessly set the format to stereo and surround sound. - * - * Any virtual sink detected will be prefixed by: - * virtual-(format name) - * If it doesn't contain that prefix, then the format will not be changed - */ + * If the requested sink is a virtual sink, meaning no speakers attached to + * the host, then we can seamlessly set the format to stereo and surround sound. + * + * Any virtual sink detected will be prefixed by: + * virtual-(format name) + * If it doesn't contain that prefix, then the format will not be changed + */ std::optional set_format(const std::string &sink) { std::string_view sv { sink.c_str(), sink.size() }; diff --git a/src/platform/windows/display.h b/src/platform/windows/display.h index 66b23d74..8facfdcc 100644 --- a/src/platform/windows/display.h +++ b/src/platform/windows/display.h @@ -1,9 +1,4 @@ -// -// Created by loki on 4/23/20. -// - -#ifndef SUNSHINE_DISPLAY_H -#define SUNSHINE_DISPLAY_H +#pragma once #include #include @@ -237,5 +232,3 @@ namespace platf::dxgi { std::atomic next_image_id; }; } // namespace platf::dxgi - -#endif diff --git a/src/platform/windows/display_base.cpp b/src/platform/windows/display_base.cpp index 4eff0456..cd997aa7 100644 --- a/src/platform/windows/display_base.cpp +++ b/src/platform/windows/display_base.cpp @@ -1,7 +1,3 @@ -// -// Created by loki on 1/12/20. -// - #include #include #include @@ -537,7 +533,7 @@ namespace platf::dxgi { } } - //FIXME: Duplicate output on RX580 in combination with DOOM (2016) --> BSOD + // FIXME: Duplicate output on RX580 in combination with DOOM (2016) --> BSOD { // IDXGIOutput5 is optional, but can provide improved performance and wide color support dxgi::output5_t output5 {}; diff --git a/src/platform/windows/display_ram.cpp b/src/platform/windows/display_ram.cpp index bfd90c5d..6bd00b2a 100644 --- a/src/platform/windows/display_ram.cpp +++ b/src/platform/windows/display_ram.cpp @@ -83,7 +83,7 @@ namespace platf::dxgi { auto colors_out = (std::uint8_t *) &cursor_pixel; auto colors_in = (std::uint8_t *) img_pixel_p; - //TODO: When use of IDXGIOutput5 is implemented, support different color formats + // TODO: When use of IDXGIOutput5 is implemented, support different color formats auto alpha = colors_out[3]; if (alpha == 255) { *img_pixel_p = cursor_pixel; @@ -97,7 +97,7 @@ namespace platf::dxgi { void apply_color_masked(int *img_pixel_p, int cursor_pixel) { - //TODO: When use of IDXGIOutput5 is implemented, support different color formats + // TODO: When use of IDXGIOutput5 is implemented, support different color formats auto alpha = ((std::uint8_t *) &cursor_pixel)[3]; if (alpha == 0xFF) { *img_pixel_p ^= cursor_pixel; @@ -270,7 +270,7 @@ namespace platf::dxgi { return capture_e::reinit; } - //Copy from GPU to CPU + // Copy from GPU to CPU device_ctx->CopyResource(texture.get(), src.get()); } } diff --git a/src/platform/windows/display_vram.cpp b/src/platform/windows/display_vram.cpp index 9ea507f4..42c3b01a 100644 --- a/src/platform/windows/display_vram.cpp +++ b/src/platform/windows/display_vram.cpp @@ -533,7 +533,7 @@ namespace platf::dxgi { frame_texture->AddRef(); hwframe_texture.reset(frame_texture); - float info_in[16 / sizeof(float)] { 1.0f / (float) out_width_f }; //aligned to 16-byte + float info_in[16 / sizeof(float)] { 1.0f / (float) out_width_f }; // aligned to 16-byte info_scene = make_buffer(device.get(), info_in); if (!info_scene) { diff --git a/src/platform/windows/misc.cpp b/src/platform/windows/misc.cpp index 0b59d343..5ecb11b2 100644 --- a/src/platform/windows/misc.cpp +++ b/src/platform/windows/misc.cpp @@ -229,10 +229,10 @@ namespace platf { } /** - * @brief A function to obtain the current sessions user's primary token with elevated privileges - * - * @return The users token, if user has admin capability it will be elevated. If not, it will return back a limited token. On error, nullptrs - */ + * @brief A function to obtain the current sessions user's primary token with elevated privileges + * + * @return The users token, if user has admin capability it will be elevated. If not, it will return back a limited token. On error, nullptrs + */ HANDLE retrieve_users_token(bool elevated) { DWORD consoleSessionId; @@ -430,15 +430,15 @@ namespace platf { } /** - * @brief Creates a bp::child object from the results of launching a process - * - * @param process_launched A boolean indicating whether the launch was successful or not - * @param cmd The command that was used to launch the process - * @param ec A reference to an std::error_code object that will store any error that occurred during the launch - * @param process_info A reference to a PROCESS_INFORMATION structure that contains information about the new process - * @param group A pointer to a bp::group object that will add the new process to its group, if not null - * @return A bp::child object representing the new process, or an empty bp::child object if the launch failed or an error occurred - */ + * @brief Creates a bp::child object from the results of launching a process + * + * @param process_launched A boolean indicating whether the launch was successful or not + * @param cmd The command that was used to launch the process + * @param ec A reference to an std::error_code object that will store any error that occurred during the launch + * @param process_info A reference to a PROCESS_INFORMATION structure that contains information about the new process + * @param group A pointer to a bp::group object that will add the new process to its group, if not null + * @return A bp::child object representing the new process, or an empty bp::child object if the launch failed or an error occurred + */ bp::child create_boost_child_from_results(bool process_launched, const std::string &cmd, std::error_code &ec, PROCESS_INFORMATION &process_info, bp::group *group) { // Use RAII to ensure the process is closed when we're done with it, even if there was an error. @@ -477,12 +477,12 @@ namespace platf { } /** - * @brief Impersonate the current user, invoke the callback function, then returns back to system context. - * - * @param user_token A handle to the user's token that was obtained from the shell - * @param callback A function that will be executed while impersonating the user - * @return An std::error_code object that will store any error that occurred during the impersonation - */ + * @brief Impersonate the current user, invoke the callback function, then returns back to system context. + * + * @param user_token A handle to the user's token that was obtained from the shell + * @param callback A function that will be executed while impersonating the user + * @return An std::error_code object that will store any error that occurred during the impersonation + */ std::error_code impersonate_current_user(HANDLE user_token, std::function callback) { std::error_code ec; @@ -515,12 +515,12 @@ namespace platf { } /** - * @brief A function to create a STARTUPINFOEXW structure for launching a process - * - * @param file A pointer to a FILE object that will be used as the standard output and error for the new process, or null if not needed - * @param ec A reference to an std::error_code object that will store any error that occurred during the creation of the structure - * @return A STARTUPINFOEXW structure that contains information about how to launch the new process - */ + * @brief A function to create a STARTUPINFOEXW structure for launching a process + * + * @param file A pointer to a FILE object that will be used as the standard output and error for the new process, or null if not needed + * @param ec A reference to an std::error_code object that will store any error that occurred during the creation of the structure + * @return A STARTUPINFOEXW structure that contains information about how to launch the new process + */ STARTUPINFOEXW create_startup_info(FILE *file, std::error_code &ec) { // Initialize a zeroed-out STARTUPINFOEXW structure and set its size @@ -563,23 +563,23 @@ namespace platf { } /** - * @brief Runs a command on the users profile - * - * This function launches a child process as the user, using the current user's environment - * and a specific working directory. If the launch is successful, a `bp::child` object representing the new - * process is returned. Otherwise, an error code is returned. - * - * @param elevated Specify to elevate the process or not - * @param interactive Specifies whether this will run in a window or hidden - * @param cmd The command to run - * @param working_dir The working directory for the new process - * @param env The environment variables to use for the new process - * @param file A file object to redirect the child process's output to (may be nullptr) - * @param ec An error code, set to indicate any errors that occur during the launch process - * @param group A pointer to a `bp::group` object to which the new process should belong (may be nullptr) - * - * @return A `bp::child` object representing the new process, or an empty `bp::child` object if the launch fails - */ + * @brief Runs a command on the users profile + * + * This function launches a child process as the user, using the current user's environment + * and a specific working directory. If the launch is successful, a `bp::child` object representing the new + * process is returned. Otherwise, an error code is returned. + * + * @param elevated Specify to elevate the process or not + * @param interactive Specifies whether this will run in a window or hidden + * @param cmd The command to run + * @param working_dir The working directory for the new process + * @param env The environment variables to use for the new process + * @param file A file object to redirect the child process's output to (may be nullptr) + * @param ec An error code, set to indicate any errors that occur during the launch process + * @param group A pointer to a `bp::group` object to which the new process should belong (may be nullptr) + * + * @return A `bp::child` object representing the new process, or an empty `bp::child` object if the launch fails + */ bp::child run_command(bool elevated, bool interactive, const std::string &cmd, boost::filesystem::path &working_dir, bp::environment &env, FILE *file, std::error_code &ec, bp::group *group) { BOOL ret; @@ -1091,4 +1091,4 @@ namespace platf { } return {}; } -} // namespace platf \ No newline at end of file +} // namespace platf diff --git a/src/platform/windows/misc.h b/src/platform/windows/misc.h index 016580fc..c6df94d5 100644 --- a/src/platform/windows/misc.h +++ b/src/platform/windows/misc.h @@ -1,5 +1,4 @@ -#ifndef SUNSHINE_WINDOWS_MISC_H -#define SUNSHINE_WINDOWS_MISC_H +#pragma once #include #include @@ -18,5 +17,3 @@ namespace platf { std::chrono::nanoseconds qpc_time_difference(int64_t performance_counter1, int64_t performance_counter2); } // namespace platf - -#endif \ No newline at end of file diff --git a/src/process.cpp b/src/process.cpp index b1efca21..bece2ddc 100644 --- a/src/process.cpp +++ b/src/process.cpp @@ -1,5 +1,3 @@ -// Created by loki on 12/14/19. - #define BOOST_BIND_GLOBAL_PLACEHOLDERS #include "process.h" diff --git a/src/process.h b/src/process.h index 418ed3a7..8a8dcaba 100644 --- a/src/process.h +++ b/src/process.h @@ -1,7 +1,4 @@ -// Created by loki on 12/14/19. - -#ifndef SUNSHINE_PROCESS_H -#define SUNSHINE_PROCESS_H +#pragma once #ifndef __kernel_entry #define __kernel_entry @@ -19,27 +16,27 @@ namespace proc { using file_t = util::safe_ptr_v2; typedef config::prep_cmd_t cmd_t; - /* - * pre_cmds -- guaranteed to be executed unless any of the commands fail. - * detached -- commands detached from Sunshine - * cmd -- Runs indefinitely until: - * No session is running and a different set of commands it to be executed - * Command exits - * working_dir -- the process working directory. This is required for some games to run properly. - * cmd_output -- - * empty -- The output of the commands are appended to the output of sunshine - * "null" -- The output of the commands are discarded - * filename -- The output of the commands are appended to filename - */ + /** + * pre_cmds -- guaranteed to be executed unless any of the commands fail. + * detached -- commands detached from Sunshine + * cmd -- Runs indefinitely until: + * No session is running and a different set of commands it to be executed + * Command exits + * working_dir -- the process working directory. This is required for some games to run properly. + * cmd_output -- + * empty -- The output of the commands are appended to the output of sunshine + * "null" -- The output of the commands are discarded + * filename -- The output of the commands are appended to filename + */ struct ctx_t { std::vector prep_cmds; /** - * Some applications, such as Steam, - * either exit quickly, or keep running indefinitely. - * Steam.exe is one such application. - * That is why some applications need be run and forgotten about - */ + * Some applications, such as Steam, + * either exit quickly, or keep running indefinitely. + * Steam.exe is one such application. + * That is why some applications need be run and forgotten about + */ std::vector detached; std::string name; @@ -66,8 +63,8 @@ namespace proc { execute(int app_id); /** - * @return _app_id if a process is running, otherwise returns 0 - */ + * @return _app_id if a process is running, otherwise returns 0 + */ int running(); @@ -102,9 +99,9 @@ namespace proc { }; /** - * Calculate a stable id based on name and image data - * @return tuple of id calculated without index (for use if no collision) and one with -*/ + * Calculate a stable id based on name and image data + * @return tuple of id calculated without index (for use if no collision) and one with + */ std::tuple calculate_app_id(const std::string &app_name, std::string app_image_path, int index); @@ -117,4 +114,3 @@ namespace proc { extern proc_t proc; } // namespace proc -#endif // SUNSHINE_PROCESS_H diff --git a/src/round_robin.h b/src/round_robin.h index 37e01033..03845e61 100644 --- a/src/round_robin.h +++ b/src/round_robin.h @@ -1,5 +1,4 @@ -#ifndef KITTY_UTIL_ITERATOR_H -#define KITTY_UTIL_ITERATOR_H +#pragma once #include @@ -180,5 +179,3 @@ namespace round_robin_util { return round_robin_t(begin, end); } } // namespace round_robin_util - -#endif diff --git a/src/rtsp.cpp b/src/rtsp.cpp index 653afde5..73678dd3 100644 --- a/src/rtsp.cpp +++ b/src/rtsp.cpp @@ -1,5 +1,3 @@ -// Created by loki on 2/2/20. - #define BOOST_BIND_GLOBAL_PLACEHOLDERS extern "C" { @@ -501,10 +499,10 @@ namespace rtsp_stream { auto mapping_p = stream_config.mapping; /** - * GFE advertises incorrect mapping for normal quality configurations, - * as a result, Moonlight rotates all channels from index '3' to the right - * To work around this, rotate channels to the left from index '3' - */ + * GFE advertises incorrect mapping for normal quality configurations, + * as a result, Moonlight rotates all channels from index '3' to the right + * To work around this, rotate channels to the left from index '3' + */ if (x == audio::SURROUND51 || x == audio::SURROUND71) { std::copy_n(mapping_p, stream_config.channelCount, mapping); std::rotate(mapping + 3, mapping + 4, mapping + audio::MAX_STREAM_CONFIG); diff --git a/src/rtsp.h b/src/rtsp.h index f33030a0..388706a5 100644 --- a/src/rtsp.h +++ b/src/rtsp.h @@ -1,7 +1,4 @@ -// Created by loki on 2/2/20. - -#ifndef SUNSHINE_RTSP_H -#define SUNSHINE_RTSP_H +#pragma once #include @@ -27,5 +24,3 @@ namespace rtsp_stream { rtpThread(); } // namespace rtsp_stream - -#endif // SUNSHINE_RTSP_H diff --git a/src/stream.cpp b/src/stream.cpp index a2ab42fb..0afcac59 100644 --- a/src/stream.cpp +++ b/src/stream.cpp @@ -1,5 +1,3 @@ -// Created by loki on 6/5/19. - #include "process.h" #include @@ -359,11 +357,11 @@ namespace stream { }; /** - * First part of cipher must be struct of type control_encrypted_t - * - * returns empty string_view on failure - * returns string_view pointing to payload data - */ + * First part of cipher must be struct of type control_encrypted_t + * + * returns empty string_view on failure + * returns string_view pointing to payload data + */ template static inline std::string_view encode_control(session_t *session, const std::string_view &plaintext, std::array &tagged_cipher) { diff --git a/src/stream.h b/src/stream.h index c8803f3c..95c2e232 100644 --- a/src/stream.h +++ b/src/stream.h @@ -1,7 +1,4 @@ -// Created by loki on 6/5/19. - -#ifndef SUNSHINE_STREAM_H -#define SUNSHINE_STREAM_H +#pragma once #include @@ -49,5 +46,3 @@ namespace stream { state(session_t &session); } // namespace session } // namespace stream - -#endif // SUNSHINE_STREAM_H diff --git a/src/sync.h b/src/sync.h index 9deeaa27..d4e81b9d 100644 --- a/src/sync.h +++ b/src/sync.h @@ -1,7 +1,4 @@ -// Created by loki on 16-4-19. - -#ifndef SUNSHINE_SYNC_H -#define SUNSHINE_SYNC_H +#pragma once #include #include @@ -98,5 +95,3 @@ namespace sync_util { }; } // namespace sync_util - -#endif // SUNSHINE_SYNC_H diff --git a/src/system_tray.cpp b/src/system_tray.cpp index c24c90aa..94195891 100644 --- a/src/system_tray.cpp +++ b/src/system_tray.cpp @@ -37,9 +37,9 @@ using namespace std::literals; namespace system_tray { /** - * @brief Callback for opening the UI from the system tray. - * @param item The tray menu item. - */ + * @brief Callback for opening the UI from the system tray. + * @param item The tray menu item. + */ void tray_open_ui_cb(struct tray_menu *item) { BOOST_LOG(info) << "Opening UI from system tray"sv; @@ -47,45 +47,45 @@ namespace system_tray { } /** - * @brief Callback for opening GitHub Sponsors from the system tray. - * @param item The tray menu item. - */ + * @brief Callback for opening GitHub Sponsors from the system tray. + * @param item The tray menu item. + */ void tray_donate_github_cb(struct tray_menu *item) { platf::open_url("https://github.com/sponsors/LizardByte"); } /** - * @brief Callback for opening MEE6 donation from the system tray. - * @param item The tray menu item. - */ + * @brief Callback for opening MEE6 donation from the system tray. + * @param item The tray menu item. + */ void tray_donate_mee6_cb(struct tray_menu *item) { platf::open_url("https://mee6.xyz/m/804382334370578482"); } /** - * @brief Callback for opening Patreon from the system tray. - * @param item The tray menu item. - */ + * @brief Callback for opening Patreon from the system tray. + * @param item The tray menu item. + */ void tray_donate_patreon_cb(struct tray_menu *item) { platf::open_url("https://www.patreon.com/LizardByte"); } /** - * @brief Callback for opening PayPal donation from the system tray. - * @param item The tray menu item. - */ + * @brief Callback for opening PayPal donation from the system tray. + * @param item The tray menu item. + */ void tray_donate_paypal_cb(struct tray_menu *item) { platf::open_url("https://www.paypal.com/paypalme/ReenigneArcher"); } /** - * @brief Callback for restarting Sunshine from the system tray. - * @param item The tray menu item. - */ + * @brief Callback for restarting Sunshine from the system tray. + * @param item The tray menu item. + */ void tray_restart_cb(struct tray_menu *item) { BOOST_LOG(info) << "Restarting from system tray"sv; @@ -94,9 +94,9 @@ namespace system_tray { } /** - * @brief Callback for exiting Sunshine from the system tray. - * @param item The tray menu item. - */ + * @brief Callback for exiting Sunshine from the system tray. + * @param item The tray menu item. + */ void tray_quit_cb(struct tray_menu *item) { BOOST_LOG(info) << "Quiting from system tray"sv; @@ -138,10 +138,10 @@ namespace system_tray { }; /** - * @brief Create the system tray. - * @details This function has an endless loop, so it should be run in a separate thread. - * @return 1 if the system tray failed to create, otherwise 0 once the tray has been terminated. - */ + * @brief Create the system tray. + * @details This function has an endless loop, so it should be run in a separate thread. + * @return 1 if the system tray failed to create, otherwise 0 once the tray has been terminated. + */ int system_tray() { #ifdef _WIN32 @@ -229,9 +229,9 @@ namespace system_tray { } /** - * @brief Run the system tray with platform specific options. - * @note macOS requires that UI elements be created on the main thread, so the system tray is not implemented for macOS. - */ + * @brief Run the system tray with platform specific options. + * @note macOS requires that UI elements be created on the main thread, so the system tray is not implemented for macOS. + */ void run_tray() { // create the system tray @@ -252,9 +252,9 @@ namespace system_tray { } /** - * @brief Exit the system tray. - * @return 0 after exiting the system tray. - */ + * @brief Exit the system tray. + * @return 0 after exiting the system tray. + */ int end_tray() { tray_exit(); diff --git a/src/system_tray.h b/src/system_tray.h index 81e62afe..2638298e 100644 --- a/src/system_tray.h +++ b/src/system_tray.h @@ -2,8 +2,7 @@ * @file system_tray.h */ -#ifndef SUNSHINE_SYSTEM_TRAY_H -#define SUNSHINE_SYSTEM_TRAY_H +#pragma once // system_tray namespace namespace system_tray { @@ -31,4 +30,3 @@ namespace system_tray { end_tray(); } // namespace system_tray -#endif // SUNSHINE_SYSTEM_TRAY_H diff --git a/src/task_pool.h b/src/task_pool.h index 193f8f23..9315ac78 100644 --- a/src/task_pool.h +++ b/src/task_pool.h @@ -1,5 +1,4 @@ -#ifndef KITTY_TASK_POOL_H -#define KITTY_TASK_POOL_H +#pragma once #include #include @@ -111,8 +110,8 @@ namespace task_pool_util { } /** - * @return an id to potentially delay the task - */ + * @return an id to potentially delay the task. + */ template auto pushDelayed(Function &&newTask, std::chrono::duration duration, Args &&...args) { @@ -146,8 +145,9 @@ namespace task_pool_util { } /** - * @param duration The delay before executing the task - */ + * @param task_id The id of the task to delay. + * @param duration The delay before executing the task. + */ template void delay(task_id_t task_id, std::chrono::duration duration) { @@ -257,4 +257,3 @@ namespace task_pool_util { } }; } // namespace task_pool_util -#endif diff --git a/src/thread_pool.h b/src/thread_pool.h index 5de54758..c130103b 100644 --- a/src/thread_pool.h +++ b/src/thread_pool.h @@ -1,14 +1,12 @@ -#ifndef KITTY_THREAD_POOL_H -#define KITTY_THREAD_POOL_H +#pragma once #include "task_pool.h" #include namespace thread_pool_util { - /* - * Allow threads to execute unhindered - * while keeping full control over the threads. - */ + /** + * Allow threads to execute unhindered while keeping full control over the threads. + */ class ThreadPool: public task_pool_util::TaskPool { public: typedef TaskPool::__task __task; @@ -127,4 +125,3 @@ namespace thread_pool_util { } }; } // namespace thread_pool_util -#endif diff --git a/src/thread_safe.h b/src/thread_safe.h index de8575d5..901dce7a 100644 --- a/src/thread_safe.h +++ b/src/thread_safe.h @@ -1,7 +1,4 @@ -// Created by loki on 6/10/19. - -#ifndef SUNSHINE_THREAD_SAFE_H -#define SUNSHINE_THREAD_SAFE_H +#pragma once #include #include @@ -574,5 +571,3 @@ namespace safe { mail->cleanup(); } } // namespace safe - -#endif // SUNSHINE_THREAD_SAFE_H diff --git a/src/upnp.h b/src/upnp.h index 43068dca..734623c9 100644 --- a/src/upnp.h +++ b/src/upnp.h @@ -1,5 +1,4 @@ -#ifndef SUNSHINE_UPNP_H -#define SUNSHINE_UPNP_H +#pragma once #include "platform/common.h" @@ -7,5 +6,3 @@ namespace upnp { [[nodiscard]] std::unique_ptr start(); } - -#endif diff --git a/src/utility.h b/src/utility.h index bb7f87a0..f2bc29ed 100644 --- a/src/utility.h +++ b/src/utility.h @@ -1,5 +1,4 @@ -#ifndef UTILITY_H -#define UTILITY_H +#pragma once #include #include @@ -1030,4 +1029,3 @@ namespace util { big(T x) { return endian_helper::big(x); } } // namespace endian } // namespace util -#endif diff --git a/src/uuid.h b/src/uuid.h index e1a893ef..32c3f56c 100644 --- a/src/uuid.h +++ b/src/uuid.h @@ -1,7 +1,4 @@ -// Created by loki on 8-2-19. - -#ifndef T_MAN_UUID_H -#define T_MAN_UUID_H +#pragma once #include @@ -80,4 +77,3 @@ namespace uuid_util { } }; } // namespace uuid_util -#endif // T_MAN_UUID_H diff --git a/src/version.h.in b/src/version.h.in index 2be10bf6..552b14f0 100644 --- a/src/version.h.in +++ b/src/version.h.in @@ -1,10 +1,7 @@ -#ifndef INCLUDE_GUARD -#define INCLUDE_GUARD +#pragma once #define PROJECT_NAME "@PROJECT_NAME@" #define PROJECT_VER "@PROJECT_VERSION@" #define PROJECT_VER_MAJOR "@PROJECT_VERSION_MAJOR@" #define PROJECT_VER_MINOR "@PROJECT_VERSION_MINOR@" #define PROJECT_VER_PATCH "@PROJECT_VERSION_PATCH@" - -#endif // INCLUDE_GUARD diff --git a/src/video.cpp b/src/video.cpp index 8bb8fa06..250fc8b9 100644 --- a/src/video.cpp +++ b/src/video.cpp @@ -1,5 +1,3 @@ -// Created by loki on 6/6/19. - #include #include #include @@ -163,8 +161,8 @@ namespace video { } /** - * When preserving aspect ratio, ensure that padding is black - */ + * When preserving aspect ratio, ensure that padding is black + */ int prefill() { auto frame = sw_frame ? sw_frame.get() : this->frame; @@ -1001,7 +999,7 @@ namespace video { auto &sps = session.sps; auto &vps = session.vps; - /* send the frame to the encoder */ + // send the frame to the encoder auto ret = avcodec_send_frame(ctx.get(), frame); if (ret < 0) { char err_str[AV_ERROR_MAX_STRING_SIZE] { 0 }; @@ -1962,13 +1960,13 @@ namespace video { return true; } - /* - This is called once at startup and each time a stream is launched to - ensure the best encoder is selected. Encoder availablility can change - at runtime due to all sorts of things from driver updates to eGPUs. - - This is only safe to call when there is no client actively streaming. - */ + /** + * This is called once at startup and each time a stream is launched to + * ensure the best encoder is selected. Encoder availablility can change + * at runtime due to all sorts of things from driver updates to eGPUs. + * + * This is only safe to call when there is no client actively streaming. + */ int probe_encoders() { auto encoder_list = encoders; diff --git a/src/video.h b/src/video.h index 37f4a728..940a33bf 100644 --- a/src/video.h +++ b/src/video.h @@ -1,7 +1,4 @@ -// Created by loki on 6/9/19. - -#ifndef SUNSHINE_VIDEO_H -#define SUNSHINE_VIDEO_H +#pragma once #include "input.h" #include "platform/common.h" @@ -103,5 +100,3 @@ namespace video { int probe_encoders(); } // namespace video - -#endif // SUNSHINE_VIDEO_H diff --git a/third-party/glad/include/KHR/khrplatform.h b/third-party/glad/include/KHR/khrplatform.h index 0c325d08..decd5704 100644 --- a/third-party/glad/include/KHR/khrplatform.h +++ b/third-party/glad/include/KHR/khrplatform.h @@ -101,7 +101,7 @@ */ #if defined(KHRONOS_STATIC) /* If the preprocessor constant KHRONOS_STATIC is defined, make the - * header compatible with static linking. */ + * header compatible with static linking. */ #define KHRONOS_APICALL #elif defined(_WIN32) #define KHRONOS_APICALL __declspec(dllimport) @@ -143,8 +143,8 @@ #if (defined(__STDC_VERSION__) && __STDC_VERSION__ >= 199901L) || defined(__GNUC__) || defined(__SCO__) || defined(__USLC__) /* - * Using - */ + * Using + */ #include typedef int32_t khronos_int32_t; typedef uint32_t khronos_uint32_t; @@ -156,8 +156,8 @@ typedef uint64_t khronos_uint64_t; #elif defined(__VMS) || defined(__sgi) /* - * Using - */ + * Using + */ #include typedef int32_t khronos_int32_t; typedef uint32_t khronos_uint32_t; @@ -208,8 +208,8 @@ typedef unsigned int khronos_uint32_t; #else /* - * Generic fallback - */ + * Generic fallback + */ #include typedef int32_t khronos_int32_t; typedef uint32_t khronos_uint32_t; diff --git a/third-party/nvfbc/NvFBC.h b/third-party/nvfbc/NvFBC.h index 17b13c7b..42d0d04b 100644 --- a/third-party/nvfbc/NvFBC.h +++ b/third-party/nvfbc/NvFBC.h @@ -280,103 +280,103 @@ extern "C" { */ typedef enum _NVFBCSTATUS { /*! - * This indicates that the API call returned with no errors. - */ + * This indicates that the API call returned with no errors. + */ NVFBC_SUCCESS = 0, /*! - * This indicates that the API version between the client and the library - * is not compatible. - */ + * This indicates that the API version between the client and the library + * is not compatible. + */ NVFBC_ERR_API_VERSION = 1, /*! - * An internal error occurred. - */ + * An internal error occurred. + */ NVFBC_ERR_INTERNAL = 2, /*! - * This indicates that one or more of the parameter passed to the API call - * is invalid. - */ + * This indicates that one or more of the parameter passed to the API call + * is invalid. + */ NVFBC_ERR_INVALID_PARAM = 3, /*! - * This indicates that one or more of the pointers passed to the API call - * is invalid. - */ + * This indicates that one or more of the pointers passed to the API call + * is invalid. + */ NVFBC_ERR_INVALID_PTR = 4, /*! - * This indicates that the handle passed to the API call to identify the - * client is invalid. - */ + * This indicates that the handle passed to the API call to identify the + * client is invalid. + */ NVFBC_ERR_INVALID_HANDLE = 5, /*! - * This indicates that the maximum number of threaded clients of the same - * process has been reached. The limit is 10 threads per process. - * There is no limit on the number of process. - */ + * This indicates that the maximum number of threaded clients of the same + * process has been reached. The limit is 10 threads per process. + * There is no limit on the number of process. + */ NVFBC_ERR_MAX_CLIENTS = 6, /*! - * This indicates that the requested feature is not currently supported - * by the library. - */ + * This indicates that the requested feature is not currently supported + * by the library. + */ NVFBC_ERR_UNSUPPORTED = 7, /*! - * This indicates that the API call failed because it was unable to allocate - * enough memory to perform the requested operation. - */ + * This indicates that the API call failed because it was unable to allocate + * enough memory to perform the requested operation. + */ NVFBC_ERR_OUT_OF_MEMORY = 8, /*! - * This indicates that the API call was not expected. This happens when - * API calls are performed in a wrong order, such as trying to capture - * a frame prior to creating a new capture session; or trying to set up - * a capture to video memory although a capture session to system memory - * was created. - */ + * This indicates that the API call was not expected. This happens when + * API calls are performed in a wrong order, such as trying to capture + * a frame prior to creating a new capture session; or trying to set up + * a capture to video memory although a capture session to system memory + * was created. + */ NVFBC_ERR_BAD_REQUEST = 9, /*! - * This indicates an X error, most likely meaning that the X server has - * been terminated. When this error is returned, the only resort is to - * create another FBC handle using NvFBCCreateHandle(). - * - * The previous handle should still be freed with NvFBCDestroyHandle(), but - * it might leak resources, in particular X, GLX, and GL resources since - * it is no longer possible to communicate with an X server to free them - * through the driver. - * - * The best course of action to eliminate this potential leak is to close - * the OpenGL driver, close the forked process running the capture, or - * restart the application. - */ + * This indicates an X error, most likely meaning that the X server has + * been terminated. When this error is returned, the only resort is to + * create another FBC handle using NvFBCCreateHandle(). + * + * The previous handle should still be freed with NvFBCDestroyHandle(), but + * it might leak resources, in particular X, GLX, and GL resources since + * it is no longer possible to communicate with an X server to free them + * through the driver. + * + * The best course of action to eliminate this potential leak is to close + * the OpenGL driver, close the forked process running the capture, or + * restart the application. + */ NVFBC_ERR_X = 10, /*! - * This indicates a GLX error. - */ + * This indicates a GLX error. + */ NVFBC_ERR_GLX = 11, /*! - * This indicates an OpenGL error. - */ + * This indicates an OpenGL error. + */ NVFBC_ERR_GL = 12, /*! - * This indicates a CUDA error. - */ + * This indicates a CUDA error. + */ NVFBC_ERR_CUDA = 13, /*! - * This indicates a HW encoder error. - */ + * This indicates a HW encoder error. + */ NVFBC_ERR_ENCODER = 14, /*! - * This indicates an NvFBC context error. - */ + * This indicates an NvFBC context error. + */ NVFBC_ERR_CONTEXT = 15, /*! - * This indicates that the application must recreate the capture session. - * - * This error can be returned if a modeset event occurred while capturing - * frames, and NVFBC_CREATE_HANDLE_PARAMS::bDisableAutoModesetRecovery - * was set to NVFBC_TRUE. - */ + * This indicates that the application must recreate the capture session. + * + * This error can be returned if a modeset event occurred while capturing + * frames, and NVFBC_CREATE_HANDLE_PARAMS::bDisableAutoModesetRecovery + * was set to NVFBC_TRUE. + */ NVFBC_ERR_MUST_RECREATE = 16, /*! - * This indicates a Vulkan error. - */ + * This indicates a Vulkan error. + */ NVFBC_ERR_VULKAN = 17, } NVFBCSTATUS; @@ -385,12 +385,12 @@ typedef enum _NVFBCSTATUS { */ typedef enum _NVFBC_BOOL { /*! - * False value. - */ + * False value. + */ NVFBC_FALSE = 0, /*! - * True value. - */ + * True value. + */ NVFBC_TRUE, } NVFBC_BOOL; @@ -404,22 +404,22 @@ typedef enum _NVFBC_BOOL { */ typedef enum _NVFBC_CAPTURE_TYPE { /*! - * Capture frames to a buffer in system memory. - */ + * Capture frames to a buffer in system memory. + */ NVFBC_CAPTURE_TO_SYS = 0, /*! - * Capture frames to a CUDA device in video memory. - * - * Specifying this will dlopen() libcuda.so.1 and fail if not available. - */ + * Capture frames to a CUDA device in video memory. + * + * Specifying this will dlopen() libcuda.so.1 and fail if not available. + */ NVFBC_CAPTURE_SHARED_CUDA, /*! - * Retired. Do not use. - */ + * Retired. Do not use. + */ /* NVFBC_CAPTURE_TO_HW_ENCODER, */ /*! - * Capture frames to an OpenGL buffer in video memory. - */ + * Capture frames to an OpenGL buffer in video memory. + */ NVFBC_CAPTURE_TO_GL = 3, } NVFBC_CAPTURE_TYPE; @@ -438,29 +438,29 @@ typedef enum _NVFBC_CAPTURE_TYPE { */ typedef enum { /*! - * By default, NvFBC tries to track a connected primary output. If none is - * found, then it tries to track the first connected output. If none is - * found then it tracks the entire X screen. - * - * If the XRandR extension is not available, this option has the same effect - * as ::NVFBC_TRACKING_SCREEN. - * - * This default behavior might be subject to changes in the future. - */ + * By default, NvFBC tries to track a connected primary output. If none is + * found, then it tries to track the first connected output. If none is + * found then it tracks the entire X screen. + * + * If the XRandR extension is not available, this option has the same effect + * as ::NVFBC_TRACKING_SCREEN. + * + * This default behavior might be subject to changes in the future. + */ NVFBC_TRACKING_DEFAULT = 0, /*! - * Track an RandR output specified by its ID in the appropriate field. - * - * The list of connected outputs can be queried via NvFBCGetStatus(). - * This list can also be obtained using e.g., xrandr(1). - * - * If the XRandR extension is not available, setting this option returns an - * error. - */ + * Track an RandR output specified by its ID in the appropriate field. + * + * The list of connected outputs can be queried via NvFBCGetStatus(). + * This list can also be obtained using e.g., xrandr(1). + * + * If the XRandR extension is not available, setting this option returns an + * error. + */ NVFBC_TRACKING_OUTPUT, /*! - * Track the entire X screen. - */ + * Track the entire X screen. + */ NVFBC_TRACKING_SCREEN, } NVFBC_TRACKING_TYPE; @@ -469,31 +469,31 @@ typedef enum { */ typedef enum _NVFBC_BUFFER_FORMAT { /*! - * Data will be converted to ARGB8888 byte-order format. 32 bpp. - */ + * Data will be converted to ARGB8888 byte-order format. 32 bpp. + */ NVFBC_BUFFER_FORMAT_ARGB = 0, /*! - * Data will be converted to RGB888 byte-order format. 24 bpp. - */ + * Data will be converted to RGB888 byte-order format. 24 bpp. + */ NVFBC_BUFFER_FORMAT_RGB, /*! - * Data will be converted to NV12 format using HDTV weights - * according to ITU-R BT.709. 12 bpp. - */ + * Data will be converted to NV12 format using HDTV weights + * according to ITU-R BT.709. 12 bpp. + */ NVFBC_BUFFER_FORMAT_NV12, /*! - * Data will be converted to YUV 444 planar format using HDTV weights - * according to ITU-R BT.709. 24 bpp - */ + * Data will be converted to YUV 444 planar format using HDTV weights + * according to ITU-R BT.709. 24 bpp + */ NVFBC_BUFFER_FORMAT_YUV444P, /*! - * Data will be converted to RGBA8888 byte-order format. 32 bpp. - */ + * Data will be converted to RGBA8888 byte-order format. 32 bpp. + */ NVFBC_BUFFER_FORMAT_RGBA, /*! - * Native format. No pixel conversion needed. - * BGRA8888 byte-order format. 32 bpp. - */ + * Native format. No pixel conversion needed. + * BGRA8888 byte-order format. 32 bpp. + */ NVFBC_BUFFER_FORMAT_BGRA, } NVFBC_BUFFER_FORMAT; @@ -516,20 +516,20 @@ typedef uint64_t NVFBC_SESSION_HANDLE; */ typedef struct _NVFBC_BOX { /*! - * [in] X offset of the box. - */ + * [in] X offset of the box. + */ uint32_t x; /*! - * [in] Y offset of the box. - */ + * [in] Y offset of the box. + */ uint32_t y; /*! - * [in] Width of the box. - */ + * [in] Width of the box. + */ uint32_t w; /*! - * [in] Height of the box. - */ + * [in] Height of the box. + */ uint32_t h; } NVFBC_BOX; @@ -538,12 +538,12 @@ typedef struct _NVFBC_BOX { */ typedef struct _NVFBC_SIZE { /*! - * [in] Width. - */ + * [in] Width. + */ uint32_t w; /*! - * [in] Height. - */ + * [in] Height. + */ uint32_t h; } NVFBC_SIZE; @@ -552,84 +552,84 @@ typedef struct _NVFBC_SIZE { */ typedef struct _NVFBC_FRAME_GRAB_INFO { /*! - * [out] Width of the captured frame. - */ + * [out] Width of the captured frame. + */ uint32_t dwWidth; /*! - * [out] Height of the captured frame. - */ + * [out] Height of the captured frame. + */ uint32_t dwHeight; /*! - * [out] Size of the frame in bytes. - */ + * [out] Size of the frame in bytes. + */ uint32_t dwByteSize; /*! - * [out] Incremental ID of the current frame. - * - * This can be used to identify a frame. - */ + * [out] Incremental ID of the current frame. + * + * This can be used to identify a frame. + */ uint32_t dwCurrentFrame; /*! - * [out] Whether the captured frame is a new frame. - * - * When using non blocking calls it is possible to capture a frame - * that was already captured before if the display server did not - * render a new frame in the meantime. In that case, this flag - * will be set to NVFBC_FALSE. - * - * When using blocking calls each captured frame will have - * this flag set to NVFBC_TRUE since the blocking mechanism waits for - * the display server to render a new frame. - * - * Note that this flag does not guarantee that the content of - * the frame will be different compared to the previous captured frame. - * - * In particular, some compositing managers report the entire - * framebuffer as damaged when an application refreshes its content. - * - * Consider a single X screen spanned across physical displays A and B - * and an NvFBC application tracking display A. Depending on the - * compositing manager, it is possible that an application refreshing - * itself on display B will trigger a frame capture on display A. - * - * Workarounds include: - * - Using separate X screens - * - Disabling the composite extension - * - Using a compositing manager that properly reports what regions - * are damaged - * - Using NvFBC's diffmaps to find out if the frame changed - */ + * [out] Whether the captured frame is a new frame. + * + * When using non blocking calls it is possible to capture a frame + * that was already captured before if the display server did not + * render a new frame in the meantime. In that case, this flag + * will be set to NVFBC_FALSE. + * + * When using blocking calls each captured frame will have + * this flag set to NVFBC_TRUE since the blocking mechanism waits for + * the display server to render a new frame. + * + * Note that this flag does not guarantee that the content of + * the frame will be different compared to the previous captured frame. + * + * In particular, some compositing managers report the entire + * framebuffer as damaged when an application refreshes its content. + * + * Consider a single X screen spanned across physical displays A and B + * and an NvFBC application tracking display A. Depending on the + * compositing manager, it is possible that an application refreshing + * itself on display B will trigger a frame capture on display A. + * + * Workarounds include: + * - Using separate X screens + * - Disabling the composite extension + * - Using a compositing manager that properly reports what regions + * are damaged + * - Using NvFBC's diffmaps to find out if the frame changed + */ NVFBC_BOOL bIsNewFrame; /*! - * [out] Frame timestamp - * - * Time in micro seconds when the display server started rendering the - * frame. - * - * This does not account for when the frame was captured. If capturing an - * old frame (e.g., bIsNewFrame is NVFBC_FALSE) the reported timestamp - * will reflect the time when the old frame was rendered by the display - * server. - */ + * [out] Frame timestamp + * + * Time in micro seconds when the display server started rendering the + * frame. + * + * This does not account for when the frame was captured. If capturing an + * old frame (e.g., bIsNewFrame is NVFBC_FALSE) the reported timestamp + * will reflect the time when the old frame was rendered by the display + * server. + */ uint64_t ulTimestampUs; /* - * [out] Number of frames generated since the last capture. - * - * This can help applications tell whether they missed frames or there - * were no frames generated by the server since the last capture. - */ + * [out] Number of frames generated since the last capture. + * + * This can help applications tell whether they missed frames or there + * were no frames generated by the server since the last capture. + */ uint32_t dwMissedFrames; /* - * [out] Whether the captured frame required post processing. - * - * See the 'Post Processing' section. - */ + * [out] Whether the captured frame required post processing. + * + * See the 'Post Processing' section. + */ NVFBC_BOOL bRequiredPostProcessing; /* - * [out] Whether this frame was obtained via direct capture. - * - * See NVFBC_CREATE_CAPTURE_SESSION_PARAMS::bAllowDirectCapture. - */ + * [out] Whether this frame was obtained via direct capture. + * + * See NVFBC_CREATE_CAPTURE_SESSION_PARAMS::bAllowDirectCapture. + */ NVFBC_BOOL bDirectCapture; } NVFBC_FRAME_GRAB_INFO; @@ -638,53 +638,53 @@ typedef struct _NVFBC_FRAME_GRAB_INFO { */ typedef struct _NVFBC_CREATE_HANDLE_PARAMS { /*! - * [in] Must be set to NVFBC_CREATE_HANDLE_PARAMS_VER - */ + * [in] Must be set to NVFBC_CREATE_HANDLE_PARAMS_VER + */ uint32_t dwVersion; /*! - * [in] Application specific private information passed to the NvFBC - * session. - */ + * [in] Application specific private information passed to the NvFBC + * session. + */ const void *privateData; /*! - * [in] Size of the application specific private information passed to the - * NvFBC session. - */ + * [in] Size of the application specific private information passed to the + * NvFBC session. + */ uint32_t privateDataSize; /*! - * [in] Whether NvFBC should not create and manage its own graphics context - * - * NvFBC internally uses OpenGL to perfom graphics operations on the - * captured frames. By default, NvFBC will create and manage (e.g., make - * current, detect new threads, etc.) its own OpenGL context. - * - * If set to NVFBC_TRUE, NvFBC will use the application's context. It will - * be the application's responsibility to make sure that a context is - * current on the thread calling into the NvFBC API. - */ + * [in] Whether NvFBC should not create and manage its own graphics context + * + * NvFBC internally uses OpenGL to perfom graphics operations on the + * captured frames. By default, NvFBC will create and manage (e.g., make + * current, detect new threads, etc.) its own OpenGL context. + * + * If set to NVFBC_TRUE, NvFBC will use the application's context. It will + * be the application's responsibility to make sure that a context is + * current on the thread calling into the NvFBC API. + */ NVFBC_BOOL bExternallyManagedContext; /*! - * [in] GLX context - * - * GLX context that NvFBC should use internally to create pixmaps and - * make them current when creating a new capture session. - * - * Note: NvFBC expects a context created against a GLX_RGBA_TYPE render - * type. - */ + * [in] GLX context + * + * GLX context that NvFBC should use internally to create pixmaps and + * make them current when creating a new capture session. + * + * Note: NvFBC expects a context created against a GLX_RGBA_TYPE render + * type. + */ void *glxCtx; /*! - * [in] GLX framebuffer configuration - * - * Framebuffer configuration that was used to create the GLX context, and - * that will be used to create pixmaps internally. - * - * Note: NvFBC expects a configuration having at least the following - * attributes: - * GLX_DRAWABLE_TYPE, GLX_PIXMAP_BIT - * GLX_BIND_TO_TEXTURE_RGBA_EXT, 1 - * GLX_BIND_TO_TEXTURE_TARGETS_EXT, GLX_TEXTURE_2D_BIT_EXT - */ + * [in] GLX framebuffer configuration + * + * Framebuffer configuration that was used to create the GLX context, and + * that will be used to create pixmaps internally. + * + * Note: NvFBC expects a configuration having at least the following + * attributes: + * GLX_DRAWABLE_TYPE, GLX_PIXMAP_BIT + * GLX_BIND_TO_TEXTURE_RGBA_EXT, 1 + * GLX_BIND_TO_TEXTURE_TARGETS_EXT, GLX_TEXTURE_2D_BIT_EXT + */ void *glxFBConfig; } NVFBC_CREATE_HANDLE_PARAMS; @@ -698,8 +698,8 @@ typedef struct _NVFBC_CREATE_HANDLE_PARAMS { */ typedef struct _NVFBC_DESTROY_HANDLE_PARAMS { /*! - * [in] Must be set to NVFBC_DESTROY_HANDLE_PARAMS_VER - */ + * [in] Must be set to NVFBC_DESTROY_HANDLE_PARAMS_VER + */ uint32_t dwVersion; } NVFBC_DESTROY_HANDLE_PARAMS; @@ -728,19 +728,19 @@ typedef struct _NVFBC_DESTROY_HANDLE_PARAMS { */ typedef struct _NVFBC_OUTPUT { /*! - * Identifier of the RandR output. - */ + * Identifier of the RandR output. + */ uint32_t dwId; /*! - * Name of the RandR output, as reported by tools such as xrandr(1). - * - * Example: "DVI-I-0" - */ + * Name of the RandR output, as reported by tools such as xrandr(1). + * + * Example: "DVI-I-0" + */ char name[NVFBC_OUTPUT_NAME_LEN]; /*! - * Region of the X screen tracked by the RandR CRTC driving this RandR - * output. - */ + * Region of the X screen tracked by the RandR CRTC driving this RandR + * output. + */ NVFBC_BOX trackedBox; } NVFBC_RANDR_OUTPUT_INFO; @@ -749,64 +749,64 @@ typedef struct _NVFBC_OUTPUT { */ typedef struct _NVFBC_GET_STATUS_PARAMS { /*! - * [in] Must be set to NVFBC_GET_STATUS_PARAMS_VER - */ + * [in] Must be set to NVFBC_GET_STATUS_PARAMS_VER + */ uint32_t dwVersion; /*! - * [out] Whether or not framebuffer capture is supported by the graphics - * driver. - */ + * [out] Whether or not framebuffer capture is supported by the graphics + * driver. + */ NVFBC_BOOL bIsCapturePossible; /*! - * [out] Whether or not there is already a capture session on this system. - */ + * [out] Whether or not there is already a capture session on this system. + */ NVFBC_BOOL bCurrentlyCapturing; /*! - * [out] Whether or not it is possible to create a capture session on this - * system. - */ + * [out] Whether or not it is possible to create a capture session on this + * system. + */ NVFBC_BOOL bCanCreateNow; /*! - * [out] Size of the X screen (framebuffer). - */ + * [out] Size of the X screen (framebuffer). + */ NVFBC_SIZE screenSize; /*! - * [out] Whether the XRandR extension is available. - * - * If this extension is not available then it is not possible to have - * information about RandR outputs. - */ + * [out] Whether the XRandR extension is available. + * + * If this extension is not available then it is not possible to have + * information about RandR outputs. + */ NVFBC_BOOL bXRandRAvailable; /*! - * [out] Array of outputs connected to the X screen. - * - * An application can track a specific output by specifying its ID when - * creating a capture session. - * - * Only if XRandR is available. - */ + * [out] Array of outputs connected to the X screen. + * + * An application can track a specific output by specifying its ID when + * creating a capture session. + * + * Only if XRandR is available. + */ NVFBC_RANDR_OUTPUT_INFO outputs[NVFBC_OUTPUT_MAX]; /*! - * [out] Number of outputs connected to the X screen. - * - * This must be used to parse the array of connected outputs. - * - * Only if XRandR is available. - */ + * [out] Number of outputs connected to the X screen. + * + * This must be used to parse the array of connected outputs. + * + * Only if XRandR is available. + */ uint32_t dwOutputNum; /*! - * [out] Version of the NvFBC library running on this system. - */ + * [out] Version of the NvFBC library running on this system. + */ uint32_t dwNvFBCVersion; /*! - * [out] Whether the X server is currently in modeset. - * - * When the X server is in modeset, it must give up all its video - * memory allocations. It is not possible to create a capture - * session until the modeset is over. - * - * Note that VT-switches are considered modesets. - */ + * [out] Whether the X server is currently in modeset. + * + * When the X server is in modeset, it must give up all its video + * memory allocations. It is not possible to create a capture + * session until the modeset is over. + * + * Note that VT-switches are considered modesets. + */ NVFBC_BOOL bInModeset; } NVFBC_GET_STATUS_PARAMS; @@ -820,160 +820,160 @@ typedef struct _NVFBC_GET_STATUS_PARAMS { */ typedef struct _NVFBC_CREATE_CAPTURE_SESSION_PARAMS { /*! - * [in] Must be set to NVFBC_CREATE_CAPTURE_SESSION_PARAMS_VER - */ + * [in] Must be set to NVFBC_CREATE_CAPTURE_SESSION_PARAMS_VER + */ uint32_t dwVersion; /*! - * [in] Desired capture type. - * - * Note that when specyfing ::NVFBC_CAPTURE_SHARED_CUDA NvFBC will try to - * dlopen() the corresponding libraries. This means that NvFBC can run on - * a system without the CUDA library since it does not link against them. - */ + * [in] Desired capture type. + * + * Note that when specyfing ::NVFBC_CAPTURE_SHARED_CUDA NvFBC will try to + * dlopen() the corresponding libraries. This means that NvFBC can run on + * a system without the CUDA library since it does not link against them. + */ NVFBC_CAPTURE_TYPE eCaptureType; /*! - * [in] What region of the framebuffer should be tracked. - */ + * [in] What region of the framebuffer should be tracked. + */ NVFBC_TRACKING_TYPE eTrackingType; /*! - * [in] ID of the output to track if eTrackingType is set to - * ::NVFBC_TRACKING_OUTPUT. - */ + * [in] ID of the output to track if eTrackingType is set to + * ::NVFBC_TRACKING_OUTPUT. + */ uint32_t dwOutputId; /*! - * [in] Crop the tracked region. - * - * The coordinates are relative to the tracked region. - * - * It can be set to 0 to capture the entire tracked region. - */ + * [in] Crop the tracked region. + * + * The coordinates are relative to the tracked region. + * + * It can be set to 0 to capture the entire tracked region. + */ NVFBC_BOX captureBox; /*! - * [in] Desired size of the captured frame. - * - * This parameter allow to scale the captured frame. - * - * It can be set to 0 to disable frame resizing. - */ + * [in] Desired size of the captured frame. + * + * This parameter allow to scale the captured frame. + * + * It can be set to 0 to disable frame resizing. + */ NVFBC_SIZE frameSize; /*! - * [in] Whether the mouse cursor should be composited to the frame. - * - * Disabling the cursor will not generate new frames when only the cursor - * is moved. - */ + * [in] Whether the mouse cursor should be composited to the frame. + * + * Disabling the cursor will not generate new frames when only the cursor + * is moved. + */ NVFBC_BOOL bWithCursor; /*! - * [in] Whether NvFBC should not attempt to recover from modesets. - * - * NvFBC is able to detect when a modeset event occured and can automatically - * re-create a capture session with the same settings as before, then resume - * its frame capture session transparently. - * - * This option allows to disable this behavior. NVFBC_ERR_MUST_RECREATE - * will be returned in that case. - * - * It can be useful in the cases when an application needs to do some work - * between setting up a capture and grabbing the first frame. - * - * For example: an application using the ToGL interface needs to register - * resources with EncodeAPI prior to encoding frames. - * - * Note that during modeset recovery, NvFBC will try to re-create the - * capture session every second until it succeeds. - */ + * [in] Whether NvFBC should not attempt to recover from modesets. + * + * NvFBC is able to detect when a modeset event occured and can automatically + * re-create a capture session with the same settings as before, then resume + * its frame capture session transparently. + * + * This option allows to disable this behavior. NVFBC_ERR_MUST_RECREATE + * will be returned in that case. + * + * It can be useful in the cases when an application needs to do some work + * between setting up a capture and grabbing the first frame. + * + * For example: an application using the ToGL interface needs to register + * resources with EncodeAPI prior to encoding frames. + * + * Note that during modeset recovery, NvFBC will try to re-create the + * capture session every second until it succeeds. + */ NVFBC_BOOL bDisableAutoModesetRecovery; /*! - * [in] Whether NvFBC should round the requested frameSize. - * - * When disabled, NvFBC will not attempt to round the requested resolution. - * - * However, some pixel formats have resolution requirements. E.g., YUV/NV - * formats must have a width being a multiple of 4, and a height being a - * multiple of 2. RGB formats don't have such requirements. - * - * If the resolution doesn't meet the requirements of the format, then NvFBC - * will fail at setup time. - * - * When enabled, NvFBC will round the requested width to the next multiple - * of 4 and the requested height to the next multiple of 2. - * - * In this case, requesting any resolution will always work with every - * format. However, an NvFBC client must be prepared to handle the case - * where the requested resolution is different than the captured resolution. - * - * NVFBC_FRAME_GRAB_INFO::dwWidth and NVFBC_FRAME_GRAB_INFO::dwHeight should - * always be used for getting information about captured frames. - */ + * [in] Whether NvFBC should round the requested frameSize. + * + * When disabled, NvFBC will not attempt to round the requested resolution. + * + * However, some pixel formats have resolution requirements. E.g., YUV/NV + * formats must have a width being a multiple of 4, and a height being a + * multiple of 2. RGB formats don't have such requirements. + * + * If the resolution doesn't meet the requirements of the format, then NvFBC + * will fail at setup time. + * + * When enabled, NvFBC will round the requested width to the next multiple + * of 4 and the requested height to the next multiple of 2. + * + * In this case, requesting any resolution will always work with every + * format. However, an NvFBC client must be prepared to handle the case + * where the requested resolution is different than the captured resolution. + * + * NVFBC_FRAME_GRAB_INFO::dwWidth and NVFBC_FRAME_GRAB_INFO::dwHeight should + * always be used for getting information about captured frames. + */ NVFBC_BOOL bRoundFrameSize; /*! - * [in] Rate in ms at which the display server generates new frames - * - * This controls the frequency at which the display server will generate - * new frames if new content is available. This effectively controls the - * capture rate when using blocking calls. - * - * Note that lower values will increase the CPU and GPU loads. - * - * The default value is 16ms (~ 60 Hz). - */ + * [in] Rate in ms at which the display server generates new frames + * + * This controls the frequency at which the display server will generate + * new frames if new content is available. This effectively controls the + * capture rate when using blocking calls. + * + * Note that lower values will increase the CPU and GPU loads. + * + * The default value is 16ms (~ 60 Hz). + */ uint32_t dwSamplingRateMs; /*! - * [in] Enable push model for frame capture - * - * When set to NVFBC_TRUE, the display server will generate frames whenever - * it receives a damage event from applications. - * - * Setting this to NVFBC_TRUE will ignore ::dwSamplingRateMs. - * - * Using push model with the NVFBC_*_GRAB_FLAGS_NOWAIT_IF_NEW_FRAME_READY - * capture flag should guarantee the shortest amount of time between an - * application rendering a frame and an NvFBC client capturing it, provided - * that the NvFBC client is able to process the frames quickly enough. - * - * Note that applications running at high frame rates will increase CPU and - * GPU loads. - */ + * [in] Enable push model for frame capture + * + * When set to NVFBC_TRUE, the display server will generate frames whenever + * it receives a damage event from applications. + * + * Setting this to NVFBC_TRUE will ignore ::dwSamplingRateMs. + * + * Using push model with the NVFBC_*_GRAB_FLAGS_NOWAIT_IF_NEW_FRAME_READY + * capture flag should guarantee the shortest amount of time between an + * application rendering a frame and an NvFBC client capturing it, provided + * that the NvFBC client is able to process the frames quickly enough. + * + * Note that applications running at high frame rates will increase CPU and + * GPU loads. + */ NVFBC_BOOL bPushModel; /*! - * [in] Allow direct capture - * - * Direct capture allows NvFBC to attach itself to a fullscreen graphics - * application. Whenever that application presents a frame, it makes a copy - * of it directly into a buffer owned by NvFBC thus bypassing the X server. - * - * When direct capture is *not* enabled, the NVIDIA X driver generates a - * frame for NvFBC when it receives a damage event from an application if push - * model is enabled, or periodically checks if there are any pending damage - * events otherwise (see NVFBC_CREATE_CAPTURE_SESSION_PARAMS::dwSamplingRateMs). - * - * Direct capture is possible under the following conditions: - * - Direct capture is allowed - * - Push model is enabled (see NVFBC_CREATE_CAPTURE_SESSION_PARAMS::bPushModel) - * - The mouse cursor is not composited (see NVFBC_CREATE_CAPTURE_SESSION_PARAMS::bWithCursor) - * - No viewport transformation is required. This happens when the remote - * desktop is e.g. rotated. - * - * When direct capture is possible, NvFBC will automatically attach itself - * to a fullscreen unoccluded application, if such exists. - * - * Notes: - * - This includes compositing desktops such as GNOME (e.g., gnome-shell - * is the fullscreen unoccluded application). - * - There can be only one fullscreen unoccluded application at a time. - * - The NVIDIA X driver monitors which application qualifies or no - * longer qualifies. - * - * For example, if a fullscreen application is launched in GNOME, NvFBC will - * detach from gnome-shell and attach to that application. - * - * Attaching and detaching happens automatically from the perspective of an - * NvFBC client. When detaching from an application, the X driver will - * transparently resume generating frames for NvFBC. - * - * An application can know whether a given frame was obtained through - * direct capture by checking NVFBC_FRAME_GRAB_INFO::bDirectCapture. - */ + * [in] Allow direct capture + * + * Direct capture allows NvFBC to attach itself to a fullscreen graphics + * application. Whenever that application presents a frame, it makes a copy + * of it directly into a buffer owned by NvFBC thus bypassing the X server. + * + * When direct capture is *not* enabled, the NVIDIA X driver generates a + * frame for NvFBC when it receives a damage event from an application if push + * model is enabled, or periodically checks if there are any pending damage + * events otherwise (see NVFBC_CREATE_CAPTURE_SESSION_PARAMS::dwSamplingRateMs). + * + * Direct capture is possible under the following conditions: + * - Direct capture is allowed + * - Push model is enabled (see NVFBC_CREATE_CAPTURE_SESSION_PARAMS::bPushModel) + * - The mouse cursor is not composited (see NVFBC_CREATE_CAPTURE_SESSION_PARAMS::bWithCursor) + * - No viewport transformation is required. This happens when the remote + * desktop is e.g. rotated. + * + * When direct capture is possible, NvFBC will automatically attach itself + * to a fullscreen unoccluded application, if such exists. + * + * Notes: + * - This includes compositing desktops such as GNOME (e.g., gnome-shell + * is the fullscreen unoccluded application). + * - There can be only one fullscreen unoccluded application at a time. + * - The NVIDIA X driver monitors which application qualifies or no + * longer qualifies. + * + * For example, if a fullscreen application is launched in GNOME, NvFBC will + * detach from gnome-shell and attach to that application. + * + * Attaching and detaching happens automatically from the perspective of an + * NvFBC client. When detaching from an application, the X driver will + * transparently resume generating frames for NvFBC. + * + * An application can know whether a given frame was obtained through + * direct capture by checking NVFBC_FRAME_GRAB_INFO::bDirectCapture. + */ NVFBC_BOOL bAllowDirectCapture; } NVFBC_CREATE_CAPTURE_SESSION_PARAMS; @@ -987,8 +987,8 @@ typedef struct _NVFBC_CREATE_CAPTURE_SESSION_PARAMS { */ typedef struct _NVFBC_DESTROY_CAPTURE_SESSION_PARAMS { /*! - * [in] Must be set to NVFBC_DESTROY_CAPTURE_SESSION_PARAMS_VER - */ + * [in] Must be set to NVFBC_DESTROY_CAPTURE_SESSION_PARAMS_VER + */ uint32_t dwVersion; } NVFBC_DESTROY_CAPTURE_SESSION_PARAMS; @@ -1002,8 +1002,8 @@ typedef struct _NVFBC_DESTROY_CAPTURE_SESSION_PARAMS { */ typedef struct _NVFBC_BIND_CONTEXT_PARAMS { /*! - * [in] Must be set to NVFBC_BIND_CONTEXT_PARAMS_VER - */ + * [in] Must be set to NVFBC_BIND_CONTEXT_PARAMS_VER + */ uint32_t dwVersion; } NVFBC_BIND_CONTEXT_PARAMS; @@ -1017,8 +1017,8 @@ typedef struct _NVFBC_BIND_CONTEXT_PARAMS { */ typedef struct _NVFBC_RELEASE_CONTEXT_PARAMS { /*! - * [in] Must be set to NVFBC_RELEASE_CONTEXT_PARAMS_VER - */ + * [in] Must be set to NVFBC_RELEASE_CONTEXT_PARAMS_VER + */ uint32_t dwVersion; } NVFBC_RELEASE_CONTEXT_PARAMS; @@ -1032,38 +1032,38 @@ typedef struct _NVFBC_RELEASE_CONTEXT_PARAMS { */ typedef enum { /*! - * Default, capturing waits for a new frame or mouse move. - * - * The default behavior of blocking grabs is to wait for a new frame until - * after the call was made. But it's possible that there is a frame already - * ready that the client hasn't seen. - * \see NVFBC_TOSYS_GRAB_FLAGS_NOWAIT_IF_NEW_FRAME_READY - */ + * Default, capturing waits for a new frame or mouse move. + * + * The default behavior of blocking grabs is to wait for a new frame until + * after the call was made. But it's possible that there is a frame already + * ready that the client hasn't seen. + * \see NVFBC_TOSYS_GRAB_FLAGS_NOWAIT_IF_NEW_FRAME_READY + */ NVFBC_TOSYS_GRAB_FLAGS_NOFLAGS = 0, /*! - * Capturing does not wait for a new frame nor a mouse move. - * - * It is therefore possible to capture the same frame multiple times. - * When this occurs, the dwCurrentFrame parameter of the - * NVFBC_FRAME_GRAB_INFO structure is not incremented. - */ + * Capturing does not wait for a new frame nor a mouse move. + * + * It is therefore possible to capture the same frame multiple times. + * When this occurs, the dwCurrentFrame parameter of the + * NVFBC_FRAME_GRAB_INFO structure is not incremented. + */ NVFBC_TOSYS_GRAB_FLAGS_NOWAIT = (1 << 0), /*! - * Forces the destination buffer to be refreshed even if the frame has not - * changed since previous capture. - * - * By default, if the captured frame is identical to the previous one, NvFBC - * will omit one copy and not update the destination buffer. - * - * Setting that flag will prevent this behavior. This can be useful e.g., - * if the application has modified the buffer in the meantime. - */ + * Forces the destination buffer to be refreshed even if the frame has not + * changed since previous capture. + * + * By default, if the captured frame is identical to the previous one, NvFBC + * will omit one copy and not update the destination buffer. + * + * Setting that flag will prevent this behavior. This can be useful e.g., + * if the application has modified the buffer in the meantime. + */ NVFBC_TOSYS_GRAB_FLAGS_FORCE_REFRESH = (1 << 1), /*! - * Similar to NVFBC_TOSYS_GRAB_FLAGS_NOFLAGS, except that the capture will - * not wait if there is already a frame available that the client has - * never seen yet. - */ + * Similar to NVFBC_TOSYS_GRAB_FLAGS_NOFLAGS, except that the capture will + * not wait if there is already a frame available that the client has + * never seen yet. + */ NVFBC_TOSYS_GRAB_FLAGS_NOWAIT_IF_NEW_FRAME_READY = (1 << 2), } NVFBC_TOSYS_GRAB_FLAGS; @@ -1072,71 +1072,71 @@ typedef enum { */ typedef struct _NVFBC_TOSYS_SETUP_PARAMS { /*! - * [in] Must be set to NVFBC_TOSYS_SETUP_PARAMS_VER - */ + * [in] Must be set to NVFBC_TOSYS_SETUP_PARAMS_VER + */ uint32_t dwVersion; /*! - * [in] Desired buffer format. - */ + * [in] Desired buffer format. + */ NVFBC_BUFFER_FORMAT eBufferFormat; /*! - * [out] Pointer to a pointer to a buffer in system memory. - * - * This buffer contains the pixel value of the requested format. Refer to - * the description of the buffer formats to understand the memory layout. - * - * The application does not need to allocate memory for this buffer. It - * should not free this buffer either. This buffer is automatically - * re-allocated when needed (e.g., when the resolution changes). - * - * This buffer is allocated by the NvFBC library to the proper size. This - * size is returned in the dwByteSize field of the - * ::NVFBC_FRAME_GRAB_INFO structure. - */ + * [out] Pointer to a pointer to a buffer in system memory. + * + * This buffer contains the pixel value of the requested format. Refer to + * the description of the buffer formats to understand the memory layout. + * + * The application does not need to allocate memory for this buffer. It + * should not free this buffer either. This buffer is automatically + * re-allocated when needed (e.g., when the resolution changes). + * + * This buffer is allocated by the NvFBC library to the proper size. This + * size is returned in the dwByteSize field of the + * ::NVFBC_FRAME_GRAB_INFO structure. + */ void **ppBuffer; /*! - * [in] Whether differential maps should be generated. - */ + * [in] Whether differential maps should be generated. + */ NVFBC_BOOL bWithDiffMap; /*! - * [out] Pointer to a pointer to a buffer in system memory. - * - * This buffer contains the differential map of two frames. It must be read - * as an array of unsigned char. Each unsigned char is either 0 or - * non-zero. 0 means that the pixel value at the given location has not - * changed since the previous captured frame. Non-zero means that the pixel - * value has changed. - * - * The application does not need to allocate memory for this buffer. It - * should not free this buffer either. This buffer is automatically - * re-allocated when needed (e.g., when the resolution changes). - * - * This buffer is allocated by the NvFBC library to the proper size. The - * size of the differential map is returned in ::diffMapSize. - * - * This option is not compatible with the ::NVFBC_BUFFER_FORMAT_YUV420P and - * ::NVFBC_BUFFER_FORMAT_YUV444P buffer formats. - */ + * [out] Pointer to a pointer to a buffer in system memory. + * + * This buffer contains the differential map of two frames. It must be read + * as an array of unsigned char. Each unsigned char is either 0 or + * non-zero. 0 means that the pixel value at the given location has not + * changed since the previous captured frame. Non-zero means that the pixel + * value has changed. + * + * The application does not need to allocate memory for this buffer. It + * should not free this buffer either. This buffer is automatically + * re-allocated when needed (e.g., when the resolution changes). + * + * This buffer is allocated by the NvFBC library to the proper size. The + * size of the differential map is returned in ::diffMapSize. + * + * This option is not compatible with the ::NVFBC_BUFFER_FORMAT_YUV420P and + * ::NVFBC_BUFFER_FORMAT_YUV444P buffer formats. + */ void **ppDiffMap; /*! - * [in] Scaling factor of the differential maps. - * - * For example, a scaling factor of 16 means that one pixel of the diffmap - * will represent 16x16 pixels of the original frames. - * - * If any of these 16x16 pixels is different between the current and the - * previous frame, then the corresponding pixel in the diffmap will be set - * to non-zero. - * - * The default scaling factor is 1. A dwDiffMapScalingFactor of 0 will be - * set to 1. - */ + * [in] Scaling factor of the differential maps. + * + * For example, a scaling factor of 16 means that one pixel of the diffmap + * will represent 16x16 pixels of the original frames. + * + * If any of these 16x16 pixels is different between the current and the + * previous frame, then the corresponding pixel in the diffmap will be set + * to non-zero. + * + * The default scaling factor is 1. A dwDiffMapScalingFactor of 0 will be + * set to 1. + */ uint32_t dwDiffMapScalingFactor; /*! - * [out] Size of the differential map. - * - * Only set if bWithDiffMap is set to NVFBC_TRUE. - */ + * [out] Size of the differential map. + * + * Only set if bWithDiffMap is set to NVFBC_TRUE. + */ NVFBC_SIZE diffMapSize; } NVFBC_TOSYS_SETUP_PARAMS; @@ -1150,44 +1150,44 @@ typedef struct _NVFBC_TOSYS_SETUP_PARAMS { */ typedef struct _NVFBC_TOSYS_GRAB_FRAME_PARAMS { /*! - * [in] Must be set to NVFBC_TOSYS_GRAB_FRAME_PARAMS_VER - */ + * [in] Must be set to NVFBC_TOSYS_GRAB_FRAME_PARAMS_VER + */ uint32_t dwVersion; /*! - * [in] Flags defining the behavior of this frame capture. - */ + * [in] Flags defining the behavior of this frame capture. + */ uint32_t dwFlags; /*! - * [out] Information about the captured frame. - * - * Can be NULL. - */ + * [out] Information about the captured frame. + * + * Can be NULL. + */ NVFBC_FRAME_GRAB_INFO *pFrameGrabInfo; /*! - * [in] Wait timeout in milliseconds. - * - * When capturing frames with the NVFBC_TOSYS_GRAB_FLAGS_NOFLAGS or - * NVFBC_TOSYS_GRAB_FLAGS_NOWAIT_IF_NEW_FRAME_READY flags, - * NvFBC will wait for a new frame or mouse move until the below timer - * expires. - * - * When timing out, the last captured frame will be returned. Note that as - * long as the NVFBC_TOSYS_GRAB_FLAGS_FORCE_REFRESH flag is not set, - * returning an old frame will incur no performance penalty. - * - * NvFBC clients can use the return value of the grab frame operation to - * find out whether a new frame was captured, or the timer expired. - * - * Note that the behavior of blocking calls is to wait for a new frame - * *after* the call has been made. When using timeouts, it is possible - * that NvFBC will return a new frame (e.g., it has never been captured - * before) even though no new frame was generated after the grab call. - * - * For the precise definition of what constitutes a new frame, see - * ::bIsNewFrame. - * - * Set to 0 to disable timeouts. - */ + * [in] Wait timeout in milliseconds. + * + * When capturing frames with the NVFBC_TOSYS_GRAB_FLAGS_NOFLAGS or + * NVFBC_TOSYS_GRAB_FLAGS_NOWAIT_IF_NEW_FRAME_READY flags, + * NvFBC will wait for a new frame or mouse move until the below timer + * expires. + * + * When timing out, the last captured frame will be returned. Note that as + * long as the NVFBC_TOSYS_GRAB_FLAGS_FORCE_REFRESH flag is not set, + * returning an old frame will incur no performance penalty. + * + * NvFBC clients can use the return value of the grab frame operation to + * find out whether a new frame was captured, or the timer expired. + * + * Note that the behavior of blocking calls is to wait for a new frame + * *after* the call has been made. When using timeouts, it is possible + * that NvFBC will return a new frame (e.g., it has never been captured + * before) even though no new frame was generated after the grab call. + * + * For the precise definition of what constitutes a new frame, see + * ::bIsNewFrame. + * + * Set to 0 to disable timeouts. + */ uint32_t dwTimeoutMs; } NVFBC_TOSYS_GRAB_FRAME_PARAMS; @@ -1201,38 +1201,38 @@ typedef struct _NVFBC_TOSYS_GRAB_FRAME_PARAMS { */ typedef enum { /*! - * Default, capturing waits for a new frame or mouse move. - * - * The default behavior of blocking grabs is to wait for a new frame until - * after the call was made. But it's possible that there is a frame already - * ready that the client hasn't seen. - * \see NVFBC_TOCUDA_GRAB_FLAGS_NOWAIT_IF_NEW_FRAME_READY - */ + * Default, capturing waits for a new frame or mouse move. + * + * The default behavior of blocking grabs is to wait for a new frame until + * after the call was made. But it's possible that there is a frame already + * ready that the client hasn't seen. + * \see NVFBC_TOCUDA_GRAB_FLAGS_NOWAIT_IF_NEW_FRAME_READY + */ NVFBC_TOCUDA_GRAB_FLAGS_NOFLAGS = 0, /*! - * Capturing does not wait for a new frame nor a mouse move. - * - * It is therefore possible to capture the same frame multiple times. - * When this occurs, the dwCurrentFrame parameter of the - * NVFBC_FRAME_GRAB_INFO structure is not incremented. - */ + * Capturing does not wait for a new frame nor a mouse move. + * + * It is therefore possible to capture the same frame multiple times. + * When this occurs, the dwCurrentFrame parameter of the + * NVFBC_FRAME_GRAB_INFO structure is not incremented. + */ NVFBC_TOCUDA_GRAB_FLAGS_NOWAIT = (1 << 0), /*! - * [in] Forces the destination buffer to be refreshed even if the frame - * has not changed since previous capture. - * - * By default, if the captured frame is identical to the previous one, NvFBC - * will omit one copy and not update the destination buffer. - * - * Setting that flag will prevent this behavior. This can be useful e.g., - * if the application has modified the buffer in the meantime. - */ + * [in] Forces the destination buffer to be refreshed even if the frame + * has not changed since previous capture. + * + * By default, if the captured frame is identical to the previous one, NvFBC + * will omit one copy and not update the destination buffer. + * + * Setting that flag will prevent this behavior. This can be useful e.g., + * if the application has modified the buffer in the meantime. + */ NVFBC_TOCUDA_GRAB_FLAGS_FORCE_REFRESH = (1 << 1), /*! - * Similar to NVFBC_TOCUDA_GRAB_FLAGS_NOFLAGS, except that the capture will - * not wait if there is already a frame available that the client has - * never seen yet. - */ + * Similar to NVFBC_TOCUDA_GRAB_FLAGS_NOFLAGS, except that the capture will + * not wait if there is already a frame available that the client has + * never seen yet. + */ NVFBC_TOCUDA_GRAB_FLAGS_NOWAIT_IF_NEW_FRAME_READY = (1 << 2), } NVFBC_TOCUDA_FLAGS; @@ -1241,12 +1241,12 @@ typedef enum { */ typedef struct _NVFBC_TOCUDA_SETUP_PARAMS { /*! - * [in] Must be set to NVFBC_TOCUDA_SETUP_PARAMS_VER - */ + * [in] Must be set to NVFBC_TOCUDA_SETUP_PARAMS_VER + */ uint32_t dwVersion; /*! - * [in] Desired buffer format. - */ + * [in] Desired buffer format. + */ NVFBC_BUFFER_FORMAT eBufferFormat; } NVFBC_TOCUDA_SETUP_PARAMS; @@ -1260,58 +1260,58 @@ typedef struct _NVFBC_TOCUDA_SETUP_PARAMS { */ typedef struct _NVFBC_TOCUDA_GRAB_FRAME_PARAMS { /*! - * [in] Must be set to NVFBC_TOCUDA_GRAB_FRAME_PARAMS_VER. - */ + * [in] Must be set to NVFBC_TOCUDA_GRAB_FRAME_PARAMS_VER. + */ uint32_t dwVersion; /*! - * [in] Flags defining the behavior of this frame capture. - */ + * [in] Flags defining the behavior of this frame capture. + */ uint32_t dwFlags; /*! - * [out] Pointer to a ::CUdeviceptr - * - * The application does not need to allocate memory for this CUDA device. - * - * The application does need to create its own CUDA context to use this - * CUDA device. - * - * This ::CUdeviceptr will be mapped to a segment in video memory containing - * the frame. It is not possible to process a CUDA device while capturing - * a new frame. If the application wants to do so, it must copy the CUDA - * device using ::cuMemcpyDtoD or ::cuMemcpyDtoH beforehand. - */ + * [out] Pointer to a ::CUdeviceptr + * + * The application does not need to allocate memory for this CUDA device. + * + * The application does need to create its own CUDA context to use this + * CUDA device. + * + * This ::CUdeviceptr will be mapped to a segment in video memory containing + * the frame. It is not possible to process a CUDA device while capturing + * a new frame. If the application wants to do so, it must copy the CUDA + * device using ::cuMemcpyDtoD or ::cuMemcpyDtoH beforehand. + */ void *pCUDADeviceBuffer; /*! - * [out] Information about the captured frame. - * - * Can be NULL. - */ + * [out] Information about the captured frame. + * + * Can be NULL. + */ NVFBC_FRAME_GRAB_INFO *pFrameGrabInfo; /*! - * [in] Wait timeout in milliseconds. - * - * When capturing frames with the NVFBC_TOCUDA_GRAB_FLAGS_NOFLAGS or - * NVFBC_TOCUDA_GRAB_FLAGS_NOWAIT_IF_NEW_FRAME_READY flags, - * NvFBC will wait for a new frame or mouse move until the below timer - * expires. - * - * When timing out, the last captured frame will be returned. Note that as - * long as the NVFBC_TOCUDA_GRAB_FLAGS_FORCE_REFRESH flag is not set, - * returning an old frame will incur no performance penalty. - * - * NvFBC clients can use the return value of the grab frame operation to - * find out whether a new frame was captured, or the timer expired. - * - * Note that the behavior of blocking calls is to wait for a new frame - * *after* the call has been made. When using timeouts, it is possible - * that NvFBC will return a new frame (e.g., it has never been captured - * before) even though no new frame was generated after the grab call. - * - * For the precise definition of what constitutes a new frame, see - * ::bIsNewFrame. - * - * Set to 0 to disable timeouts. - */ + * [in] Wait timeout in milliseconds. + * + * When capturing frames with the NVFBC_TOCUDA_GRAB_FLAGS_NOFLAGS or + * NVFBC_TOCUDA_GRAB_FLAGS_NOWAIT_IF_NEW_FRAME_READY flags, + * NvFBC will wait for a new frame or mouse move until the below timer + * expires. + * + * When timing out, the last captured frame will be returned. Note that as + * long as the NVFBC_TOCUDA_GRAB_FLAGS_FORCE_REFRESH flag is not set, + * returning an old frame will incur no performance penalty. + * + * NvFBC clients can use the return value of the grab frame operation to + * find out whether a new frame was captured, or the timer expired. + * + * Note that the behavior of blocking calls is to wait for a new frame + * *after* the call has been made. When using timeouts, it is possible + * that NvFBC will return a new frame (e.g., it has never been captured + * before) even though no new frame was generated after the grab call. + * + * For the precise definition of what constitutes a new frame, see + * ::bIsNewFrame. + * + * Set to 0 to disable timeouts. + */ uint32_t dwTimeoutMs; } NVFBC_TOCUDA_GRAB_FRAME_PARAMS; @@ -1325,38 +1325,38 @@ typedef struct _NVFBC_TOCUDA_GRAB_FRAME_PARAMS { */ typedef enum { /*! - * Default, capturing waits for a new frame or mouse move. - * - * The default behavior of blocking grabs is to wait for a new frame until - * after the call was made. But it's possible that there is a frame already - * ready that the client hasn't seen. - * \see NVFBC_TOGL_GRAB_FLAGS_NOWAIT_IF_NEW_FRAME_READY - */ + * Default, capturing waits for a new frame or mouse move. + * + * The default behavior of blocking grabs is to wait for a new frame until + * after the call was made. But it's possible that there is a frame already + * ready that the client hasn't seen. + * \see NVFBC_TOGL_GRAB_FLAGS_NOWAIT_IF_NEW_FRAME_READY + */ NVFBC_TOGL_GRAB_FLAGS_NOFLAGS = 0, /*! - * Capturing does not wait for a new frame nor a mouse move. - * - * It is therefore possible to capture the same frame multiple times. - * When this occurs, the dwCurrentFrame parameter of the - * NVFBC_FRAME_GRAB_INFO structure is not incremented. - */ + * Capturing does not wait for a new frame nor a mouse move. + * + * It is therefore possible to capture the same frame multiple times. + * When this occurs, the dwCurrentFrame parameter of the + * NVFBC_FRAME_GRAB_INFO structure is not incremented. + */ NVFBC_TOGL_GRAB_FLAGS_NOWAIT = (1 << 0), /*! - * [in] Forces the destination buffer to be refreshed even if the frame - * has not changed since previous capture. - * - * By default, if the captured frame is identical to the previous one, NvFBC - * will omit one copy and not update the destination buffer. - * - * Setting that flag will prevent this behavior. This can be useful e.g., - * if the application has modified the buffer in the meantime. - */ + * [in] Forces the destination buffer to be refreshed even if the frame + * has not changed since previous capture. + * + * By default, if the captured frame is identical to the previous one, NvFBC + * will omit one copy and not update the destination buffer. + * + * Setting that flag will prevent this behavior. This can be useful e.g., + * if the application has modified the buffer in the meantime. + */ NVFBC_TOGL_GRAB_FLAGS_FORCE_REFRESH = (1 << 1), /*! - * Similar to NVFBC_TOGL_GRAB_FLAGS_NOFLAGS, except that the capture will - * not wait if there is already a frame available that the client has - * never seen yet. - */ + * Similar to NVFBC_TOGL_GRAB_FLAGS_NOFLAGS, except that the capture will + * not wait if there is already a frame available that the client has + * never seen yet. + */ NVFBC_TOGL_GRAB_FLAGS_NOWAIT_IF_NEW_FRAME_READY = (1 << 2), } NVFBC_TOGL_FLAGS; @@ -1370,59 +1370,59 @@ typedef enum { */ typedef struct _NVFBC_TOGL_SETUP_PARAMS { /*! - * [in] Must be set to NVFBC_TOGL_SETUP_PARAMS_VER - */ + * [in] Must be set to NVFBC_TOGL_SETUP_PARAMS_VER + */ uint32_t dwVersion; /*! - * [in] Desired buffer format. - */ + * [in] Desired buffer format. + */ NVFBC_BUFFER_FORMAT eBufferFormat; /*! - * [in] Whether differential maps should be generated. - */ + * [in] Whether differential maps should be generated. + */ NVFBC_BOOL bWithDiffMap; /*! - * [out] Pointer to a pointer to a buffer in system memory. - * - * \see NVFBC_TOSYS_SETUP_PARAMS::ppDiffMap - */ + * [out] Pointer to a pointer to a buffer in system memory. + * + * \see NVFBC_TOSYS_SETUP_PARAMS::ppDiffMap + */ void **ppDiffMap; /*! - * [in] Scaling factor of the differential maps. - * - * \see NVFBC_TOSYS_SETUP_PARAMS::dwDiffMapScalingFactor - */ + * [in] Scaling factor of the differential maps. + * + * \see NVFBC_TOSYS_SETUP_PARAMS::dwDiffMapScalingFactor + */ uint32_t dwDiffMapScalingFactor; /*! - * [out] List of GL textures that will store the captured frames. - * - * This array is 0 terminated. The number of textures varies depending on - * the capture settings (such as whether diffmaps are enabled). - * - * An application wishing to interop with, for example, EncodeAPI will need - * to register these textures prior to start encoding frames. - * - * After each frame capture, the texture holding the current frame will be - * returned in NVFBC_TOGL_GRAB_FRAME_PARAMS::dwTexture. - */ + * [out] List of GL textures that will store the captured frames. + * + * This array is 0 terminated. The number of textures varies depending on + * the capture settings (such as whether diffmaps are enabled). + * + * An application wishing to interop with, for example, EncodeAPI will need + * to register these textures prior to start encoding frames. + * + * After each frame capture, the texture holding the current frame will be + * returned in NVFBC_TOGL_GRAB_FRAME_PARAMS::dwTexture. + */ uint32_t dwTextures[NVFBC_TOGL_TEXTURES_MAX]; /*! - * [out] GL target to which the texture should be bound. - */ + * [out] GL target to which the texture should be bound. + */ uint32_t dwTexTarget; /*! - * [out] GL format of the textures. - */ + * [out] GL format of the textures. + */ uint32_t dwTexFormat; /*! - * [out] GL type of the textures. - */ + * [out] GL type of the textures. + */ uint32_t dwTexType; /*! - * [out] Size of the differential map. - * - * Only set if bWithDiffMap is set to NVFBC_TRUE. - */ + * [out] Size of the differential map. + * + * Only set if bWithDiffMap is set to NVFBC_TRUE. + */ NVFBC_SIZE diffMapSize; } NVFBC_TOGL_SETUP_PARAMS; @@ -1436,50 +1436,50 @@ typedef struct _NVFBC_TOGL_SETUP_PARAMS { */ typedef struct _NVFBC_TOGL_GRAB_FRAME_PARAMS { /*! - * [in] Must be set to NVFBC_TOGL_GRAB_FRAME_PARAMS_VER. - */ + * [in] Must be set to NVFBC_TOGL_GRAB_FRAME_PARAMS_VER. + */ uint32_t dwVersion; /*! - * [in] Flags defining the behavior of this frame capture. - */ + * [in] Flags defining the behavior of this frame capture. + */ uint32_t dwFlags; /*! - * [out] Index of the texture storing the current frame. - * - * This is an index in the NVFBC_TOGL_SETUP_PARAMS::dwTextures array. - */ + * [out] Index of the texture storing the current frame. + * + * This is an index in the NVFBC_TOGL_SETUP_PARAMS::dwTextures array. + */ uint32_t dwTextureIndex; /*! - * [out] Information about the captured frame. - * - * Can be NULL. - */ + * [out] Information about the captured frame. + * + * Can be NULL. + */ NVFBC_FRAME_GRAB_INFO *pFrameGrabInfo; /*! - * [in] Wait timeout in milliseconds. - * - * When capturing frames with the NVFBC_TOGL_GRAB_FLAGS_NOFLAGS or - * NVFBC_TOGL_GRAB_FLAGS_NOWAIT_IF_NEW_FRAME_READY flags, - * NvFBC will wait for a new frame or mouse move until the below timer - * expires. - * - * When timing out, the last captured frame will be returned. Note that as - * long as the NVFBC_TOGL_GRAB_FLAGS_FORCE_REFRESH flag is not set, - * returning an old frame will incur no performance penalty. - * - * NvFBC clients can use the return value of the grab frame operation to - * find out whether a new frame was captured, or the timer expired. - * - * Note that the behavior of blocking calls is to wait for a new frame - * *after* the call has been made. When using timeouts, it is possible - * that NvFBC will return a new frame (e.g., it has never been captured - * before) even though no new frame was generated after the grab call. - * - * For the precise definition of what constitutes a new frame, see - * ::bIsNewFrame. - * - * Set to 0 to disable timeouts. - */ + * [in] Wait timeout in milliseconds. + * + * When capturing frames with the NVFBC_TOGL_GRAB_FLAGS_NOFLAGS or + * NVFBC_TOGL_GRAB_FLAGS_NOWAIT_IF_NEW_FRAME_READY flags, + * NvFBC will wait for a new frame or mouse move until the below timer + * expires. + * + * When timing out, the last captured frame will be returned. Note that as + * long as the NVFBC_TOGL_GRAB_FLAGS_FORCE_REFRESH flag is not set, + * returning an old frame will incur no performance penalty. + * + * NvFBC clients can use the return value of the grab frame operation to + * find out whether a new frame was captured, or the timer expired. + * + * Note that the behavior of blocking calls is to wait for a new frame + * *after* the call has been made. When using timeouts, it is possible + * that NvFBC will return a new frame (e.g., it has never been captured + * before) even though no new frame was generated after the grab call. + * + * For the precise definition of what constitutes a new frame, see + * ::bIsNewFrame. + * + * Set to 0 to disable timeouts. + */ uint32_t dwTimeoutMs; } NVFBC_TOGL_GRAB_FRAME_PARAMS;