diff options
author | kartofen <mladenovnasko0@gmail.com> | 2022-10-18 23:25:46 +0300 |
---|---|---|
committer | kartofen <mladenovnasko0@gmail.com> | 2022-10-18 23:25:46 +0300 |
commit | 145775818375bafcf191a7b4986e57a00b41ac68 (patch) | |
tree | b539525328515401be6bc2a6c9fb17841b8a16d1 /src/listener.c | |
parent | 7e64d0c78e8a21f2ede7eab1303758391001c0dc (diff) |
use glfw and some minor refactoring
Diffstat (limited to 'src/listener.c')
-rw-r--r-- | src/listener.c | 29 |
1 files changed, 18 insertions, 11 deletions
diff --git a/src/listener.c b/src/listener.c index 135405c..141a3f3 100644 --- a/src/listener.c +++ b/src/listener.c @@ -1,5 +1,6 @@ #include <stdio.h> #include <stdlib.h> +#include <string.h> #include <unistd.h> #include <fcntl.h> #include <pthread.h> @@ -9,32 +10,38 @@ #include "audio.h" #include "typedef.h" -char *cam_data; +char cam_data[BUF_CAP]; void *display_thread(void *arg) { (void)arg; - int c = 1; - char *name = "./display"; - display(&c, &name); - pthread_exit(0); + int r = display(); + if(r == 0) + info("display: closed\n"); + else + err("display: failed\n"); + exit(r); + // pthread_exit(0); } void on_recv(char *buf, int numbytes) { - cam_data = &(buf[REC_CAP]); - usleep(100000); - // audio_play(buf); + memcpy(cam_data, &(buf[REC_CAP]), BUF_CAP-REC_CAP); + audio_play(buf); } int main(void) { - // char empty[1024] = {0}; - // cam_data = empty; + memset(cam_data, 0, BUF_CAP); pthread_t tid; pthread_create(&tid, NULL, display_thread, NULL); - return listener("4950", &on_recv); + if(listener("4950", &on_recv) != 0) { + err("listener: failed"); + return 1; + } + + return 0; } |