CLI: make "-noaudio" implicit with "-b/--background"
Running background mode now behaves as if the "-noaudio" was passed in. The -setaudio command now has a "Default" option which can be used in the rare cases audio playback is desired in background mode. e.g. blender --background -setaudio Default Ref !118192
This commit is contained in:
parent
2b02d6c1e2
commit
7c90018f23
|
@ -889,12 +889,33 @@ static int arg_handle_debug_exit_on_error(int /*argc*/, const char ** /*argv*/,
|
|||
}
|
||||
|
||||
static const char arg_handle_background_mode_set_doc[] =
|
||||
"\n\t"
|
||||
"Run in background (often used for UI-less rendering).";
|
||||
"\n"
|
||||
"\tRun in background (often used for UI-less rendering).\n"
|
||||
"\n"
|
||||
"\tThe audio device is disabled in background-mode by default\n"
|
||||
"\tand can be re-enabled by passing in '-setaudo Default' afterwards.";
|
||||
static int arg_handle_background_mode_set(int /*argc*/, const char ** /*argv*/, void * /*data*/)
|
||||
{
|
||||
print_version_short();
|
||||
G.background = true;
|
||||
|
||||
/* Background Mode Defaults:
|
||||
*
|
||||
* In general background mode should strive to match the behavior of running
|
||||
* Blender inside a graphical session, any exception to this should have a well
|
||||
* justified reason and be noted in the doc-string. */
|
||||
|
||||
/* NOTE(@ideasman42): While there is no requirement for sound to be disabled in background-mode,
|
||||
* the use case for playing audio in background mode is enough of a special-case
|
||||
* that users who wish to do this can explicitly enable audio in background mode.
|
||||
* While the down sides for connecting to an audio device aren't terrible they include:
|
||||
* - Listing Blender as an active application which may output audio.
|
||||
* - Unnecessary overhead running an operation in background mode or ...
|
||||
* - Having to remember to include `-noaudio` with batch operations.
|
||||
* - A quiet but audible click when Blender starts & configures its audio device.
|
||||
*/
|
||||
BKE_sound_force_device("None");
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
@ -1538,9 +1559,8 @@ static int arg_handle_audio_disable(int /*argc*/, const char ** /*argv*/, void *
|
|||
|
||||
static const char arg_handle_audio_set_doc[] =
|
||||
"\n\t"
|
||||
"Force sound system to a specific device."
|
||||
"\n\t"
|
||||
"'None' 'SDL' 'OpenAL' 'CoreAudio' 'JACK' 'PulseAudio' 'WASAPI'.";
|
||||
"Force sound system to a specific device.\n"
|
||||
"\t'None' 'Default' 'SDL' 'OpenAL' 'CoreAudio' 'JACK' 'PulseAudio' 'WASAPI'.";
|
||||
static int arg_handle_audio_set(int argc, const char **argv, void * /*data*/)
|
||||
{
|
||||
if (argc < 1) {
|
||||
|
@ -1548,7 +1568,13 @@ static int arg_handle_audio_set(int argc, const char **argv, void * /*data*/)
|
|||
exit(1);
|
||||
}
|
||||
|
||||
BKE_sound_force_device(argv[1]);
|
||||
const char *device = argv[1];
|
||||
if (STREQ(device, "Default")) {
|
||||
/* Unset any forced device. */
|
||||
device = nullptr;
|
||||
}
|
||||
|
||||
BKE_sound_force_device(device);
|
||||
return 1;
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue