Ensure pulse gets cleaned up
This commit is contained in:
parent
26b304eeb3
commit
cc78fe00af
@ -213,7 +213,8 @@ void statusloop() {
|
||||
|
||||
void stopthreads() {
|
||||
for (int i = 0; i < LENGTH(thread_callbacks); ++i) {
|
||||
pthread_kill(threads[i], SIGTERM);
|
||||
pthread_cancel(threads[i]);
|
||||
pthread_join(threads[i], NULL);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -66,6 +66,11 @@ static void state_callback(pa_context *ctx, pthread_t *main_thread) {
|
||||
}
|
||||
}
|
||||
|
||||
static void cleanup(void *data_to_free[2]) {
|
||||
pa_context_unref(data_to_free[1]);
|
||||
pa_mainloop_free(data_to_free[0]);
|
||||
}
|
||||
|
||||
void pulse_listener_main(pthread_t *main_thread) {
|
||||
pa_mainloop *mainloop = pa_mainloop_new();
|
||||
if (!mainloop) {
|
||||
@ -89,5 +94,8 @@ void pulse_listener_main(pthread_t *main_thread) {
|
||||
ERROR("could not connect to pulse");
|
||||
return;
|
||||
}
|
||||
void *data_to_free[2] = { mainloop, context };
|
||||
pthread_cleanup_push((void(*)(void *)) cleanup, data_to_free);
|
||||
pa_mainloop_run(mainloop, NULL);
|
||||
pthread_cleanup_pop(1);
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user