diff options
author | dec05eba <dec05eba@protonmail.com> | 2024-11-13 22:18:30 +0100 |
---|---|---|
committer | dec05eba <dec05eba@protonmail.com> | 2024-11-13 22:36:55 +0100 |
commit | 4ba1e814b748d57631f6b7afb7eaa63e8435c24e (patch) | |
tree | aa49caab6f299fb42f404ace5907025616aad553 /src/GsrInfo.cpp | |
parent | 590428425e8d35c96fffca666a50755a65c1cdba (diff) |
Add application audio option
Diffstat (limited to 'src/GsrInfo.cpp')
-rw-r--r-- | src/GsrInfo.cpp | 26 |
1 files changed, 26 insertions, 0 deletions
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<std::string> get_application_audio() { + std::vector<std::string> 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; + } } |