diff options
author | Kacper Michajłow <kasper93@gmail.com> | 2023-10-21 04:55:41 +0200 |
---|---|---|
committer | Dudemanguy <random342@airmail.cc> | 2023-11-05 17:36:17 +0000 |
commit | 174df99ffa53f1091589eaa4fa0c16cdd55a9326 (patch) | |
tree | 3a60d45615f18beed98a9b08267c28ed7e05dd5f /input/ipc-unix.c | |
parent | 3a8b107f6216b38a151d5ca1e9d4f2727e3418f5 (diff) | |
download | mpv-174df99ffa53f1091589eaa4fa0c16cdd55a9326.tar.bz2 mpv-174df99ffa53f1091589eaa4fa0c16cdd55a9326.tar.xz |
ALL: use new mp_thread abstraction
Diffstat (limited to 'input/ipc-unix.c')
-rw-r--r-- | input/ipc-unix.c | 25 |
1 files changed, 12 insertions, 13 deletions
diff --git a/input/ipc-unix.c b/input/ipc-unix.c index 2cb53be546..595cf7f029 100644 --- a/input/ipc-unix.c +++ b/input/ipc-unix.c @@ -15,7 +15,6 @@ * License along with mpv. If not, see <http://www.gnu.org/licenses/>. */ -#include <pthread.h> #include <errno.h> #include <unistd.h> #include <limits.h> @@ -48,7 +47,7 @@ struct mp_ipc_ctx { struct mp_client_api *client_api; const char *path; - pthread_t thread; + mp_thread thread; int death_pipe[2]; }; @@ -91,9 +90,9 @@ static int ipc_write_str(struct client_arg *client, const char *buf) return 0; } -static void *client_thread(void *p) +static MP_THREAD_VOID client_thread(void *p) { - pthread_detach(pthread_self()); + pthread_detach(mp_thread_self()); // We don't use MSG_NOSIGNAL because the moldy fruit OS doesn't support it. struct sigaction sa = { .sa_handler = SIG_IGN, .sa_flags = SA_RESTART }; @@ -106,7 +105,7 @@ static void *client_thread(void *p) bstr client_msg = { talloc_strdup(NULL, ""), 0 }; char *tname = talloc_asprintf(NULL, "ipc/%s", arg->client_name); - mpthread_set_name(tname); + mp_thread_set_name(tname); talloc_free(tname); int pipe_fd = mpv_get_wakeup_pipe(arg->client); @@ -219,7 +218,7 @@ done: } else { mpv_destroy(h); } - return NULL; + MP_THREAD_RETURN(); } static bool ipc_start_client(struct mp_ipc_ctx *ctx, struct client_arg *client, @@ -232,8 +231,8 @@ static bool ipc_start_client(struct mp_ipc_ctx *ctx, struct client_arg *client, client->log = mp_client_get_log(client->client); - pthread_t client_thr; - if (pthread_create(&client_thr, NULL, client_thread, client)) + mp_thread client_thr; + if (mp_thread_create(&client_thr, client_thread, client)) goto err; return true; @@ -295,7 +294,7 @@ bool mp_ipc_start_anon_client(struct mp_ipc_ctx *ctx, struct mpv_handle *h, return true; } -static void *ipc_thread(void *p) +static MP_THREAD_VOID ipc_thread(void *p) { int rc; @@ -304,7 +303,7 @@ static void *ipc_thread(void *p) struct mp_ipc_ctx *arg = p; - mpthread_set_name("ipc/socket"); + mp_thread_set_name("ipc/socket"); MP_VERBOSE(arg, "Starting IPC master\n"); @@ -379,7 +378,7 @@ done: if (ipc_fd >= 0) close(ipc_fd); - return NULL; + MP_THREAD_RETURN(); } struct mp_ipc_ctx *mp_init_ipc(struct mp_client_api *client_api, @@ -418,7 +417,7 @@ struct mp_ipc_ctx *mp_init_ipc(struct mp_client_api *client_api, if (mp_make_wakeup_pipe(arg->death_pipe) < 0) goto out; - if (pthread_create(&arg->thread, NULL, ipc_thread, arg)) + if (mp_thread_create(&arg->thread, ipc_thread, arg)) goto out; return arg; @@ -438,7 +437,7 @@ void mp_uninit_ipc(struct mp_ipc_ctx *arg) return; (void)write(arg->death_pipe[1], &(char){0}, 1); - pthread_join(arg->thread, NULL); + mp_thread_join(arg->thread); close(arg->death_pipe[0]); close(arg->death_pipe[1]); |