-
-
Notifications
You must be signed in to change notification settings - Fork 22k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add keep_screen_on
editor setting
#95048
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
At least on macOS, this won't fully solve the issue, Project Manager will still prevent Mac from sleeping since it's initializing the audio driver, which is constantly outputting "empty" sound.
Adding something like this on top of it (this change by itself seems fine and is necessary to allow sleeping) will do it:
diff --git a/main/main.cpp b/main/main.cpp
index e42469b51b..fcace48686 100644
--- a/main/main.cpp
+++ b/main/main.cpp
@@ -2355,6 +2355,10 @@ Error Main::setup(const char *execpath, int argc, char *argv[], bool p_second_ph
// If all else failed it would be the dummy driver (no sound).
audio_driver_idx = 0;
}
+ if (project_manager) {
+ audio_driver = NULL_AUDIO_DRIVER;
+ audio_driver_idx = AudioDriverManager::get_driver_count() - 1;
+ }
if (Engine::get_singleton()->get_write_movie_path() != String()) {
// Always use dummy driver for audio driver (which is last), also in no threaded mode.
I do not think project manager is using audio at all, so it should not have any negative effects. Won't help with the editor, we probably gonna need some sort of "low priority" audio driver mode, where it's starting on demand and shutting down after few seconds of silence.
Something like this feels a little bit better from the style perspective (keeps special cases together where diff --git a/main/main.cpp b/main/main.cpp
index e42469b51b0..acc271c594e 100644
--- a/main/main.cpp
+++ b/main/main.cpp
@@ -2360,6 +2360,9 @@ Error Main::setup(const char *execpath, int argc, char *argv[], bool p_second_ph
// Always use dummy driver for audio driver (which is last), also in no threaded mode.
audio_driver_idx = AudioDriverManager::get_driver_count() - 1;
AudioDriverDummy::get_dummy_singleton()->set_use_threads(false);
+ } else if (project_manager) {
+ // Always use dummy driver for audio driver (which is last).
+ audio_driver_idx = AudioDriverManager::get_driver_count() - 1;
}
{
Specifiying audio driver in command line arguments can be useful for testing (even in Project Manager just to check that everything initializes properly), but it's not possible when going with the current style. I would refactor it like this, but it's probably worth it's own PR: diff
diff --git a/main/main.cpp b/main/main.cpp
index e42469b51b0..fd37fea7a6c 100644
--- a/main/main.cpp
+++ b/main/main.cpp
@@ -2336,30 +2336,35 @@ Error Main::setup(const char *execpath, int argc, char *argv[], bool p_second_ph
GLOBAL_DEF_NOVAL(PropertyInfo(Variant::STRING, "display/display_server/driver.ios", PROPERTY_HINT_ENUM_SUGGESTION, "default,iOS,headless"), "default");
GLOBAL_DEF_NOVAL(PropertyInfo(Variant::STRING, "display/display_server/driver.macos", PROPERTY_HINT_ENUM_SUGGESTION, "default,macos,headless"), "default");
- GLOBAL_DEF_RST_NOVAL("audio/driver/driver", AudioDriverManager::get_driver(0)->get_name());
- if (audio_driver.is_empty()) { // Specified in project.godot.
- audio_driver = GLOBAL_GET("audio/driver/driver");
- }
-
// Make sure that dummy is the last one, which it is assumed to be by design.
DEV_ASSERT(NULL_AUDIO_DRIVER == AudioDriverManager::get_driver(AudioDriverManager::get_driver_count() - 1)->get_name());
- for (int i = 0; i < AudioDriverManager::get_driver_count(); i++) {
- if (audio_driver == AudioDriverManager::get_driver(i)->get_name()) {
- audio_driver_idx = i;
- break;
- }
- }
- if (audio_driver_idx < 0) {
- // If the requested driver wasn't found, pick the first entry.
- // If all else failed it would be the dummy driver (no sound).
- audio_driver_idx = 0;
- }
-
- if (Engine::get_singleton()->get_write_movie_path() != String()) {
+ GLOBAL_DEF_RST_NOVAL("audio/driver/driver", AudioDriverManager::get_driver(0)->get_name());
+ if (!Engine::get_singleton()->get_write_movie_path().is_empty()) {
// Always use dummy driver for audio driver (which is last), also in no threaded mode.
audio_driver_idx = AudioDriverManager::get_driver_count() - 1;
AudioDriverDummy::get_dummy_singleton()->set_use_threads(false);
+ } else if (project_manager && audio_driver.is_empty()) {
+ // Project Manager uses the dummy driver for the audio driver (which is last)
+ // unless the audio driver is specified in command line arguments.
+ audio_driver_idx = AudioDriverManager::get_driver_count() - 1;
+ } else {
+ if (audio_driver.is_empty()) { // Specified in project.godot.
+ audio_driver = GLOBAL_GET("audio/driver/driver");
+ }
+
+ for (int i = 0; i < AudioDriverManager::get_driver_count(); i++) {
+ if (audio_driver == AudioDriverManager::get_driver(i)->get_name()) {
+ audio_driver_idx = i;
+ break;
+ }
+ }
+
+ if (audio_driver_idx < 0) {
+ // If the requested driver wasn't found, pick the first entry.
+ // If all else failed it would be the dummy driver (no sound).
+ audio_driver_idx = 0;
+ }
}
{
See #63458 for 3.x. |
The audio driver issue is quite old and not really related to the one linked here. I think #38208 addresses it. |
Thanks! |
Closes #95020
I did not test if the setting is working correctly.