From b992ca41965edf663f99bae19a95d59f2fd1ed97 Mon Sep 17 00:00:00 2001 From: JozanLeClerc Date: Sun, 15 Mar 2020 02:15:01 +0100 Subject: okok --- src/ft_init_sfx.c | 21 +++++++++++++++++++-- 1 file changed, 19 insertions(+), 2 deletions(-) (limited to 'src/ft_init_sfx.c') diff --git a/src/ft_init_sfx.c b/src/ft_init_sfx.c index 728e410..658fa6c 100644 --- a/src/ft_init_sfx.c +++ b/src/ft_init_sfx.c @@ -17,6 +17,7 @@ #include #include #include +#include static int8_t ft_split_sfx(char ***target, const char *path) @@ -38,13 +39,29 @@ static int8_t return (0); } +static int8_t + ft_init_sfx_cmd(char **target, const char *path) +{ + uint8_t len; + + len = ft_strlen(path); + len += ft_strlen(FT_SND_CMD) - 2; + if (!(*target = (char *)malloc((len + 1) * sizeof(char)))) + return (-1); + ft_sprintf(*target, FT_SND_CMD, path); + return (0); +} + int8_t ft_init_sfx(t_sfx *sfx) { + if (ft_init_sfx_cmd(&sfx->pain_one, FT_SFX_SCR_ONE_PATH) < 0 || + ft_init_sfx_cmd(&sfx->pain_two, FT_SFX_SCR_TWO_PATH) < 0) + return (-1); + pthread_mutex_init(&sfx->pain_mutex, NULL); + pthread_create(&sfx->pain_tid, NULL, ft_sfx_pain_thread, sfx); if (ft_split_sfx(&sfx->death, FT_SFX_DEATH_PATH) < 0 || ft_split_sfx(&sfx->new_lvl, FT_SFX_N_LVL_PATH) < 0 || - ft_split_sfx(&sfx->pain_one, FT_SFX_SCR_ONE_PATH) < 0 || - ft_split_sfx(&sfx->pain_two, FT_SFX_SCR_TWO_PATH) < 0 || ft_split_sfx(&sfx->trap, FT_SFX_TRAP_PATH) < 0) return (-1); return (0); -- cgit v1.2.3 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_init_sfx.c | 37 +++++++++++-------------------------- 1 file changed, 11 insertions(+), 26 deletions(-) (limited to 'src/ft_init_sfx.c') diff --git a/src/ft_init_sfx.c b/src/ft_init_sfx.c index 658fa6c..e1e9b7f 100644 --- a/src/ft_init_sfx.c +++ b/src/ft_init_sfx.c @@ -19,26 +19,6 @@ #include #include -static int8_t - ft_split_sfx(char ***target, const char *path) -{ - uint8_t len; - char *tmp; - - len = ft_strlen(path); - len += ft_strlen(FT_SND_CMD) - 2; - if (!(tmp = (char *)malloc((len + 1) * sizeof(char)))) - return (-1); - ft_sprintf(tmp, FT_SND_CMD, path); - if (!(*target = ft_split(tmp, ' '))) - { - ft_memdel((void**)&tmp); - return (-1); - } - ft_memdel((void**)&tmp); - return (0); -} - static int8_t ft_init_sfx_cmd(char **target, const char *path) { @@ -55,14 +35,19 @@ static int8_t int8_t ft_init_sfx(t_sfx *sfx) { - if (ft_init_sfx_cmd(&sfx->pain_one, FT_SFX_SCR_ONE_PATH) < 0 || - ft_init_sfx_cmd(&sfx->pain_two, FT_SFX_SCR_TWO_PATH) < 0) + if (ft_init_sfx_cmd(&sfx->death, FT_SFX_DEATH_PATH) < 0 || + ft_init_sfx_cmd(&sfx->new_lvl, FT_SFX_N_LVL_PATH) < 0 || + ft_init_sfx_cmd(&sfx->pain_one, FT_SFX_SCR_ONE_PATH) < 0 || + ft_init_sfx_cmd(&sfx->pain_two, FT_SFX_SCR_TWO_PATH) < 0 || + ft_init_sfx_cmd(&sfx->trap, FT_SFX_TRAP_PATH) < 0) return (-1); + pthread_mutex_init(&sfx->death_mutex, NULL); + pthread_mutex_init(&sfx->new_lvl_mutex, NULL); pthread_mutex_init(&sfx->pain_mutex, NULL); + pthread_mutex_init(&sfx->trap_mutex, NULL); + pthread_create(&sfx->death_tid, NULL, ft_sfx_death_thread, sfx); + pthread_create(&sfx->new_lvl_tid, NULL, ft_sfx_new_lvl_thread, sfx); pthread_create(&sfx->pain_tid, NULL, ft_sfx_pain_thread, sfx); - if (ft_split_sfx(&sfx->death, FT_SFX_DEATH_PATH) < 0 || - ft_split_sfx(&sfx->new_lvl, FT_SFX_N_LVL_PATH) < 0 || - ft_split_sfx(&sfx->trap, FT_SFX_TRAP_PATH) < 0) - return (-1); + pthread_create(&sfx->trap_tid, NULL, ft_sfx_trap_thread, sfx); return (0); } -- cgit v1.2.3 From 163bed0c8988ff020b746bf96dc01dd2058dc4f9 Mon Sep 17 00:00:00 2001 From: JozanLeClerc Date: Sun, 15 Mar 2020 15:09:59 +0100 Subject: Footsteps are bav --- src/ft_init_sfx.c | 4 ++++ 1 file changed, 4 insertions(+) (limited to 'src/ft_init_sfx.c') diff --git a/src/ft_init_sfx.c b/src/ft_init_sfx.c index e1e9b7f..35ab57d 100644 --- a/src/ft_init_sfx.c +++ b/src/ft_init_sfx.c @@ -36,16 +36,20 @@ int8_t ft_init_sfx(t_sfx *sfx) { if (ft_init_sfx_cmd(&sfx->death, FT_SFX_DEATH_PATH) < 0 || + ft_init_sfx_cmd(&sfx->footstep_one, FT_SFX_FS_ONE_PATH) < 0 || + ft_init_sfx_cmd(&sfx->footstep_two, FT_SFX_FS_TWO_PATH) < 0 || ft_init_sfx_cmd(&sfx->new_lvl, FT_SFX_N_LVL_PATH) < 0 || ft_init_sfx_cmd(&sfx->pain_one, FT_SFX_SCR_ONE_PATH) < 0 || ft_init_sfx_cmd(&sfx->pain_two, FT_SFX_SCR_TWO_PATH) < 0 || ft_init_sfx_cmd(&sfx->trap, FT_SFX_TRAP_PATH) < 0) return (-1); pthread_mutex_init(&sfx->death_mutex, NULL); + pthread_mutex_init(&sfx->footstep_mutex, NULL); pthread_mutex_init(&sfx->new_lvl_mutex, NULL); pthread_mutex_init(&sfx->pain_mutex, NULL); pthread_mutex_init(&sfx->trap_mutex, NULL); pthread_create(&sfx->death_tid, NULL, ft_sfx_death_thread, sfx); + pthread_create(&sfx->footstep_tid, NULL, ft_sfx_footstep_thread, sfx); pthread_create(&sfx->new_lvl_tid, NULL, ft_sfx_new_lvl_thread, sfx); pthread_create(&sfx->pain_tid, NULL, ft_sfx_pain_thread, sfx); pthread_create(&sfx->trap_tid, NULL, ft_sfx_trap_thread, sfx); -- cgit v1.2.3