2026-05-24 17:13:03 +05:30
|
|
|
#ifndef THREAD_SHARING_H
|
2026-05-25 13:50:49 +05:30
|
|
|
#define THREAD_SHARING_H
|
2026-05-24 17:13:03 +05:30
|
|
|
|
2026-05-25 13:50:49 +05:30
|
|
|
#include "ascii.h"
|
2026-05-20 16:20:11 +05:30
|
|
|
#include <pthread.h>
|
|
|
|
|
#include <stdint.h>
|
|
|
|
|
|
|
|
|
|
typedef struct {
|
2026-05-25 13:50:49 +05:30
|
|
|
uint8_t *buf[2]; // Double buffer, one slot per thread
|
|
|
|
|
int width, height; // capture dimensions
|
|
|
|
|
int ascii_w, ascii_h;
|
|
|
|
|
int ready_idx; // which slot has the freshest frame
|
|
|
|
|
int has_frame; // non-zero once producer has written once
|
2026-05-20 16:20:11 +05:30
|
|
|
pthread_mutex_t lock;
|
2026-05-25 13:50:49 +05:30
|
|
|
pthread_cond_t cond;
|
|
|
|
|
volatile int stop;
|
|
|
|
|
ascii_opts_t opts;
|
2026-05-20 16:20:11 +05:30
|
|
|
} shared_frame_t;
|
|
|
|
|
|
2026-05-24 17:13:03 +05:30
|
|
|
void *capture_thread(void *arg);
|
2026-05-25 13:50:49 +05:30
|
|
|
void *render_thread(void *arg);
|
2026-05-24 17:13:03 +05:30
|
|
|
|
|
|
|
|
#endif
|