Skip to content

Commit fc0c05b

Browse files
committed
refactoring
1 parent 56d0699 commit fc0c05b

File tree

6 files changed

+465
-323
lines changed

6 files changed

+465
-323
lines changed

src/confighttp.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -580,7 +580,7 @@ namespace confighttp {
580580
fileTree.add_child("apps", sorted_apps);
581581

582582
pt::write_json(config::stream.file_apps, fileTree);
583-
proc::refresh(config::stream.file_apps);
583+
proc::proc.refresh(config::stream.file_apps);
584584

585585
outputTree.put("status", true);
586586
send_response(response, outputTree);
@@ -634,7 +634,7 @@ namespace confighttp {
634634
fileTree.push_back(std::make_pair("apps", newApps));
635635

636636
pt::write_json(config::stream.file_apps, fileTree);
637-
proc::refresh(config::stream.file_apps);
637+
proc::proc.refresh(config::stream.file_apps);
638638

639639
outputTree.put("status", true);
640640
outputTree.put("result", "application "s + std::to_string(index) + " deleted");

src/main.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -276,7 +276,7 @@ int main(int argc, char *argv[]) {
276276
SetConsoleCtrlHandler(ConsoleCtrlHandler, TRUE);
277277
#endif
278278

279-
proc::refresh(config::stream.file_apps);
279+
proc::proc.refresh(config::stream.file_apps);
280280

281281
// If any of the following fail, we log an error and continue event though sunshine will not function correctly.
282282
// This allows access to the UI to fix configuration problems or view the logs.

src/nvhttp.cpp

Lines changed: 8 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -753,10 +753,10 @@ namespace nvhttp {
753753
}
754754
tree.put("root.ServerCodecModeSupport", codec_mode_flags);
755755

756-
auto current_appid = proc::proc.running();
756+
auto current_appid = proc::proc.get_running_app_id();
757757
tree.put("root.PairStatus", pair_status);
758-
tree.put("root.currentgame", current_appid);
759-
tree.put("root.state", current_appid > 0 ? "SUNSHINE_SERVER_BUSY" : "SUNSHINE_SERVER_FREE");
758+
tree.put("root.currentgame", current_appid.value_or(0));
759+
tree.put("root.state", current_appid ? "SUNSHINE_SERVER_BUSY" : "SUNSHINE_SERVER_FREE");
760760

761761
std::ostringstream data;
762762

@@ -837,10 +837,7 @@ namespace nvhttp {
837837
return;
838838
}
839839

840-
auto appid = util::from_view(get_arg(args, "appid"));
841-
842-
auto current_appid = proc::proc.running();
843-
if (current_appid > 0) {
840+
if (proc::proc.get_running_app_id()) {
844841
tree.put("root.resume", 0);
845842
tree.put("root.<xmlattr>.status_code", 400);
846843
tree.put("root.<xmlattr>.status_message", "An app is already running on this host");
@@ -884,6 +881,7 @@ namespace nvhttp {
884881
return;
885882
}
886883

884+
auto appid = util::from_view(get_arg(args, "appid"));
887885
if (appid > 0) {
888886
auto err = proc::proc.execute(appid, launch_session);
889887
if (err) {
@@ -917,8 +915,7 @@ namespace nvhttp {
917915
response->close_connection_after_response = true;
918916
});
919917

920-
auto current_appid = proc::proc.running();
921-
if (current_appid == 0) {
918+
if (!proc::proc.get_running_app_id()) {
922919
tree.put("root.resume", 0);
923920
tree.put("root.<xmlattr>.status_code", 503);
924921
tree.put("root.<xmlattr>.status_message", "No running app to resume");
@@ -1000,12 +997,9 @@ namespace nvhttp {
1000997
tree.put("root.<xmlattr>.status_code", 200);
1001998

1002999
rtsp_stream::terminate_sessions();
1000+
proc::proc.terminate();
10031001

1004-
if (proc::proc.running() > 0) {
1005-
proc::proc.terminate();
1006-
}
1007-
1008-
// The config needs to be reverted regardless of whether "proc::proc.terminate()" was called or not.
1002+
// The config needs to be reverted regardless of whether "proc::proc.terminate()" actually terminated app or not.
10091003
display_device::revert_configuration();
10101004
}
10111005

0 commit comments

Comments
 (0)