aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTim Keller <tjkeller.xyz>2025-04-18 22:48:43 -0500
committerTim Keller <tjkeller.xyz>2025-04-18 22:48:43 -0500
commitf179eb32587a6261ee196ccf3bf0030c4237dd6a (patch)
treef7efa5a52d4f4d09e141e915786e1ba9489ec814
parent98ce3996a4eaeea8b57d4fa23fc54cb59e1afdd9 (diff)
downloadpavolctld-1.0.2.tar.xz
pavolctld-1.0.2.zip
fix bug where error msg always get sent when default sink is manually changed because the check of useridx != default_sink_index runs before the default sink callback is ran / finished runningHEADv1.0.2master
-rw-r--r--pavolctld.c8
1 files changed, 5 insertions, 3 deletions
diff --git a/pavolctld.c b/pavolctld.c
index 6504f74..bb18d91 100644
--- a/pavolctld.c
+++ b/pavolctld.c
@@ -125,16 +125,18 @@ static void change_command_sink(pa_context *c, char *cmd) {
}
static void sink_info_change_default_sink_callback(pa_context *c, const pa_sink_info *i, int eol, void *userdata) {
- int useridx = *(int *)userdata;
+ static int success = 0; // if the index passed to pa_context_get_sink_info_by_index is invalid, then eol is set immediately
if (eol) {
- if (useridx != default_sink_index) {
- printf("e3,sink %d does not exist\n", useridx); // same as sink_info_change_command_sink_callback
+ if (!success) {
+ printf("e3,sink %d does not exist\n", *(int *)userdata); // same as sink_info_change_command_sink_callback
fflush(stdout);
}
+ success = 0;
return;
}
+ success = 1;
pa_context_set_default_sink(c, i->name, NULL, NULL);
}