aboutsummaryrefslogtreecommitdiff
path: root/src/dbus.c
diff options
context:
space:
mode:
authordec05eba <dec05eba@protonmail.com>2024-11-10 23:54:36 +0100
committerdec05eba <dec05eba@protonmail.com>2024-11-10 23:54:39 +0100
commit4240f0e334b235f4e17f266550db28c3a01b26bf (patch)
tree5271201090fc268756866357e9b06b2c19227c1f /src/dbus.c
parentf1b49793658d42cc7dd53be757f34ec6437d0517 (diff)
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.
Diffstat (limited to 'src/dbus.c')
-rw-r--r--src/dbus.c19
1 files changed, 2 insertions, 17 deletions
diff --git a/src/dbus.c b/src/dbus.c
index 5757b8b..2087c35 100644
--- a/src/dbus.c
+++ b/src/dbus.c
@@ -1,11 +1,11 @@
#include "../include/dbus.h"
+#include "../include/utils.h"
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <errno.h>
#include <assert.h>
-#include <sys/random.h>
/* TODO: Make non-blocking when GPU Screen Recorder is turned into a library */
/* TODO: Make sure responses matches the requests */
@@ -37,27 +37,12 @@ static const char* dict_value_type_to_string(dict_value_type type) {
return "(unknown)";
}
-static 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, "gsr error: generate_random_characters: 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 gsr_dbus_init(gsr_dbus *self, const char *screencast_restore_token) {
memset(self, 0, sizeof(*self));
dbus_error_init(&self->err);
self->random_str[DBUS_RANDOM_STR_SIZE] = '\0';
- if(!generate_random_characters(self->random_str, DBUS_RANDOM_STR_SIZE, "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789", 62)) {
+ if(!generate_random_characters_standard_alphabet(self->random_str, DBUS_RANDOM_STR_SIZE)) {
fprintf(stderr, "gsr error: gsr_dbus_init: failed to generate random string\n");
return false;
}