mirror of
https://github.com/termux/termux-packages
synced 2024-06-18 23:27:06 +00:00
71 lines
1.9 KiB
Diff
71 lines
1.9 KiB
Diff
--- ./data-loop.c.orig 2022-05-23 23:10:06.894402311 +0530
|
|
+++ ./src/pipewire/data-loop.c 2022-05-23 23:13:31.814402233 +0530
|
|
@@ -230,8 +230,8 @@
|
|
if (loop->running) {
|
|
struct spa_thread_utils *utils;
|
|
if (loop->cancel) {
|
|
- pw_log_debug("%p cancel", loop);
|
|
- pthread_cancel(loop->thread);
|
|
+ pw_log_debug("%p cancel (used pthread_kill as cancel not available on android)", loop);
|
|
+ pthread_kill(loop->thread, SIGUSR2);
|
|
} else {
|
|
pw_log_debug("%p signal", loop);
|
|
pw_loop_invoke(loop->loop, do_stop, 1, NULL, 0, false, loop);
|
|
--- a/src/pipewire/thread.c
|
|
+++ b/src/pipewire/thread.c
|
|
@@ -73,6 +73,37 @@
|
|
#endif
|
|
#endif
|
|
|
|
+#ifdef __ANDROID__
|
|
+typedef struct wrapped_thread_start {
|
|
+ void *(*start)(void *);
|
|
+ void *arg;
|
|
+} wrapped_thread_start_t;
|
|
+
|
|
+static void thread_signal_handler(int signum)
|
|
+{
|
|
+ pthread_exit(0);
|
|
+}
|
|
+
|
|
+static void *pthread_create_wrapper(void *wrapped_arg)
|
|
+{
|
|
+ wrapped_thread_start_t *wrapped_start = (wrapped_thread_start_t *)wrapped_arg;
|
|
+
|
|
+ struct sigaction actions;
|
|
+ memset(&actions, 0, sizeof(actions));
|
|
+ sigemptyset(&actions.sa_mask);
|
|
+ actions.sa_flags = 0;
|
|
+ actions.sa_handler = thread_signal_handler;
|
|
+ sigaction(SIGUSR2, &actions, NULL);
|
|
+
|
|
+ void *(*start)(void *) = wrapped_start->start;
|
|
+ void *arg = wrapped_start->arg;
|
|
+
|
|
+ free(wrapped_start);
|
|
+
|
|
+ return (*start)(arg);
|
|
+}
|
|
+#endif
|
|
+
|
|
static struct spa_thread *impl_create(void *object,
|
|
const struct spa_dict *props,
|
|
void *(*start)(void*), void *arg)
|
|
@@ -84,7 +115,16 @@
|
|
|
|
attr = pw_thread_fill_attr(props, &attributes);
|
|
|
|
+#ifndef __ANDROID__
|
|
err = pthread_create(&pt, attr, start, arg);
|
|
+#else
|
|
+ wrapped_thread_start_t *wrapped_start = malloc(sizeof(wrapped_thread_start_t));
|
|
+ if (wrapped_start == NULL)
|
|
+ return NULL;
|
|
+ wrapped_start->start = start;
|
|
+ wrapped_start->arg = arg;
|
|
+ err = pthread_create(&pt, attr, pthread_create_wrapper, wrapped_start);
|
|
+#endif
|
|
|
|
if (attr)
|
|
pthread_attr_destroy(attr);
|