aboutsummaryrefslogtreecommitdiff
path: root/src/listener.c
diff options
context:
space:
mode:
authorkartofen <mladenovnasko0@gmail.com>2022-10-16 22:55:45 +0300
committerkartofen <mladenovnasko0@gmail.com>2022-10-16 22:55:45 +0300
commitb1b7c92aa96af5502f276819b628b05d54f4655c (patch)
tree6a04459dc7128fd4259356a88785defeab678b30 /src/listener.c
parent675ded0d66b9fd60777d3037ded1446a3f9ef986 (diff)
nearly works
Diffstat (limited to 'src/listener.c')
-rw-r--r--src/listener.c19
1 files changed, 17 insertions, 2 deletions
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 <stdio.h>
-#include <fcntl.h>
+#include <stdlib.h>
#include <unistd.h>
+#include <fcntl.h>
#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)