aboutsummaryrefslogtreecommitdiffstats
path: root/src/ft_sfx_trap.c
diff options
context:
space:
mode:
authorJozanLeClerc <bousset.rudy@gmail.com>2020-03-15 14:26:29 +0100
committerJozanLeClerc <bousset.rudy@gmail.com>2020-03-15 14:26:29 +0100
commitbcbe3db5345f86fcacb039039382f3130c933eea (patch)
tree36cb74b5e6d4c1b6ade5816ee821c58acbd4fd17 /src/ft_sfx_trap.c
parentCharacter is now FAT (diff)
download42-cub3d-bcbe3db5345f86fcacb039039382f3130c933eea.tar.gz
42-cub3d-bcbe3db5345f86fcacb039039382f3130c933eea.tar.bz2
42-cub3d-bcbe3db5345f86fcacb039039382f3130c933eea.tar.xz
42-cub3d-bcbe3db5345f86fcacb039039382f3130c933eea.tar.zst
42-cub3d-bcbe3db5345f86fcacb039039382f3130c933eea.zip
Sounds have been threaded
Diffstat (limited to 'src/ft_sfx_trap.c')
-rw-r--r--src/ft_sfx_trap.c27
1 files changed, 22 insertions, 5 deletions
diff --git a/src/ft_sfx_trap.c b/src/ft_sfx_trap.c
index 4b3dcf9..d55dd57 100644
--- a/src/ft_sfx_trap.c
+++ b/src/ft_sfx_trap.c
@@ -11,13 +11,30 @@
/* ************************************************************************** */
#include <cub3d.h>
-#include <unistd.h>
-#include <stdint.h>
+#include <stdlib.h>
+#include <pthread.h>
+
+void
+ *ft_sfx_trap_thread(void *vargp)
+{
+ 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->trap_mutex);
+ while (1)
+ {
+ pthread_mutex_lock(&sfx->trap_mutex);
+ system(sfx->trap);
+ }
+ return (NULL);
+}
void
ft_sfx_trap(t_cub *cl)
{
- cl->sfx.trap_pid = fork();
- if (cl->sfx.trap_pid == 0)
- execve(*(cl->sfx.trap + 0), cl->sfx.trap, cl->envp);
+ pthread_mutex_unlock(&cl->sfx.trap_mutex);
}