mirror of
https://github.com/kunkundi/crossdesk.git
synced 2025-10-26 20:25:34 +08:00
[fix] fix settings error when load from cache file
This commit is contained in:
@@ -33,7 +33,7 @@ class ConfigCenter {
|
|||||||
// Default value should be same with parameters in localization.h
|
// Default value should be same with parameters in localization.h
|
||||||
LANGUAGE language_ = LANGUAGE::CHINESE;
|
LANGUAGE language_ = LANGUAGE::CHINESE;
|
||||||
VIDEO_QUALITY video_quality_ = VIDEO_QUALITY::MEDIUM;
|
VIDEO_QUALITY video_quality_ = VIDEO_QUALITY::MEDIUM;
|
||||||
VIDEO_ENCODE_FORMAT video_encode_format_ = VIDEO_ENCODE_FORMAT::H264;
|
VIDEO_ENCODE_FORMAT video_encode_format_ = VIDEO_ENCODE_FORMAT::AV1;
|
||||||
bool hardware_video_codec_ = false;
|
bool hardware_video_codec_ = false;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
@@ -88,15 +88,36 @@ int Render::SaveSettingsIntoCacheFile() {
|
|||||||
fwrite(&cd_cache_, sizeof(cd_cache_), 1, cd_cache_file_);
|
fwrite(&cd_cache_, sizeof(cd_cache_), 1, cd_cache_file_);
|
||||||
fclose(cd_cache_file_);
|
fclose(cd_cache_file_);
|
||||||
|
|
||||||
|
config_center_.SetLanguage((ConfigCenter::LANGUAGE)language_button_value_);
|
||||||
|
config_center_.SetVideoQuality(
|
||||||
|
(ConfigCenter::VIDEO_QUALITY)video_quality_button_value_);
|
||||||
|
config_center_.SetVideoEncodeFormat(
|
||||||
|
(ConfigCenter::VIDEO_ENCODE_FORMAT)video_encode_format_button_value_);
|
||||||
|
config_center_.SetHardwareVideoCodec(enable_hardware_video_codec_);
|
||||||
|
|
||||||
LOG_INFO("Save settings into cache file success");
|
LOG_INFO("Save settings into cache file success");
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
int Render::LoadSettingsIntoCacheFile() {
|
int Render::LoadSettingsFromCacheFile() {
|
||||||
std::lock_guard<std::mutex> lock(cd_cache_mutex_);
|
std::lock_guard<std::mutex> lock(cd_cache_mutex_);
|
||||||
cd_cache_file_ = fopen("cache.cd", "r+");
|
cd_cache_file_ = fopen("cache.cd", "r+");
|
||||||
if (!cd_cache_file_) {
|
if (!cd_cache_file_) {
|
||||||
|
LOG_INFO("Init cache file by using default settings");
|
||||||
|
password_saved_ = "";
|
||||||
|
language_button_value_ = 0;
|
||||||
|
video_quality_button_value_ = 0;
|
||||||
|
video_encode_format_button_value_ = 1;
|
||||||
|
enable_hardware_video_codec_ = false;
|
||||||
|
|
||||||
|
config_center_.SetLanguage((ConfigCenter::LANGUAGE)language_button_value_);
|
||||||
|
config_center_.SetVideoQuality(
|
||||||
|
(ConfigCenter::VIDEO_QUALITY)video_quality_button_value_);
|
||||||
|
config_center_.SetVideoEncodeFormat(
|
||||||
|
(ConfigCenter::VIDEO_ENCODE_FORMAT)video_encode_format_button_value_);
|
||||||
|
config_center_.SetHardwareVideoCodec(enable_hardware_video_codec_);
|
||||||
|
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -130,12 +151,12 @@ int Render::StartScreenCapture() {
|
|||||||
rect.top = 0;
|
rect.top = 0;
|
||||||
rect.right = screen_width_;
|
rect.right = screen_width_;
|
||||||
rect.bottom = screen_height_;
|
rect.bottom = screen_height_;
|
||||||
last_frame_time_ = std::chrono::high_resolution_clock::now();
|
last_frame_time_ = std::chrono::steady_clock::now();
|
||||||
|
|
||||||
int screen_capturer_init_ret = screen_capturer_->Init(
|
int screen_capturer_init_ret = screen_capturer_->Init(
|
||||||
rect, 60,
|
rect, 60,
|
||||||
[this](unsigned char *data, int size, int width, int height) -> void {
|
[this](unsigned char *data, int size, int width, int height) -> void {
|
||||||
auto now_time = std::chrono::high_resolution_clock::now();
|
auto now_time = std::chrono::steady_clock::now();
|
||||||
std::chrono::duration<double> duration = now_time - last_frame_time_;
|
std::chrono::duration<double> duration = now_time - last_frame_time_;
|
||||||
auto tc = duration.count() * 1000;
|
auto tc = duration.count() * 1000;
|
||||||
|
|
||||||
@@ -261,7 +282,7 @@ int Render::CreateConnectionPeer() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
int Render::Run() {
|
int Render::Run() {
|
||||||
LoadSettingsIntoCacheFile();
|
LoadSettingsFromCacheFile();
|
||||||
|
|
||||||
localization_language_ = (ConfigCenter::LANGUAGE)language_button_value_;
|
localization_language_ = (ConfigCenter::LANGUAGE)language_button_value_;
|
||||||
localization_language_index_ = language_button_value_;
|
localization_language_index_ = language_button_value_;
|
||||||
|
|||||||
@@ -75,7 +75,7 @@ class Render {
|
|||||||
|
|
||||||
private:
|
private:
|
||||||
int SaveSettingsIntoCacheFile();
|
int SaveSettingsIntoCacheFile();
|
||||||
int LoadSettingsIntoCacheFile();
|
int LoadSettingsFromCacheFile();
|
||||||
|
|
||||||
int StartScreenCapture();
|
int StartScreenCapture();
|
||||||
int StopScreenCapture();
|
int StopScreenCapture();
|
||||||
|
|||||||
@@ -199,7 +199,7 @@ int Render::SettingWindow() {
|
|||||||
settings_window_pos_reset_ = true;
|
settings_window_pos_reset_ = true;
|
||||||
|
|
||||||
// Recreate peer instance
|
// Recreate peer instance
|
||||||
LoadSettingsIntoCacheFile();
|
LoadSettingsFromCacheFile();
|
||||||
|
|
||||||
// Recreate peer instance
|
// Recreate peer instance
|
||||||
{
|
{
|
||||||
|
|||||||
2
thirdparty/projectx
vendored
2
thirdparty/projectx
vendored
Submodule thirdparty/projectx updated: 911f209fda...10cb335779
Reference in New Issue
Block a user