This commit is contained in:
Yukino Song
2025-05-14 20:25:20 +08:00
parent 2b86bc541d
commit bcb3e0c81d
2 changed files with 10 additions and 18 deletions

View File

@@ -172,11 +172,11 @@ namespace proc {
int proc_t::execute(const ctx_t& app, std::shared_ptr<rtsp_stream::launch_session_t> launch_session) {
if (_app_id == input_only_app_id) {
terminate();
terminate(false, false);
std::this_thread::sleep_for(1s);
} else {
// Ensure starting from a clean slate
terminate();
terminate(false, false);
}
_app = app;
@@ -572,7 +572,7 @@ namespace proc {
return 0;
}
void proc_t::terminate(bool immediate) {
void proc_t::terminate(bool immediate, bool needs_refresh) {
std::error_code ec;
placebo = false;
@@ -671,13 +671,9 @@ namespace proc {
virtual_display = false;
allow_client_commands = false;
if (refreshing) {
return;
if (needs_refresh) {
refresh(config::stream.file_apps, false);
}
refreshing = true;
refresh(config::stream.file_apps);
refreshing = false;
}
const std::vector<ctx_t> &proc_t::get_apps() const {
@@ -1393,11 +1389,9 @@ namespace proc {
};
}
void refresh(const std::string &file_name) {
if (!proc.refreshing) {
proc.refreshing = true;
proc.terminate();
proc.refreshing = false;
void refresh(const std::string &file_name, bool needs_terminate) {
if (needs_terminate) {
proc.terminate(false, false);
}
#ifdef _WIN32

View File

@@ -100,8 +100,6 @@ namespace proc {
bool initial_hdr;
bool virtual_display;
bool allow_client_commands;
bool refreshing;
proc_t(
boost::process::v1::environment &&env,
@@ -129,7 +127,7 @@ namespace proc {
std::string get_last_run_app_name();
std::string get_running_app_uuid();
boost::process::environment get_env();
void terminate(bool immediate = false);
void terminate(bool immediate = false, bool needs_refresh = true);
private:
int _app_id;
@@ -164,7 +162,7 @@ namespace proc {
std::tuple<std::string, std::string> calculate_app_id(const std::string &app_name, std::string app_image_path, int index);
std::string validate_app_image_path(std::string app_image_path);
void refresh(const std::string &file_name);
void refresh(const std::string &file_name, bool needs_terminate = true);
void migrate_apps(nlohmann::json* fileTree_p, nlohmann::json* inputTree_p);
std::optional<proc::proc_t> parse(const std::string &file_name);