Allow an option set_realtime_priority() to revert

This commit is contained in:
Robbert van der Helm
2021-01-11 14:04:54 +01:00
parent 5855ffbe85
commit e3ea1dd2fe
5 changed files with 10 additions and 6 deletions
+3 -2
View File
@@ -31,7 +31,8 @@ fs::path get_temporary_directory() {
}
}
bool set_realtime_priority() {
bool set_realtime_priority(bool sched_fifo) {
sched_param params{.sched_priority = 5};
return sched_setscheduler(0, SCHED_FIFO, &params) == 0;
return sched_setscheduler(0, sched_fifo ? SCHED_FIFO : SCHED_OTHER,
&params) == 0;
}
+4 -1
View File
@@ -41,7 +41,10 @@ boost::filesystem::path get_temporary_directory();
* We explicitly don't do this for wineserver itself since from my testing that
* can actually increase latencies.
*
* @param sched_fifo If true, set the current process/thread's scheudling policy
* to `SCHED_FIFO`. Otherwise reset it back to `SCHWED_OTHER`.
*
* @return Whether the operation was successful or not. This will fail if the
* user does not have the privileges to set realtime priorities.
*/
bool set_realtime_priority();
bool set_realtime_priority(bool sched_fifo);
+1 -1
View File
@@ -86,7 +86,7 @@ class PluginBridge {
info.windows_plugin_path.string(),
.endpoint_base_dir =
sockets.base_dir.string()}))),
has_realtime_priority(set_realtime_priority()),
has_realtime_priority(set_realtime_priority(true)),
wine_io_handler([&]() { io_context.run(); }) {}
virtual ~PluginBridge(){};
+1 -1
View File
@@ -41,7 +41,7 @@ int __attribute__((visibility("default")))
__cdecl
#endif
main(int argc, char* argv[]) {
set_realtime_priority();
set_realtime_priority(true);
// Instead of directly hosting a plugin, this process will receive a UNIX
// domain socket endpoint path that it should listen on to allow yabridge
+1 -1
View File
@@ -37,7 +37,7 @@ int __attribute__((visibility("default")))
__cdecl
#endif
main(int argc, char* argv[]) {
set_realtime_priority();
set_realtime_priority(true);
// We pass plugin format, the name of the VST2 plugin .dll file or VST3
// bundle to load, and the base directory for the Unix domain socket