2 * Copyright (C) 2015 "IoT.bzh"
4 * This program is free software: you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License as published by
6 * the Free Software Foundation, either version 3 of the License, or
7 * (at your option) any later version.
9 * This program is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details.
14 * You should have received a copy of the GNU General Public License
15 * along with this program. If not, see <http://www.gnu.org/licenses/>.
18 #ifndef RADIO_RTLSDR_H
19 #define RADIO_RTLSDR_H
21 /* -------------- RADIO RTLSDR DEFINITIONS ------------------ */
27 #include "local-def.h"
29 #define pthread_signal(n, m) pthread_mutex_lock(m); pthread_cond_signal(n); pthread_mutex_unlock(m)
30 #define pthread_wait(n, m) pthread_mutex_lock(m); pthread_cond_wait(n, m); pthread_mutex_unlock(m)
31 #define BUF_LEN 16*16384
33 typedef enum { FM, AM } Mode;
34 typedef struct dongle_ctx dongle_ctx;
35 typedef struct demod_ctx demod_ctx;
36 typedef struct output_ctx output_ctx;
37 typedef struct dev_ctx dev_ctx_T;
41 unsigned char thr_finished;
42 uint16_t buf[BUF_LEN];
48 unsigned char thr_finished;
52 int pre_r, pre_j, now_r, now_j, index;
53 int pre_index, now_index;
62 unsigned char thr_finished;
71 int used; // radio is free ???
76 unsigned char should_run;
83 PUBLIC unsigned int _radio_dev_count (void);
84 PUBLIC const char* _radio_dev_name (unsigned int);
86 STATIC void* _dongle_thread_fn (void *);
87 STATIC void* _demod_thread_fn (void *);
88 STATIC void* _output_thread_fn (void *);
89 STATIC unsigned char _radio_dev_init (struct dev_ctx *, unsigned int);
90 STATIC unsigned char _radio_dev_free (struct dev_ctx *);
91 STATIC void _radio_apply_params (struct dev_ctx *);
92 STATIC void _radio_start_threads (struct dev_ctx *);
93 STATIC void _radio_stop_threads (struct dev_ctx *);
95 static unsigned int init_dev_count = 0;
96 static struct dev_ctx **dev_ctx = NULL;
98 #endif /* RADIO_RTLSDR_H */