forked from charlie-foxtrot/RTLSDR-Airband
-
Notifications
You must be signed in to change notification settings - Fork 0
/
input-common.h
83 lines (75 loc) · 2.25 KB
/
input-common.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
/*
* input-common.h
*
* Copyright (c) 2015-2021 Tomasz Lemiech <[email protected]>
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#ifndef _INPUT_COMMON_H
#define _INPUT_COMMON_H 1
#include <pthread.h>
#include <libconfig.h++>
#ifdef __MINGW32__
#define MODULE_EXPORT extern "C" __declspec(dllexport)
#else
#if __GNUC__ >= 4
#define MODULE_EXPORT extern "C" __attribute__((visibility("default")))
#else
#define MODULE_EXPORT extern "C"
#endif
#endif
typedef enum {
SFMT_UNDEF = 0,
SFMT_U8,
SFMT_S8,
SFMT_S16,
SFMT_F32
} sample_format_t;
#define SAMPLE_FORMAT_CNT 5
typedef enum {
INPUT_UNKNOWN = 0,
INPUT_INITIALIZED,
INPUT_RUNNING,
INPUT_FAILED,
INPUT_STOPPED,
INPUT_DISABLED
} input_state_t;
#define INPUT_STATE_CNT 6
typedef struct input_t input_t;
struct input_t {
unsigned char *buffer;
void *dev_data;
size_t buf_size, bufs, bufe;
size_t overflow_count;
input_state_t state;
sample_format_t sfmt;
float fullscale;
int bytes_per_sample;
int sample_rate;
int centerfreq;
int (*parse_config)(input_t * const input, libconfig::Setting &cfg);
int (*init)(input_t * const input);
void *(*run_rx_thread)(void *input_ptr); // to be launched via pthread_create()
int (*set_centerfreq)(input_t * const input, int const centerfreq);
int (*stop)(input_t * const input) ;
pthread_t rx_thread;
pthread_mutex_t buffer_lock;
};
input_t *input_new(char const * const type);
int input_init(input_t * const input);
int input_parse_config(input_t * const input, libconfig::Setting &cfg);
int input_start(input_t * const input);
int input_set_centerfreq(input_t * const input, int const centerfreq);
int input_stop(input_t * const input);
#endif // _INPUT_COMMON_H