From bcbe3db5345f86fcacb039039382f3130c933eea Mon Sep 17 00:00:00 2001 From: JozanLeClerc Date: Sun, 15 Mar 2020 14:26:29 +0100 Subject: Sounds have been threaded --- src/ft_sfx_new_level.c | 26 +++++++++++++++++++++----- 1 file changed, 21 insertions(+), 5 deletions(-) (limited to 'src/ft_sfx_new_level.c') diff --git a/src/ft_sfx_new_level.c b/src/ft_sfx_new_level.c index 05e9059..ec648e0 100644 --- a/src/ft_sfx_new_level.c +++ b/src/ft_sfx_new_level.c @@ -11,14 +11,30 @@ /* ************************************************************************** */ #include -#include +#include +#include void - ft_sfx_new_level(t_cub *cl) + *ft_sfx_new_lvl_thread(void *vargp) { - cl->sfx.new_lvl_pid = fork(); - if (cl->sfx.new_lvl_pid == 0) + t_sfx *sfx; + + if (FT_OS == 1) + pthread_setcancelstate(PTHREAD_CANCEL_ASYNCHRONOUS, NULL); + else + pthread_setcancelstate(PTHREAD_CANCEL_ENABLE, NULL); + sfx = (t_sfx *)vargp; + pthread_mutex_lock(&sfx->new_lvl_mutex); + while (1) { - execve(*(cl->sfx.new_lvl + 0), cl->sfx.new_lvl, cl->envp); + pthread_mutex_lock(&sfx->new_lvl_mutex); + system(sfx->new_lvl); } + return (NULL); +} + +void + ft_sfx_new_level(t_cub *cl) +{ + pthread_mutex_unlock(&cl->sfx.new_lvl_mutex); } -- cgit v1.2.3