From 4240f0e334b235f4e17f266550db28c3a01b26bf Mon Sep 17 00:00:00 2001 From: dec05eba Date: Sun, 10 Nov 2024 23:54:36 +0100 Subject: Add -aa and -aai options to record audio only from selected applications Use the --list-application-audio option to list available applications to record from. --- src/utils.c | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) (limited to 'src/utils.c') diff --git a/src/utils.c b/src/utils.c index a8e4dc2..e871126 100644 --- a/src/utils.c +++ b/src/utils.c @@ -7,6 +7,7 @@ #include #include #include +#include #include #include @@ -27,6 +28,25 @@ double clock_get_monotonic_seconds(void) { return (double)ts.tv_sec + (double)ts.tv_nsec * 0.000000001; } +bool generate_random_characters(char *buffer, int buffer_size, const char *alphabet, size_t alphabet_size) { + /* TODO: Use other functions on other platforms than linux */ + if(getrandom(buffer, buffer_size, 0) < buffer_size) { + fprintf(stderr, "Failed to get random bytes, error: %s\n", strerror(errno)); + return false; + } + + for(int i = 0; i < buffer_size; ++i) { + unsigned char c = *(unsigned char*)&buffer[i]; + buffer[i] = alphabet[c % alphabet_size]; + } + + return true; +} + +bool generate_random_characters_standard_alphabet(char *buffer, int buffer_size) { + return generate_random_characters(buffer, buffer_size, "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789", 62); +} + static gsr_monitor_rotation wayland_transform_to_gsr_rotation(int32_t rot) { switch(rot) { case 0: return GSR_MONITOR_ROT_0; -- cgit v1.2.3