diff options
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; } |