diff options
author | rear1019 <rear1019@posteo.de> | 2020-03-29 11:04:24 +0200 |
---|---|---|
committer | Marcus Müller <marcus@hostalia.de> | 2020-04-13 14:23:31 +0200 |
commit | ec8a92846a388cb0d2982822ea1961910cd552f8 (patch) | |
tree | 22f948325fa655bdbe4787758e296b603d743471 | |
parent | 596c6495f3bdf579dae0c26531a16f6adcc7fb2f (diff) |
file_sink: Flush file on stop()
Make sure that data passed to the file sink is written to the disk when
the flowgraph is stopped. Before this change this only happened
implicitly due to a fclose() in the base class destructor. This in turn
means that data was written delayed after stopping the flowgraph [1].
This fixes #2590.
[1] https://github.com/gnuradio/gnuradio/issues/2590
-rw-r--r-- | gr-blocks/lib/file_sink_impl.cc | 7 | ||||
-rw-r--r-- | gr-blocks/lib/file_sink_impl.h | 2 |
2 files changed, 9 insertions, 0 deletions
diff --git a/gr-blocks/lib/file_sink_impl.cc b/gr-blocks/lib/file_sink_impl.cc index 7f2c462030..75995da9a0 100644 --- a/gr-blocks/lib/file_sink_impl.cc +++ b/gr-blocks/lib/file_sink_impl.cc @@ -67,5 +67,12 @@ int file_sink_impl::work(int noutput_items, return nwritten; } +bool file_sink_impl::stop() +{ + do_update(); + fflush(d_fp); + return true; +} + } /* namespace blocks */ } /* namespace gr */ diff --git a/gr-blocks/lib/file_sink_impl.h b/gr-blocks/lib/file_sink_impl.h index 8fb89d37f0..18d2539860 100644 --- a/gr-blocks/lib/file_sink_impl.h +++ b/gr-blocks/lib/file_sink_impl.h @@ -28,6 +28,8 @@ public: int work(int noutput_items, gr_vector_const_void_star& input_items, gr_vector_void_star& output_items); + + bool stop() override; }; } /* namespace blocks */ |