Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

audio: fix reacting on mic enable/disable requests #161

Merged
merged 1 commit into from
Dec 10, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
27 changes: 23 additions & 4 deletions pulse/pacat-simple-vchan.c
Original file line number Diff line number Diff line change
Expand Up @@ -847,10 +847,19 @@ static void control_socket_callback(pa_mainloop_api *UNUSED(a),

struct userdata *u = userdata;
int new_rec_allowed = -1;
char *watch_path;

if (!(f & PA_IO_EVENT_INPUT))
return;

watch_path = qdb_read_watch(u->watch_qdb);
if (!watch_path) {
pacat_log("Failed to read the qdb watch");
return;
}
/* don't bother checking which watch fired, there is just one */
free(watch_path);

new_rec_allowed = is_rec_allowed_from_qdb(u);
if (new_rec_allowed >= 0) {
g_mutex_lock(&u->prop_mutex);
Expand Down Expand Up @@ -903,13 +912,20 @@ static int setup_control(struct userdata *u) {
u->qdb_config_path = NULL;
goto fail;
}

// Setup a QubesDB watch to get authorization on demand
if (!qdb_watch(u->qdb, u->qdb_config_path)) {
u->watch_qdb = qdb_open(NULL);
if (!u->watch_qdb) {
pacat_log("qdb_open (watch) failed: %s", strerror(errno));
goto fail;
}

if (!qdb_watch(u->watch_qdb, u->qdb_config_path)) {
pacat_log("failed to setup watch on %s: %m\n", u->qdb_config_path);
goto fail;
}

socket_fd = qdb_watch_fd(u->qdb);
socket_fd = qdb_watch_fd(u->watch_qdb);
if (socket_fd < 0)
goto fail;

Expand Down Expand Up @@ -946,8 +962,9 @@ static int setup_control(struct userdata *u) {
if (u->control_socket_event)
u->mainloop_api->io_free(u->control_socket_event);
u->control_socket_event = NULL;
if (socket_fd >= 0)
close(socket_fd);
if (u->watch_qdb)
qdb_close(u->watch_qdb);
u->watch_qdb = NULL;

return 1;
}
Expand All @@ -964,6 +981,8 @@ static void control_cleanup(struct userdata *u) {
free(u->qdb_status_path);
if (u->qdb_request_path)
free(u->qdb_request_path);
if (u->watch_qdb)
qdb_close(u->watch_qdb);
if (u->qdb)
qdb_close(u->qdb);
}
Expand Down
1 change: 1 addition & 0 deletions pulse/pacat-simple-vchan.h
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ struct userdata {

GMutex prop_mutex;
qdb_handle_t qdb;
qdb_handle_t watch_qdb; // separate connection for watches
char *qdb_config_path;
char *qdb_status_path;
char *qdb_request_path;
Expand Down