GNU Radio's TEST 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_visible;
49  bool d_active;
50  bool d_frozen;
51 
52  void worker();
53  static void _worker(base_sink_c_impl *obj);
54 
55  gr::thread::mutex d_render_mutex;
56 
57  /* fosphor core */
58  fifo *d_fifo;
59 
60  struct fosphor *d_fosphor;
61  struct fosphor_render *d_render_main;
62  struct fosphor_render *d_render_zoom;
63 
64  void render();
65 
66  static gr::thread::mutex s_boot_mutex;
67 
68  /* settings refresh logic */
69  enum {
70  SETTING_DIMENSIONS = (1 << 0),
71  SETTING_POWER_RANGE = (1 << 1),
72  SETTING_FREQUENCY_RANGE = (1 << 2),
73  SETTING_FFT_WINDOW = (1 << 3),
74  SETTING_RENDER_OPTIONS = (1 << 4),
75  };
76 
77  uint32_t d_settings_changed;
78  gr::thread::mutex d_settings_mutex;
79 
80  void settings_mark_changed(uint32_t setting);
81  uint32_t settings_get_and_reset_changed(void);
82  void settings_apply(uint32_t settings);
83 
84  /* settings values */
85  int d_width;
86  int d_height;
87 
88  static const int k_db_per_div[];
89  int d_db_ref;
90  int d_db_per_div_idx;
91 
92  bool d_zoom_enabled;
93  double d_zoom_center;
94  double d_zoom_width;
95 
96  float d_ratio;
97 
98  struct {
99  double center;
100  double span;
101  } d_frequency;
102 
103  gr::fft::window::win_type d_fft_window;
104 
105  protected:
107 
108  /* Delegated implementation of GL context management */
109  virtual void glctx_init() = 0;
110  virtual void glctx_poll() = 0;
111  virtual void glctx_swap() = 0;
112  virtual void glctx_fini() = 0;
113  virtual void glctx_update() = 0;
114 
115  /* Callbacks from GL window */
116  void cb_reshape(int width, int height);
117  void cb_visibility(bool visible);
118 
119  public:
120  virtual ~base_sink_c_impl();
121 
122  /* gr::fosphor::base_sink_c implementation */
123  void execute_ui_action(enum ui_action_t action);
124 
125  void set_frequency_range(const double center,
126  const double span);
127  void set_frequency_center(const double center);
128  void set_frequency_span(const double span);
129 
130  void set_fft_window(const gr::fft::window::win_type win);
131 
132  /* gr::sync_block implementation */
133  int work (int noutput_items,
134  gr_vector_const_void_star &input_items,
135  gr_vector_void_star &output_items);
136 
137  bool start();
138  bool stop();
139  };
140 
141  } // namespace fosphor
142 } // namespace gr
143 
144 #endif /* INCLUDED_GR_FOSPHOR_BASE_SINK_C_IMPL_H */
145 
gr::fosphor::base_sink_c_impl::work
int work(int noutput_items, gr_vector_const_void_star &input_items, gr_vector_void_star &output_items)
gr::fosphor::base_sink_c_impl::glctx_update
virtual void glctx_update()=0
gr::fosphor::base_sink_c_impl::glctx_poll
virtual void glctx_poll()=0
gr::fosphor::base_sink_c_impl::set_frequency_center
void set_frequency_center(const double center)
gr::fosphor::base_sink_c_impl::start
bool start()
gr::fosphor::base_sink_c_impl::cb_visibility
void cb_visibility(bool visible)
gr::fosphor::base_sink_c_impl::glctx_swap
virtual void glctx_swap()=0
gr::fosphor::base_sink_c_impl::execute_ui_action
void execute_ui_action(enum ui_action_t action)
base_sink_c.h
gr::fosphor::base_sink_c_impl::set_frequency_range
void set_frequency_range(const double center, const double span)
gr::fosphor::base_sink_c_impl::span
double span
Definition: base_sink_c_impl.h:100
fosphor_render
fosphor render options
Definition: fosphor.h:76
gr::fosphor::base_sink_c
Base fosphor sink API interface.
Definition: base_sink_c.h:38
gr::fosphor::base_sink_c::ui_action_t
ui_action_t
Definition: base_sink_c.h:44
gr::fosphor::base_sink_c_impl::stop
bool stop()
fosphor
Definition: private.h:44
gr::fosphor::base_sink_c_impl::base_sink_c_impl
base_sink_c_impl()
gr::fosphor::base_sink_c_impl::set_fft_window
void set_fft_window(const gr::fft::window::win_type win)
gr::fosphor::base_sink_c_impl
Base class for fosphor sink implementation.
Definition: base_sink_c_impl.h:44
gr::fosphor::base_sink_c_impl::glctx_fini
virtual void glctx_fini()=0
gr::fosphor::fifo
Definition: fifo.h:33
gr
Definition: base_sink_c.h:30
gr::fosphor::base_sink_c_impl::cb_reshape
void cb_reshape(int width, int height)
gr::fosphor::base_sink_c_impl::~base_sink_c_impl
virtual ~base_sink_c_impl()
gr::fosphor::base_sink_c_impl::set_frequency_span
void set_frequency_span(const double span)
gr::fosphor::base_sink_c_impl::glctx_init
virtual void glctx_init()=0
gr::fosphor::base_sink_c_impl::center
double center
Definition: base_sink_c_impl.h:99