patch-gnuradio
[Top][All Lists]
Advanced

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

[Patch-gnuradio] [PATCH] WAV sink: is now threadsafe; do_update() theref


From: Martin Braun
Subject: [Patch-gnuradio] [PATCH] WAV sink: is now threadsafe; do_update() therefore must be private
Date: Mon, 12 Dec 2011 18:49:47 +0100

---
 gnuradio-core/src/lib/io/gr_wavfile_sink.cc |    2 +-
 gnuradio-core/src/lib/io/gr_wavfile_sink.h  |   14 +++++++-------
 2 files changed, 8 insertions(+), 8 deletions(-)

diff --git a/gnuradio-core/src/lib/io/gr_wavfile_sink.cc 
b/gnuradio-core/src/lib/io/gr_wavfile_sink.cc
index a96aadc..88b2323 100644
--- a/gnuradio-core/src/lib/io/gr_wavfile_sink.cc
+++ b/gnuradio-core/src/lib/io/gr_wavfile_sink.cc
@@ -184,6 +184,7 @@ gr_wavfile_sink::work (int noutput_items,
   
   int nwritten;
   
+  gruel::scoped_lock guard(d_mutex);     // hold mutex for duration of this 
block
   do_update(); // update: d_fp is reqd
   if (!d_fp)   // drop output on the floor
     return noutput_items;
@@ -254,7 +255,6 @@ gr_wavfile_sink::do_update()
     return;
   }
   
-  gruel::scoped_lock guard(d_mutex);     // hold mutex for duration of this 
block
   if (d_fp) {
     close_wav();
   }
diff --git a/gnuradio-core/src/lib/io/gr_wavfile_sink.h 
b/gnuradio-core/src/lib/io/gr_wavfile_sink.h
index 5fd3eaa..6a6b7eb 100644
--- a/gnuradio-core/src/lib/io/gr_wavfile_sink.h
+++ b/gnuradio-core/src/lib/io/gr_wavfile_sink.h
@@ -86,6 +86,13 @@ private:
   short convert_to_short(float sample);
 
   /*!
+   * \brief If any file changes have occurred, update now. This is called
+   * internally by work() and thus doesn't usually need to be called by
+   * hand.
+   */
+  void do_update();
+  
+  /*!
    * \brief Writes information to the WAV header which is not available
    * a-priori (chunk size etc.) and closes the file. Not thread-safe and
    * assumes d_fp is a valid file pointer, should thus only be called by
@@ -108,13 +115,6 @@ public:
   void close();
 
   /*!
-   * \brief If any file changes have occurred, update now. This is called
-   * internally by work() and thus doesn't usually need to be called by
-   * hand.
-   */
-  void do_update();
-  
-  /*!
    * \brief Set the sample rate. This will not affect the WAV file
    * currently opened. Any following open() calls will use this new
    * sample rate.
-- 
1.7.5.4




reply via email to

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