Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(display)!: Add libdisplaydevice dependency and output name mapping #2894

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

FrogTheFrog
Copy link
Collaborator

Description

This is one of the first PRs related to #2582.
The code has been moved to the https://github.com/LizardByte/libdisplaydevice repo and will be coming to Sunshine little by little.

In this PR libdisplaydevice has been added as a submodule and a new singleton class with a new map_output_name method has been added.
For Windows the map_output_name now maps a device id to its corresponding display name, while on other platforms it simply performs a pass-trough.
On WIndows, in case the corresponding device has no display name at the moment (either inactive or the id is just wrong), it will return an empty string and the default display would be used as a result (you would still be able to start the stream).

Unfortunately, the method cannot be called just once when the config is loaded to remap the output_name immediately, since on Windows there is no guarantee that the display name will remain the same for the display (even without restarting the PC).

The display name is tied to a topology of active displays, whose settings are cached by the OS. When Windows encounters a completely new topology of active displays, it will generate the "best" settings to be used as a base.
The new base is not guaranteed to have the same display names as the other cached topology. Now, by simply turning off/on any of the displays, the active topology will change and so can the display name.
This is at least one of the factors why the display name seems random and unpredictable.

Screenshot

Some changes have been made in the UI to show how to configure the output name on Windows.
image

Type of Change

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to not work as expected)
  • Dependency update (updates to dependencies)
  • Documentation update (changes to documentation)
  • Repository update (changes to repository files, e.g. .github/...)

Checklist

  • My code follows the style guidelines of this project
  • I have performed a self-review of my own code
  • I have commented my code, particularly in hard-to-understand areas
  • I have added or updated the in code docstring/documentation-blocks for new or existing methods/components

Branch Updates

LizardByte requires that branches be up-to-date before merging. This means that after any PR is merged, this branch
must be updated before it can be merged. You must also
Allow edits from maintainers.

  • I want maintainers to keep my branch updated

@FrogTheFrog FrogTheFrog marked this pull request as draft July 19, 2024 08:23
@FrogTheFrog FrogTheFrog marked this pull request as ready for review July 19, 2024 08:23
Copy link

codecov bot commented Jul 19, 2024

Codecov Report

Attention: Patch coverage is 19.67213% with 49 lines in your changes missing coverage. Please review.

Project coverage is 9.74%. Comparing base (c892026) to head (3af95c8).

Files with missing lines Patch % Lines
src/display_device.cpp 9.09% 16 Missing and 4 partials ⚠️
src/logging.cpp 28.57% 14 Missing and 6 partials ⚠️
src/video.cpp 25.00% 3 Missing and 3 partials ⚠️
src/platform/windows/display_base.cpp 0.00% 2 Missing ⚠️
src/platform/macos/input.cpp 0.00% 0 Missing and 1 partial ⚠️
Additional details and impacted files
@@            Coverage Diff            @@
##           master   #2894      +/-   ##
=========================================
+ Coverage    9.72%   9.74%   +0.02%     
=========================================
  Files          77      78       +1     
  Lines       14058   14110      +52     
  Branches     6453    6475      +22     
=========================================
+ Hits         1367    1375       +8     
- Misses      10070   10105      +35     
- Partials     2621    2630       +9     
Flag Coverage Δ
Windows 5.14% <20.33%> (+0.06%) ⬆️
macOS-12 10.83% <19.56%> (+0.03%) ⬆️
macOS-13 10.73% <19.56%> (+0.03%) ⬆️
macOS-14 11.02% <19.56%> (+0.03%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

Files with missing lines Coverage Δ
src/logging.h 32.35% <ø> (ø)
src/platform/macos/input.cpp 37.85% <0.00%> (-0.92%) ⬇️
src/platform/windows/display_base.cpp 12.90% <0.00%> (-0.03%) ⬇️
src/video.cpp 21.14% <25.00%> (-0.04%) ⬇️
src/display_device.cpp 9.09% <9.09%> (ø)
src/logging.cpp 58.08% <28.57%> (-7.66%) ⬇️

... and 3 files with indirect coverage changes

@FrogTheFrog FrogTheFrog marked this pull request as draft July 19, 2024 08:43
@FrogTheFrog FrogTheFrog force-pushed the libdd-part-1 branch 2 times, most recently from 9a8d7bb to c622bec Compare July 19, 2024 17:01
@FrogTheFrog FrogTheFrog marked this pull request as ready for review July 19, 2024 17:55
src/display_device.h Outdated Show resolved Hide resolved
src_assets/common/assets/web/public/assets/locale/en.json Outdated Show resolved Hide resolved
docs/source/about/advanced_usage.rst Outdated Show resolved Hide resolved
cmake/compile_definitions/common.cmake Outdated Show resolved Hide resolved
@ReenigneArcher ReenigneArcher changed the title feat: Add libdisplaydevice dependency and output name mapping feat(display)!: Add libdisplaydevice dependency and output name mapping Jul 26, 2024
@ReenigneArcher

This comment was marked as resolved.

@FrogTheFrog FrogTheFrog force-pushed the libdd-part-1 branch 2 times, most recently from 58c729d to 7a80ccb Compare July 28, 2024 13:41
ReenigneArcher
ReenigneArcher previously approved these changes Jul 28, 2024
docs/source/about/advanced_usage.rst Outdated Show resolved Hide resolved
third-party/libdisplaydevice Outdated Show resolved Hide resolved
Copy link
Member

@Hazer Hazer left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good to me, I'll be basing my display changes on it "soon".

docs/configuration.md Outdated Show resolved Hide resolved
third-party/libdisplaydevice Outdated Show resolved Hide resolved
Copy link

sonarcloud bot commented Sep 12, 2024

Quality Gate Failed Quality Gate failed

Failed conditions
7 New issues
7 New Code Smells (required ≤ 0)

See analysis details on SonarCloud

Catch issues before they fail your Quality Gate with our IDE extension SonarLint

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants