Merge remote-tracking branch 'origin/master'

This commit is contained in:
Yukino Song
2024-12-14 19:02:11 +08:00
24 changed files with 347 additions and 107 deletions

View File

@@ -19,6 +19,7 @@ extern "C" {
#include "process.h"
#include "cbs.h"
#include "config.h"
#include "display_device.h"
#include "globals.h"
#include "input.h"
#include "logging.h"
@@ -995,6 +996,8 @@ namespace video {
*/
void
refresh_displays(platf::mem_type_e dev_type, std::vector<std::string> &display_names, int &current_display_index, std::string &preferred_display_name) {
// It is possible that the output name may be empty even if it wasn't before (device disconnected) or vice-versa
const auto output_name { display_device::map_output_name(config::video.output_name) };
std::string current_display_name = preferred_display_name;
// If we have a current display index, let's start with that
@@ -1013,7 +1016,7 @@ namespace video {
return;
}
else if (display_names.empty()) {
display_names.emplace_back(config::video.output_name);
display_names.emplace_back(output_name);
}
// We now have a new display name list, so reset the index back to 0
@@ -1033,7 +1036,15 @@ namespace video {
}
// The old display was removed, so we'll start back at the first display again
BOOST_LOG(warning) << "Desired display ["sv << current_display_name << "] does not exist"sv;
BOOST_LOG(warning) << "Previous active display ["sv << current_display_name << "] is no longer present"sv;
}
else {
for (int x = 0; x < display_names.size(); ++x) {
if (display_names[x] == output_name) {
current_display_index = x;
return;
}
}
}
}
@@ -2359,6 +2370,7 @@ namespace video {
bool
validate_encoder(encoder_t &encoder, bool expect_failure) {
const auto output_name { display_device::map_output_name(config::video.output_name) };
std::shared_ptr<platf::display_t> disp;
BOOST_LOG(info) << "Trying encoder ["sv << encoder.name << ']';
@@ -2378,7 +2390,7 @@ namespace video {
config_t config_autoselect { 1920, 1080, 60, 1000, 1, 0, 1, 0, 0, 0 };
// If the encoder isn't supported at all (not even H.264), bail early
reset_display(disp, encoder.platform_formats->dev_type, config::video.output_name, config_autoselect);
reset_display(disp, encoder.platform_formats->dev_type, output_name, config_autoselect);
if (!disp) {
return false;
}
@@ -2486,7 +2498,7 @@ namespace video {
const config_t generic_hdr_config = { 1920, 1080, 60, 1000, 1, 0, 3, 1, 1, 0 };
// Reset the display since we're switching from SDR to HDR
reset_display(disp, encoder.platform_formats->dev_type, config::video.output_name, generic_hdr_config);
reset_display(disp, encoder.platform_formats->dev_type, output_name, generic_hdr_config);
if (!disp) {
return false;
}
@@ -2667,8 +2679,9 @@ namespace video {
}
if (chosen_encoder == nullptr) {
const auto output_name { display_device::map_output_name(config::video.output_name) };
BOOST_LOG(fatal) << "Unable to find display or encoder during startup."sv;
if (!config::video.adapter_name.empty() || !config::video.output_name.empty()) {
if (!config::video.adapter_name.empty() || !output_name.empty()) {
BOOST_LOG(fatal) << "Please ensure your manually chosen GPU and monitor are connected and powered on."sv;
}
else {