From 4684ee49c3bc0d736c4e94e9343f324ba6e5dc68 Mon Sep 17 00:00:00 2001 From: Paul Dino Jones Date: Fri, 15 Aug 2025 04:19:39 -0400 Subject: [PATCH] Add disable_audio flag --- src/monocoque/devices/simdevice.c | 26 ++++++++++++++++---------- src/monocoque/helper/confighelper.h | 1 + src/monocoque/helper/parameters.c | 15 +++++++++++++-- src/monocoque/helper/parameters.h | 1 + src/monocoque/monocoque.c | 21 +++++++++++++++++---- 5 files changed, 48 insertions(+), 16 deletions(-) diff --git a/src/monocoque/devices/simdevice.c b/src/monocoque/devices/simdevice.c index a1b40b8..06bf2e1 100644 --- a/src/monocoque/devices/simdevice.c +++ b/src/monocoque/devices/simdevice.c @@ -50,20 +50,26 @@ int devinit(SimDevice* simdevices, int numdevices, DeviceSettings* ds, Monocoque } if (ds[j].dev_type == SIMDEV_SOUND) { - - SoundDevice* sim = new_sound_device(&ds[j], ms); - if (sim != NULL) + if(ms->disable_audio == true) { - - simdevices[j] = sim->m; - simdevices[j].initialized = true; - simdevices[j].type = SIMDEV_SOUND; - simdevices[j].fps = ds[j].fps; - devices++; + slogi("skipping configured sound device due to disable_audio being specified..."); } else { - slogw("Could not initialize Sound Device"); + SoundDevice* sim = new_sound_device(&ds[j], ms); + if (sim != NULL) + { + + simdevices[j] = sim->m; + simdevices[j].initialized = true; + simdevices[j].type = SIMDEV_SOUND; + simdevices[j].fps = ds[j].fps; + devices++; + } + else + { + slogw("Could not initialize Sound Device"); + } } } diff --git a/src/monocoque/helper/confighelper.h b/src/monocoque/helper/confighelper.h index a5a3baf..c235445 100644 --- a/src/monocoque/helper/confighelper.h +++ b/src/monocoque/helper/confighelper.h @@ -136,6 +136,7 @@ typedef struct int verbosity_count; int fps; bool force_udp_mode; + bool disable_audio; char* tyre_diameter_config; char* config_str; char* log_filename_str; diff --git a/src/monocoque/helper/parameters.c b/src/monocoque/helper/parameters.c index 996cd8d..916d604 100644 --- a/src/monocoque/helper/parameters.c +++ b/src/monocoque/helper/parameters.c @@ -46,6 +46,7 @@ ConfigError getParameters(int argc, char** argv, Parameters* p) p->verbosity_count = 0; p->fps = 60; + p->disable_audio = false; p->udp = false; p->user_specified_config_file = false; @@ -61,6 +62,7 @@ ConfigError getParameters(int argc, char** argv, Parameters* p) struct arg_rex* cmd1 = arg_rex1(NULL, NULL, "play", NULL, REG_ICASE, NULL); struct arg_lit* arg_udp = arg_lit0("d", "udp", "force udp mode for sims which support it"); + struct arg_lit* arg_audio1 = arg_lit0("a", "disable_audio", "force disable of audio devices"); struct arg_file* arg_conf = arg_file0("c", "uiconf", "", NULL); struct arg_file* arg_log = arg_filen("l", "log", "", 0, 1, NULL); struct arg_str* arg_confdir = arg_strn(NULL, "configdir", "config_dir>", 0, 1, NULL); @@ -68,7 +70,7 @@ ConfigError getParameters(int argc, char** argv, Parameters* p) struct arg_lit* help = arg_litn(NULL,"help", 0, 1, "print this help and exit"); struct arg_lit* vers = arg_litn(NULL,"version", 0, 1, "print version information and exit"); struct arg_end* end1 = arg_end(20); - void* argtable1[] = {cmd1,arg_log,arg_conf,arg_fps,arg_udp,arg_verbosity1,help,vers,end1}; + void* argtable1[] = {cmd1,arg_log,arg_conf,arg_fps,arg_udp,arg_audio1,arg_verbosity1,help,vers,end1}; int nerrors1; struct arg_rex* cmd2a = arg_rex1(NULL, NULL, "config", NULL, REG_ICASE, NULL); @@ -83,10 +85,11 @@ ConfigError getParameters(int argc, char** argv, Parameters* p) int nerrors2; struct arg_rex* cmd3 = arg_rex1(NULL, NULL, "test", NULL, REG_ICASE, NULL); + struct arg_lit* arg_audio2 = arg_lit0("a", "disable_audio", "force disable of audio devices"); struct arg_lit* help3 = arg_litn(NULL,"help", 0, 1, "print this help and exit"); struct arg_lit* vers3 = arg_litn(NULL,"version", 0, 1, "print version information and exit"); struct arg_end* end3 = arg_end(20); - void* argtable3[] = {cmd3,arg_verbosity3,help3,vers3,end3}; + void* argtable3[] = {cmd3,arg_verbosity3,arg_audio2,help3,vers3,end3}; int nerrors3; struct arg_lit* help0 = arg_lit0(NULL,"help", "print this help and exit"); @@ -132,6 +135,10 @@ ConfigError getParameters(int argc, char** argv, Parameters* p) { p->udp = true; } + if (arg_audio1->count > 0) + { + p->disable_audio = true; + } if(arg_fps->count > 0) { p->fps = arg_fps->ival[0]; @@ -167,6 +174,10 @@ ConfigError getParameters(int argc, char** argv, Parameters* p) { p->program_action = A_TEST; p->verbosity_count = arg_verbosity3->count; + if (arg_audio2->count > 0) + { + p->disable_audio = true; + } exitcode = E_SUCCESS_AND_DO; } else diff --git a/src/monocoque/helper/parameters.h b/src/monocoque/helper/parameters.h index 09b5636..c9582ce 100644 --- a/src/monocoque/helper/parameters.h +++ b/src/monocoque/helper/parameters.h @@ -17,6 +17,7 @@ typedef struct SimulatorAPI sim; bool simon; bool udp; + bool disable_audio; char* config_filepath; char* config_dirpath; diff --git a/src/monocoque/monocoque.c b/src/monocoque/monocoque.c index b095755..ce06ed1 100644 --- a/src/monocoque/monocoque.c +++ b/src/monocoque/monocoque.c @@ -70,6 +70,7 @@ void SetSettingsFromParameters(Parameters* p, MonocoqueSettings* ms, char* confi } ms->force_udp_mode = false; + ms->disable_audio = p->disable_audio; } int main(int argc, char** argv) @@ -243,7 +244,10 @@ int main(int argc, char** argv) pulseaudio = true; //#endif - setupsound(); + if(ms->disable_audio == false) + { + setupsound(); + } //error = looper(devices, numdevices, p); error = monocoque_mainloop(ms); if (error == MONOCOQUE_ERROR_NONE) @@ -254,13 +258,19 @@ int main(int argc, char** argv) { sloge("Game loop exited with error code: %i", error); } - freesound(); + if(ms->disable_audio == false) + { + freesound(); + } } else { slogi("running monocoque in test mode..."); - setupsound(); + if(ms->disable_audio == false) + { + setupsound(); + } ms->useconfig = 0; int configs = getNumberOfConfigs(ms->config_str); @@ -295,7 +305,10 @@ int main(int argc, char** argv) simdevices[x].free(&simdevices[x]); } } - freesound(); + if(ms->disable_audio == false) + { + freesound(); + } } }