summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--gnuradio-core/src/lib/io/gr_file_sink.cc3
-rw-r--r--gnuradio-core/src/lib/io/gr_file_sink_base.cc6
-rw-r--r--gnuradio-core/src/lib/io/gr_file_sink_base.h7
-rw-r--r--gnuradio-core/src/lib/io/gr_file_sink_base.i5
-rw-r--r--grc/blocks/gr_file_sink.xml19
5 files changed, 39 insertions, 1 deletions
diff --git a/gnuradio-core/src/lib/io/gr_file_sink.cc b/gnuradio-core/src/lib/io/gr_file_sink.cc
index d40235fab..d2c43aac7 100644
--- a/gnuradio-core/src/lib/io/gr_file_sink.cc
+++ b/gnuradio-core/src/lib/io/gr_file_sink.cc
@@ -70,5 +70,8 @@ gr_file_sink::work (int noutput_items,
nwritten += count;
inbuf += count * d_itemsize;
}
+ if (d_unbuffered)
+ fflush (d_fp);
+
return nwritten;
}
diff --git a/gnuradio-core/src/lib/io/gr_file_sink_base.cc b/gnuradio-core/src/lib/io/gr_file_sink_base.cc
index 5ddeeb4d5..c43304b0d 100644
--- a/gnuradio-core/src/lib/io/gr_file_sink_base.cc
+++ b/gnuradio-core/src/lib/io/gr_file_sink_base.cc
@@ -118,3 +118,9 @@ gr_file_sink_base::do_update()
d_updated = false;
}
}
+
+void
+gr_file_sink_base::set_unbuffered(bool unbuffered)
+{
+ d_unbuffered = unbuffered;
+}
diff --git a/gnuradio-core/src/lib/io/gr_file_sink_base.h b/gnuradio-core/src/lib/io/gr_file_sink_base.h
index 0c028d7fd..7b96cdb7f 100644
--- a/gnuradio-core/src/lib/io/gr_file_sink_base.h
+++ b/gnuradio-core/src/lib/io/gr_file_sink_base.h
@@ -37,6 +37,7 @@ class gr_file_sink_base
bool d_updated; // is there a new FILE pointer?
bool d_is_binary;
boost::mutex d_mutex;
+ bool d_unbuffered;
protected:
gr_file_sink_base(const char *filename, bool is_binary);
@@ -61,6 +62,12 @@ class gr_file_sink_base
* \brief if we've had an update, do it now.
*/
void do_update();
+
+
+ /*!
+ * \brief turn on unbuffered writes for slower outputs
+ */
+ void set_unbuffered(bool unbuffered);
};
diff --git a/gnuradio-core/src/lib/io/gr_file_sink_base.i b/gnuradio-core/src/lib/io/gr_file_sink_base.i
index 05a3353bb..ed4342482 100644
--- a/gnuradio-core/src/lib/io/gr_file_sink_base.i
+++ b/gnuradio-core/src/lib/io/gr_file_sink_base.i
@@ -43,4 +43,9 @@ class gr_file_sink_base
* \brief if we've had an update, do it now.
*/
void do_update();
+
+ /*!
+ *\brief turn on unbuffered mode for slow outputs
+ */
+ void set_unbuffered(bool unbuffered);
};
diff --git a/grc/blocks/gr_file_sink.xml b/grc/blocks/gr_file_sink.xml
index 880dc2759..0081c93f8 100644
--- a/grc/blocks/gr_file_sink.xml
+++ b/grc/blocks/gr_file_sink.xml
@@ -8,7 +8,9 @@
<name>File Sink</name>
<key>gr_file_sink</key>
<import>from gnuradio import gr</import>
- <make>gr.file_sink($type.size*$vlen, $file)</make>
+ <make>gr.file_sink($type.size*$vlen, $file)
+self.$(id).set_unbuffered($unbuffered)</make>
+ <callback>set_unbuffered($unbuffered)</callback>
<param>
<name>File</name>
<key>file</key>
@@ -51,6 +53,21 @@
<value>1</value>
<type>int</type>
</param>
+ <param>
+ <name>Unbuffered</name>
+ <key>unbuffered</key>
+ <value>False</value>
+ <type>bool</type>
+ <option>
+ <name>Off</name>
+ <key>False</key>
+ </option>
+ <option>
+ <name>On</name>
+ <key>True</key>
+ </option>
+ </param>
+
<check>$vlen &gt; 0</check>
<sink>
<name>in</name>