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

For CI build #1

Closed
wants to merge 2 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions .gitmodules
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,10 @@
path = third-party/inputtino
url = https://github.com/games-on-whales/inputtino.git
branch = stable
[submodule "third-party/libdisplaydevice"]
path = third-party/libdisplaydevice
url = https://github.com/LizardByte/libdisplaydevice.git
branch = master
[submodule "third-party/moonlight-common-c"]
path = third-party/moonlight-common-c
url = https://github.com/moonlight-stream/moonlight-common-c.git
Expand Down
3 changes: 3 additions & 0 deletions cmake/compile_definitions/common.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,8 @@ set(SUNSHINE_TARGET_FILES
"${CMAKE_SOURCE_DIR}/src/uuid.h"
"${CMAKE_SOURCE_DIR}/src/config.h"
"${CMAKE_SOURCE_DIR}/src/config.cpp"
"${CMAKE_SOURCE_DIR}/src/display_device.h"
"${CMAKE_SOURCE_DIR}/src/display_device.cpp"
"${CMAKE_SOURCE_DIR}/src/entry_handler.cpp"
"${CMAKE_SOURCE_DIR}/src/entry_handler.h"
"${CMAKE_SOURCE_DIR}/src/file_handler.cpp"
Expand Down Expand Up @@ -146,6 +148,7 @@ list(APPEND SUNSHINE_EXTERNAL_LIBRARIES
${MINIUPNP_LIBRARIES}
${CMAKE_THREAD_LIBS_INIT}
enet
libdisplaydevice::display_device
opus
${FFMPEG_LIBRARIES}
${Boost_LIBRARIES}
Expand Down
3 changes: 3 additions & 0 deletions cmake/dependencies/common.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,9 @@ add_subdirectory("${CMAKE_SOURCE_DIR}/third-party/moonlight-common-c/enet")
# web server
add_subdirectory("${CMAKE_SOURCE_DIR}/third-party/Simple-Web-Server")

# libdisplaydevice
add_subdirectory("${CMAKE_SOURCE_DIR}/third-party/libdisplaydevice")

# common dependencies
find_package(OpenSSL REQUIRED)
find_package(PkgConfig REQUIRED)
Expand Down
256 changes: 253 additions & 3 deletions docs/configuration.md
Original file line number Diff line number Diff line change
Expand Up @@ -865,10 +865,56 @@ editing the `conf` file in a text editor. Use the examples as reference.
<br>
**Windows:**
<br>
Enter the following command in command prompt or PowerShell.
During Sunshine startup, you should see the list of detected displays:
@code{}
%ProgramFiles%\Sunshine\tools\dxgi-info.exe
Info: Currently available display devices:
[
{
"device_id": "{64243705-4020-5895-b923-adc862c3457e}",
"display_name": "",
"friendly_name": "IDD HDR",
"info": null
},
{
"device_id": "{77f67f3e-754f-5d31-af64-ee037e18100a}",
"display_name": "",
"friendly_name": "SunshineHDR",
"info": null
},
{
"device_id": "{daeac860-f4db-5208-b1f5-cf59444fb768}",
"display_name": "\\\\.\\DISPLAY1",
"friendly_name": "ROG PG279Q",
"info": {
"hdr_state": null,
"origin_point": {
"x": 0,
"y": 0
},
"primary": true,
"refresh_rate": {
"type": "rational",
"value": {
"denominator": 1000,
"numerator": 119998
}
},
"resolution": {
"height": 1440,
"width": 2560
},
"resolution_scale": {
"type": "rational",
"value": {
"denominator": 100,
"numerator": 100
}
}
}
}
]
@endcode
You need to use the `device_id` value.
}
</td>
</tr>
Expand All @@ -891,7 +937,211 @@ editing the `conf` file in a text editor. Use the examples as reference.
<tr>
<td>Example (Windows)</td>
<td colspan="2">@code{}
output_name = \\.\DISPLAY1
output_name = {daeac860-f4db-5208-b1f5-cf59444fb768}
@endcode</td>
</tr>
</table>

### dd_configuration_option

<table>
<tr>
<td>Description</td>
<td colspan="2">
@warning{Windows only!}
Perform additional configuration for the display device:
<ul>
<li>`disabled` - perform no additional configuration (disables all `dd_` configuration options).</li>
<li>`verify_only` - verify that display is active only (required for changing display mode and other options).</li>
<li>`ensure_active` - activate the display if it's currently inactive.</li>
<li>`ensure_primary` - activate the display if it's currently inactive and make it primary.</li>
<li>`ensure_only_display` - activate the display if it's currently inactive and disable all others.</li>
</ul>
</td>
</tr>
<tr>
<td>Default</td>
<td colspan="2">@code{}verify_only@endcode</td>
</tr>
<tr>
<td>Example</td>
<td colspan="2">@code{}
dd_configuration_option = ensure_only_display
@endcode</td>
</tr>
</table>

### dd_resolution_option

<table>
<tr>
<td>Description</td>
<td colspan="2">
@warning{Windows only!}
@note{"Optimize game settings" must be enabled for this option to work.}
Perform additional resolution configuration for the display device:
<ul>
<li>`disabled` - perform no additional configuration.</li>
<li>`automatic` - change resolution to the requested resolution from the client.</li>
<li>`manual` - change resolution to the user specified one (set via `dd_manual_resolution`).</li>
</ul>
</td>
</tr>
<tr>
<td>Default</td>
<td colspan="2">@code{}automatic@endcode</td>
</tr>
<tr>
<td>Example</td>
<td colspan="2">@code{}
dd_resolution_option = manual
@endcode</td>
</tr>
</table>

### dd_manual_resolution

<table>
<tr>
<td>Description</td>
<td colspan="2">
@warning{Windows only!}
@note{`dd_resolution_option` must be set to `manual`}
Specify manual resolution to be used.
</td>
</tr>
<tr>
<td>Default</td>
<td colspan="2">No value</td>
</tr>
<tr>
<td>Example</td>
<td colspan="2">@code{}
dd_manual_resolution = 1920x1080
@endcode</td>
</tr>
</table>

### dd_refresh_rate_option

<table>
<tr>
<td>Description</td>
<td colspan="2">
@warning{Windows only!}
Perform additional refresh rate configuration for the display device:
<ul>
<li>`disabled` - perform no additional configuration.</li>
<li>`automatic` - change refresh rate to the requested FPS value from the client.</li>
<li>`manual` - change refresh rate to the user specified one (set via `dd_manual_refresh_rate`).</li>
</ul>
</td>
</tr>
<tr>
<td>Default</td>
<td colspan="2">@code{}automatic@endcode</td>
</tr>
<tr>
<td>Example</td>
<td colspan="2">@code{}
dd_refresh_rate_option = manual
@endcode</td>
</tr>
</table>

### dd_manual_refresh_rate

<table>
<tr>
<td>Description</td>
<td colspan="2">
@warning{Windows only!}
@note{`dd_refresh_rate_option` must be set to `manual`}
Specify manual refresh rate to be used.
</td>
</tr>
<tr>
<td>Default</td>
<td colspan="2">No value</td>
</tr>
<tr>
<td>Example</td>
<td colspan="2">@code{}
dd_manual_resolution = 120
dd_manual_resolution = 59.95
@endcode</td>
</tr>
</table>

### dd_hdr_option

<table>
<tr>
<td>Description</td>
<td colspan="2">
@warning{Windows only!}
Perform additional HDR configuration for the display device:
<ul>
<li>`disabled` - perform no additional configuration.</li>
<li>`automatic` - change HDR to the requested state from the client if the display supports it.</li>
</ul>
</td>
</tr>
<tr>
<td>Default</td>
<td colspan="2">@code{}automatic@endcode</td>
</tr>
<tr>
<td>Example</td>
<td colspan="2">@code{}
dd_hdr_option = disabled
@endcode</td>
</tr>
</table>

### dd_wa_hdr_toggle

<table>
<tr>
<td>Description</td>
<td colspan="2">
@warning{Windows only!}
@note{This option works independently of `dd_hdr_option`}
When using virtual display device as for streaming, it might display incorrect (high-contrast) color.
With this option enabled, Sunshine will try to mitigate this issue.
</td>
</tr>
<tr>
<td>Default</td>
<td colspan="2">@code{}false@endcode</td>
</tr>
<tr>
<td>Example</td>
<td colspan="2">@code{}
dd_wa_hdr_toggle = true
@endcode</td>
</tr>
</table>

### dd_config_revert_delay

<table>
<tr>
<td>Description</td>
<td colspan="2">
@warning{Windows only!}
Additional delay in milliseconds to wait before reverting configuration when the app has been closed or the last session terminated.
Main purpose is to provide a smoother transition when quickly switching between apps.
</td>
</tr>
<tr>
<td>Default</td>
<td colspan="2">@code{}3000@endcode</td>
</tr>
<tr>
<td>Example</td>
<td colspan="2">@code{}
dd_config_revert_delay = 1500
@endcode</td>
</tr>
</table>
Expand Down
3 changes: 3 additions & 0 deletions packaging/linux/flatpak/dev.lizardbyte.app.Sunshine.yml
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,9 @@ modules:
# Test dependencies
- "modules/xvfb/xvfb.json"

# Build dependencies
- "modules/nlohmann_json.json"

# Runtime dependencies
- shared-modules/libayatana-appindicator/libayatana-appindicator-gtk3.json
- "modules/avahi.json"
Expand Down
15 changes: 15 additions & 0 deletions packaging/linux/flatpak/modules/nlohmann_json.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
{
"name": "nlohmann_json",
"buildsystem": "cmake-ninja",
"config-opts": [
"-DJSON_MultipleHeaders=OFF",
"-DJSON_BuildTests=OFF"
],
"sources": [
{
"type": "archive",
"url": "https://github.com/nlohmann/json/releases/download/v3.11.3/json.tar.xz",
"sha256": "d6c65aca6b1ed68e7a182f4757257b107ae403032760ed6ef121c9d55e81757d"
}
]
}
34 changes: 21 additions & 13 deletions src/audio.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -20,16 +20,6 @@ namespace audio {
using opus_t = util::safe_ptr<OpusMSEncoder, opus_multistream_encoder_destroy>;
using sample_queue_t = std::shared_ptr<safe::queue_t<std::vector<float>>>;

struct audio_ctx_t {
// We want to change the sink for the first stream only
std::unique_ptr<std::atomic_bool> sink_flag;

std::unique_ptr<platf::audio_control_t> control;

bool restore_sink;
platf::sink_t sink;
};

static int
start_audio_control(audio_ctx_t &ctx);
static void
Expand Down Expand Up @@ -95,8 +85,6 @@ namespace audio {
},
};

auto control_shared = safe::make_shared<audio_ctx_t>(start_audio_control, stop_audio_control);

void
encodeThread(sample_queue_t samples, config_t config, void *channel_data) {
auto packets = mail::man->queue<packet_t>(mail::audio_packets);
Expand Down Expand Up @@ -149,7 +137,7 @@ namespace audio {
apply_surround_params(stream, config.customStreamParams);
}

auto ref = control_shared.ref();
auto ref = get_audio_ctx_ref();
if (!ref) {
return;
}
Expand Down Expand Up @@ -255,6 +243,26 @@ namespace audio {
}
}

audio_ctx_ref_t
get_audio_ctx_ref() {
static auto control_shared { safe::make_shared<audio_ctx_t>(start_audio_control, stop_audio_control) };
return control_shared.ref();
}

bool
is_audio_ctx_sink_available(const audio_ctx_t &ctx) {
if (!ctx.control) {
return false;
}

const std::string &sink = ctx.sink.host.empty() ? config::audio.sink : ctx.sink.host;
if (sink.empty()) {
return false;
}

return ctx.control->is_sink_available(sink);
}

int
map_stream(int channels, bool quality) {
int shift = quality ? 1 : 0;
Expand Down
Loading