From b1b7c92aa96af5502f276819b628b05d54f4655c Mon Sep 17 00:00:00 2001 From: kartofen Date: Sun, 16 Oct 2022 22:55:45 +0300 Subject: nearly works --- src/listener.c | 19 +++++++++++++++++-- 1 file changed, 17 insertions(+), 2 deletions(-) (limited to 'src/listener.c') diff --git a/src/listener.c b/src/listener.c index 0a5df2d..7e9a839 100644 --- a/src/listener.c +++ b/src/listener.c @@ -1,9 +1,11 @@ #include -#include +#include #include +#include #include "socket.h" #include "display.h" +#include "audio.h" #include "typedef.h" static int fd; @@ -11,7 +13,20 @@ static int fd; void on_recv(char *buf, int numbytes) { // read and play audio - write(fd, buf, numbytes); + pid_t p = fork(); + if(p < 0) { + fputs("fork: failed", stderr); + exit(1); + } else if(p > 0) { + write(fd, &(buf[REC_CAP]), numbytes-REC_CAP); + } else { + audio_play(buf); + exit(0); + } + + // audio_play(buf); + // write(fd, &(buf[REC_CAP]), numbytes-REC_CAP); + } int main(int argc, char **argv) -- cgit v1.2.3