aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorJozanLeClerc <bousset.rudy@gmail.com>2020-03-06 21:47:09 +0100
committerJozanLeClerc <bousset.rudy@gmail.com>2020-03-06 21:47:09 +0100
commit3048aae5d3f50359f19e0d440376ae422a16a7b7 (patch)
tree056ef0bcf64a304759e2fe29bf3a0ccdacd3786f /src
parentboy (diff)
download42-cub3d-3048aae5d3f50359f19e0d440376ae422a16a7b7.tar.gz
42-cub3d-3048aae5d3f50359f19e0d440376ae422a16a7b7.tar.bz2
42-cub3d-3048aae5d3f50359f19e0d440376ae422a16a7b7.tar.xz
42-cub3d-3048aae5d3f50359f19e0d440376ae422a16a7b7.tar.zst
42-cub3d-3048aae5d3f50359f19e0d440376ae422a16a7b7.zip
Good enough
Diffstat (limited to 'src')
-rw-r--r--src/ft_music.c25
-rw-r--r--src/ft_treat_args.c9
-rw-r--r--src/ft_warp_level.c4
3 files changed, 20 insertions, 18 deletions
diff --git a/src/ft_music.c b/src/ft_music.c
index a3e2120..0667ecb 100644
--- a/src/ft_music.c
+++ b/src/ft_music.c
@@ -10,20 +10,25 @@
/* */
/* ************************************************************************** */
-#include <libft.h>
-#include <stddef.h>
-#include <stdlib.h>
+#include <cub3d.h>
#include <unistd.h>
void
ft_music_fork(char **mcmd_words, char *const envp[])
{
- /* execve(2) here */
- char *arg[3];
+ if (FT_OS == 1)
+ execve("/usr/bin/afplay", mcmd_words, envp);
+ else
+ execve("/usr/bin/aplay", mcmd_words, envp);
+}
- arg[0] = "/usr/bin/aplay";
- arg[1] = "./media/sound/DEVANT-LES-KAISSONS.wav";
- arg[2] = NULL;
- (void)mcmd_words;
- execve("/usr/bin/aplay", &arg[0], envp);
+void
+ ft_enable_music(t_cub *cl)
+{
+ cl->isoldmus = 1;
+ cl->mpid = fork();
+ if (cl->mpid == 0)
+ {
+ ft_music_fork(cl->mlist.mcmd_words, cl->envp);
+ }
}
diff --git a/src/ft_treat_args.c b/src/ft_treat_args.c
index 79eedae..a47f9f7 100644
--- a/src/ft_treat_args.c
+++ b/src/ft_treat_args.c
@@ -31,18 +31,17 @@ uint8_t
uint8_t
ft_use_args(int argc, const char *argv[], char *const envp[], t_cub *clist)
{
+ clist->envp = envp;
if (argc < 3)
{
if (ft_init_winptr(clist) < 0)
+ {
return (ft_exit(FT_RET_FAILED_MLX, clist));
+ }
ft_draw_scene(clist);
if (clist->mlist.ismusic)
{
- /* create music fork() here */
- clist->isoldmus = 1;
- clist->mpid = fork();
- if (clist->mpid == 0)
- ft_music_fork(clist->mlist.mcmd_words, envp);
+ ft_enable_music(clist);
}
ft_hooks_and_loops(&clist->wlist, clist);
}
diff --git a/src/ft_warp_level.c b/src/ft_warp_level.c
index 2721aca..37789a5 100644
--- a/src/ft_warp_level.c
+++ b/src/ft_warp_level.c
@@ -78,9 +78,7 @@ static void
{
kill(cl->mpid, SIGTERM);
wait(&cl->mpid);
- /* cl->mpid = fork(); */
- /* if (cl->mpid == 0) */
- /* ft_music_fork(cl->mlist.mcmd_words); */
+ ft_enable_music(cl);
}
else if (isoldmus && cl->mlist.ismusic
&& !ft_strncmp(tmp_mup, cl->mlist.music_path, ft_strlen(tmp_mup) + 1))