From 4ba1e814b748d57631f6b7afb7eaa63e8435c24e Mon Sep 17 00:00:00 2001 From: dec05eba Date: Wed, 13 Nov 2024 22:18:30 +0100 Subject: Add application audio option --- src/GsrInfo.cpp | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) (limited to 'src/GsrInfo.cpp') diff --git a/src/GsrInfo.cpp b/src/GsrInfo.cpp index 916430c..bb410dc 100644 --- a/src/GsrInfo.cpp +++ b/src/GsrInfo.cpp @@ -218,4 +218,30 @@ namespace gsr { return audio_devices; } + + std::vector get_application_audio() { + std::vector application_audio; + + FILE *f = popen("gpu-screen-recorder --list-application-audio", "r"); + if(!f) { + fprintf(stderr, "error: 'gpu-screen-recorder --list-application-audio' failed\n"); + return application_audio; + } + + char output[16384]; + ssize_t bytes_read = fread(output, 1, sizeof(output) - 1, f); + if(bytes_read < 0 || ferror(f)) { + fprintf(stderr, "error: failed to read 'gpu-screen-recorder --list-application-audio' output\n"); + pclose(f); + return application_audio; + } + output[bytes_read] = '\0'; + + string_split_char({output, (size_t)bytes_read}, '\n', [&](std::string_view line) { + application_audio.emplace_back(line); + return true; + }); + + return application_audio; + } } -- cgit v1.2.3-70-g09d2