From f4c66a4c77e5818ca9703f59a80ea92e27ed45c6 Mon Sep 17 00:00:00 2001 From: kartofen Date: Sat, 22 Oct 2022 21:08:08 +0300 Subject: abstract messages for easier use --- src/listener.c | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) (limited to 'src/listener.c') diff --git a/src/listener.c b/src/listener.c index b344b6e..f819383 100644 --- a/src/listener.c +++ b/src/listener.c @@ -10,7 +10,9 @@ #include "audio.h" #include "typedef.h" -char cam_data[BUF_CAP]; +char cam_data[BUF_CAP] = {0}; +unsigned int WIDTH = 1; +unsigned int HEIGHT = 1; void *display_thread(void *arg) { @@ -24,18 +26,17 @@ void *display_thread(void *arg) exit(r); } -void on_recv(char *buf, int numbytes) +void on_recv(message *m) { - (void)numbytes; + WIDTH = m->WIDTH; + HEIGHT = m->HEIGHT; - memcpy(cam_data, &(buf[REC_CAP]), BUF_CAP-REC_CAP); - audio_play(buf); + memcpy(cam_data, m->video, WIDTH * HEIGHT * 3); + audio_play(m->audio); } int main(void) { - memset(cam_data, 0, BUF_CAP); - pthread_t tid; pthread_create(&tid, NULL, display_thread, NULL); -- cgit v1.2.3