From 3a0242c399e274323d8a68cc45a063b1b2c3bbcd Mon Sep 17 00:00:00 2001 From: Mikhail Burakov Date: Sun, 12 May 2024 15:18:30 +0200 Subject: Add audio capturing switch to the commandline --- main.c | 19 ++++++++++++------- 1 file changed, 12 insertions(+), 7 deletions(-) (limited to 'main.c') diff --git a/main.c b/main.c index c1ce446..8676a14 100644 --- a/main.c +++ b/main.c @@ -311,7 +311,7 @@ drop_client: int main(int argc, char* argv[]) { if (argc < 2) { - LOG("Usage: %s [--disable-uhid]", argv[0]); + LOG("Usage: %s [--disable-uhid] [--disable-audio]", argv[0]); return EXIT_FAILURE; } if (signal(SIGINT, OnSignal) == SIG_ERR || @@ -325,20 +325,25 @@ int main(int argc, char* argv[]) { .server_fd = -1, .client_fd = -1, }; + bool disable_audio = false; for (int i = 2; i < argc; i++) { if (!strcmp(argv[i], "--disable-uhid")) { contexts.disable_uhid = true; + } else if (!strcmp(argv[i], "--disable-audio")) { + disable_audio = true; } } static struct AudioContextCallbacks kAudioContextCallbacks = { .OnAudioReady = OnAudioContextAudioReady, }; - contexts.audio_context = - AudioContextCreate(&kAudioContextCallbacks, &contexts); - if (!contexts.audio_context) { - LOG("Failed to create audio context"); - return EXIT_FAILURE; + if (!disable_audio) { + contexts.audio_context = + AudioContextCreate(&kAudioContextCallbacks, &contexts); + if (!contexts.audio_context) { + LOG("Failed to create audio context"); + return EXIT_FAILURE; + } } contexts.gpu_context = GpuContextCreate(colorspace, range); @@ -384,7 +389,7 @@ rollback_io_muxer: IoMuxerDestroy(&contexts.io_muxer); GpuContextDestroy(contexts.gpu_context); rollback_audio_context: - AudioContextDestroy(contexts.audio_context); + if (!disable_audio) AudioContextDestroy(contexts.audio_context); bool result = g_signal == SIGINT || g_signal == SIGTERM; return result ? EXIT_SUCCESS : EXIT_FAILURE; } -- cgit v1.2.3