GNU Radio's FOSPHOR Package
base_sink_c_impl.h
Go to the documentation of this file.
1 /* -*- c++ -*- */
2 /*
3  * Copyright 2013-2014 Sylvain Munaut <tnt@246tNt.com>
4  *
5  * This is free software; you can redistribute it and/or modify
6  * it under the terms of the GNU General Public License as published by
7  * the Free Software Foundation; either version 3, or (at your option)
8  * any later version.
9  *
10  * This software is distributed in the hope that it will be useful,
11  * but WITHOUT ANY WARRANTY; without even the implied warranty of
12  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13  * GNU General Public License for more details.
14  *
15  * You should have received a copy of the GNU General Public License
16  * along with this software; see the file COPYING. If not, write to
17  * the Free Software Foundation, Inc., 51 Franklin Street,
18  * Boston, MA 02110-1301, USA.
19  */
20 
21 
22 #ifndef INCLUDED_GR_FOSPHOR_BASE_SINK_C_IMPL_H
23 #define INCLUDED_GR_FOSPHOR_BASE_SINK_C_IMPL_H
24 
25 #include <stdint.h>
26 
27 #include <gnuradio/thread/thread.h>
28 
30 
31 struct fosphor;
32 struct fosphor_render;
33 
34 namespace gr {
35  namespace fosphor {
36 
37  class fifo;
38 
39  /*!
40  * \brief Base class for fosphor sink implementation
41  * \ingroup fosphor
42  */
43  class base_sink_c_impl : virtual public base_sink_c
44  {
45  private:
46  /* Worker thread */
47  gr::thread::thread d_worker;
48  bool d_active;
49  bool d_frozen;
50 
51  void worker();
52  static void _worker(base_sink_c_impl *obj);
53 
54  /* fosphor core */
55  fifo *d_fifo;
56 
57  struct fosphor *d_fosphor;
58  struct fosphor_render *d_render_main;
59  struct fosphor_render *d_render_zoom;
60 
61  void render();
62 
63  static gr::thread::mutex s_boot_mutex;
64 
65  /* settings refresh logic */
66  enum {
67  SETTING_DIMENSIONS = (1 << 0),
68  SETTING_POWER_RANGE = (1 << 1),
69  SETTING_FREQUENCY_RANGE = (1 << 2),
70  SETTING_FFT_WINDOW = (1 << 3),
71  SETTING_RENDER_OPTIONS = (1 << 4),
72  };
73 
74  uint32_t d_settings_changed;
75  thread::mutex d_settings_mutex;
76 
77  void settings_mark_changed(uint32_t setting);
78  uint32_t settings_get_and_reset_changed(void);
79  void settings_apply(uint32_t settings);
80 
81  /* settings values */
82  int d_width;
83  int d_height;
84 
85  static const int k_db_per_div[];
86  int d_db_ref;
87  int d_db_per_div_idx;
88 
89  bool d_zoom_enabled;
90  double d_zoom_center;
91  double d_zoom_width;
92 
93  float d_ratio;
94 
95  struct {
96  double center;
97  double span;
98  } d_frequency;
99 
100  gr::fft::window::win_type d_fft_window;
101 
102  protected:
104 
105  /* Delegated implementation of GL context management */
106  virtual void glctx_init() = 0;
107  virtual void glctx_poll() = 0;
108  virtual void glctx_swap() = 0;
109  virtual void glctx_fini() = 0;
110  virtual void glctx_update() = 0;
111 
112  /* Callbacks from GL window */
113  void cb_reshape(int width, int height);
114 
115  public:
116  virtual ~base_sink_c_impl();
117 
118  /* gr::fosphor::base_sink_c implementation */
119  void execute_ui_action(enum ui_action_t action);
120 
121  void set_frequency_range(const double center,
122  const double span);
123  void set_frequency_center(const double center);
124  void set_frequency_span(const double span);
125 
126  void set_fft_window(const gr::fft::window::win_type win);
127 
128  /* gr::sync_block implementation */
129  int work (int noutput_items,
130  gr_vector_const_void_star &input_items,
131  gr_vector_void_star &output_items);
132 
133  bool start();
134  bool stop();
135  };
136 
137  } // namespace fosphor
138 } // namespace gr
139 
140 #endif /* INCLUDED_GR_FOSPHOR_BASE_SINK_C_IMPL_H */
141 
Base fosphor sink API interface.
Definition: base_sink_c.h:37
double center
Definition: base_sink_c_impl.h:96
int work(int noutput_items, gr_vector_const_void_star &input_items, gr_vector_void_star &output_items)
void set_frequency_range(const double center, const double span)
virtual void glctx_update()=0
void set_fft_window(const gr::fft::window::win_type win)
Definition: private.h:43
Base class for fosphor sink implementation.
Definition: base_sink_c_impl.h:43
ui_action_t
Definition: base_sink_c.h:44
Definition: base_sink_c.h:30
void execute_ui_action(enum ui_action_t action)
void set_frequency_center(const double center)
fosphor render options
Definition: fosphor.h:75
void set_frequency_span(const double span)
double span
Definition: base_sink_c_impl.h:97
Definition: fifo.h:32
void cb_reshape(int width, int height)