commit-gnuradio
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Commit-gnuradio] [gnuradio] 08/16: analog: Wrapped squelch blocks' sett


From: git
Subject: [Commit-gnuradio] [gnuradio] 08/16: analog: Wrapped squelch blocks' setter methods with lock
Date: Sun, 29 Mar 2015 02:27:26 +0000 (UTC)

This is an automated email from the git hooks/post-receive script.

jcorgan pushed a commit to branch master
in repository gnuradio.

commit 816eb840fd86000b12525ff28d128fe643a15a73
Author: Jon Szymaniak <address@hidden>
Date:   Tue Mar 24 11:52:45 2015 -0400

    analog: Wrapped squelch blocks' setter methods with lock
    
    The setter methods of squelch_base and its children have been updated to
    hold d_setlock to avoid races.
    
    For example, updating the CTCSS frequency parameter requires
    updates to three separate fft::goertzel objects, which are used during
    the general_work().
---
 gr-analog/lib/ctcss_squelch_ff_impl.cc | 15 +++++++++++++++
 gr-analog/lib/ctcss_squelch_ff_impl.h  |  9 ++-------
 gr-analog/lib/pwr_squelch_cc_impl.cc   | 14 ++++++++++++++
 gr-analog/lib/pwr_squelch_cc_impl.h    |  4 ++--
 gr-analog/lib/squelch_base_cc_impl.cc  |  4 ++++
 5 files changed, 37 insertions(+), 9 deletions(-)

diff --git a/gr-analog/lib/ctcss_squelch_ff_impl.cc 
b/gr-analog/lib/ctcss_squelch_ff_impl.cc
index fb34485..7edda64 100644
--- a/gr-analog/lib/ctcss_squelch_ff_impl.cc
+++ b/gr-analog/lib/ctcss_squelch_ff_impl.cc
@@ -149,5 +149,20 @@ namespace gr {
       }
     }
 
+    void
+    ctcss_squelch_ff_impl::set_level(float level)
+    {
+      gr::thread::scoped_lock l(d_setlock);
+      d_level = level;
+    }
+
+    void
+    ctcss_squelch_ff_impl::set_frequency(float frequency)
+    {
+      gr::thread::scoped_lock l(d_setlock);
+      d_freq = frequency;
+      update_fft_params();
+    }
+
   } /* namespace analog */
 } /* namespace gr */
diff --git a/gr-analog/lib/ctcss_squelch_ff_impl.h 
b/gr-analog/lib/ctcss_squelch_ff_impl.h
index 67ce66c..f6e12de 100644
--- a/gr-analog/lib/ctcss_squelch_ff_impl.h
+++ b/gr-analog/lib/ctcss_squelch_ff_impl.h
@@ -59,15 +59,10 @@ namespace gr {
 
       std::vector<float> squelch_range() const;
       float level() const { return d_level; }
-      void set_level(float level) { d_level = level; }
+      void set_level(float level);
       int len() const { return d_len; }
       float frequency() const { return d_freq; }
-
-      void set_frequency(float frequency)
-      {
-          d_freq = frequency;
-          update_fft_params();
-      }
+      void set_frequency(float frequency);
 
       int ramp() const { return squelch_base_ff_impl::ramp(); }
       void set_ramp(int ramp) { squelch_base_ff_impl::set_ramp(ramp); }
diff --git a/gr-analog/lib/pwr_squelch_cc_impl.cc 
b/gr-analog/lib/pwr_squelch_cc_impl.cc
index 1a414ed..62b9cff 100644
--- a/gr-analog/lib/pwr_squelch_cc_impl.cc
+++ b/gr-analog/lib/pwr_squelch_cc_impl.cc
@@ -69,5 +69,19 @@ namespace gr {
       d_pwr = d_iir.filter(in.real()*in.real()+in.imag()*in.imag());
     }
 
+    void
+    pwr_squelch_cc_impl::set_threshold(double db)
+    {
+        gr::thread::scoped_lock l(d_setlock);
+        d_threshold = std::pow(10.0, db/10);
+    }
+
+    void
+    pwr_squelch_cc_impl::set_alpha(double alpha)
+    {
+        gr::thread::scoped_lock l(d_setlock);
+        d_iir.set_taps(alpha);
+    }
+
   } /* namespace analog */
 } /* namespace gr */
diff --git a/gr-analog/lib/pwr_squelch_cc_impl.h 
b/gr-analog/lib/pwr_squelch_cc_impl.h
index eea881a..d72ad58 100644
--- a/gr-analog/lib/pwr_squelch_cc_impl.h
+++ b/gr-analog/lib/pwr_squelch_cc_impl.h
@@ -51,8 +51,8 @@ namespace gr {
       std::vector<float> squelch_range() const;
 
       double threshold() const { return 10*log10(d_threshold); }
-      void set_threshold(double db) { d_threshold = std::pow(10.0, db/10); }
-      void set_alpha(double alpha) { d_iir.set_taps(alpha); }
+      void set_threshold(double db);
+      void set_alpha(double alpha);
 
       int ramp() const { return squelch_base_cc_impl::ramp(); }
       void set_ramp(int ramp) { squelch_base_cc_impl::set_ramp(ramp); }
diff --git a/gr-analog/lib/squelch_base_cc_impl.cc 
b/gr-analog/lib/squelch_base_cc_impl.cc
index c62efc3..3255d3b 100644
--- a/gr-analog/lib/squelch_base_cc_impl.cc
+++ b/gr-analog/lib/squelch_base_cc_impl.cc
@@ -55,6 +55,7 @@ namespace gr {
     void
     squelch_base_cc_impl::set_ramp(int ramp)
     {
+      gr::thread::scoped_lock l(d_setlock);
       d_ramp = ramp;
     }
 
@@ -67,6 +68,7 @@ namespace gr {
     void
     squelch_base_cc_impl::set_gate(bool gate)
     {
+      gr::thread::scoped_lock l(d_setlock);
       d_gate = gate;
     }
 
@@ -87,6 +89,8 @@ namespace gr {
 
       int j = 0;
 
+      gr::thread::scoped_lock l(d_setlock);
+
       for(int i = 0; i < noutput_items; i++) {
        update_state(in[i]);
 



reply via email to

[Prev in Thread] Current Thread [Next in Thread]