76 lines
1.7 KiB
C
76 lines
1.7 KiB
C
#ifndef _DS_READER_INNER_H_
|
|
#define _DS_READER_INNER_H_
|
|
|
|
#include <pthread.h>
|
|
|
|
#include "dataserver_reader.h"
|
|
#include "list.h"
|
|
|
|
#ifdef __cplusplus
|
|
extern "C" {
|
|
#endif
|
|
|
|
typedef struct {
|
|
struct list_head head;
|
|
ds_data_callback_fn_t fn;
|
|
void *priv;
|
|
} ds_data_callback_t;
|
|
|
|
typedef struct {
|
|
struct list_head head;
|
|
|
|
#define MAX_SIZE_DEVNAME 256
|
|
char devname[MAX_SIZE_DEVNAME];
|
|
|
|
int fd;
|
|
int evtfd;
|
|
|
|
struct list_head callback_list;
|
|
/*
|
|
* The callback will be added into wait list first,
|
|
* reader task decides when to merge
|
|
* the waiting callbacks into the main list.
|
|
* To avoid partial data pkt in the buffer.
|
|
*/
|
|
struct list_head callback_wait_list;
|
|
pthread_mutex_t callback_list_lock;
|
|
|
|
pthread_t thread;
|
|
int running;
|
|
|
|
void* (*read_task)(void *);
|
|
|
|
size_t priv;
|
|
} reader_inst_t;
|
|
|
|
typedef void* (*ds_read_task_t)(void *);
|
|
typedef int (*ds_read_set_t)(reader_inst_t *inst, const char *settings);
|
|
typedef int (*ds_read_close_t)(reader_inst_t *inst);
|
|
|
|
typedef struct {
|
|
ds_read_task_t task;
|
|
ds_read_set_t set;
|
|
ds_read_close_t close;
|
|
} ds_reader_t;
|
|
|
|
typedef ds_reader_t* (*ds_reader_checker_t)(const char *devname);
|
|
|
|
#ifdef BUILD_FOR_ANDROID
|
|
#define _ds_readers_section __attribute__((retain, used, section("ds_readers")))
|
|
#else
|
|
#define _ds_readers_section __attribute__((used, section("ds_readers")))
|
|
#endif
|
|
#define REG_DS_READER(_func_) static ds_reader_checker_t _fn_##_func_ _ds_readers_section = _func_
|
|
|
|
extern size_t __start_ds_readers;
|
|
extern size_t __stop_ds_readers;
|
|
|
|
#define DS_READ_TASKS_CHECKER_START ((ds_reader_checker_t *)&__start_ds_readers)
|
|
#define DS_READ_TASKS_CHECKER_STOP ((ds_reader_checker_t *)&__stop_ds_readers)
|
|
|
|
#ifdef __cplusplus
|
|
}
|
|
#endif
|
|
#endif
|
|
|