summaryrefslogtreecommitdiff
path: root/gnuradio-core/src/lib/general
diff options
context:
space:
mode:
authorjcorgan2006-11-27 04:53:34 +0000
committerjcorgan2006-11-27 04:53:34 +0000
commit7887a76a7d9eb140da6a33c15845f2ad5a072faa (patch)
tree915883179103c51bae9a3aea1e86fcb093a608c0 /gnuradio-core/src/lib/general
parent41d981f49e20fc55a6bc23ff854c2f868c980e6c (diff)
downloadgnuradio-7887a76a7d9eb140da6a33c15845f2ad5a072faa.tar.gz
gnuradio-7887a76a7d9eb140da6a33c15845f2ad5a072faa.tar.bz2
gnuradio-7887a76a7d9eb140da6a33c15845f2ad5a072faa.zip
Fixes ticket:103 (patch applied)
git-svn-id: http://gnuradio.org/svn/gnuradio/trunk@4032 221aa14e-8319-0410-a670-987f0aec2ac5
Diffstat (limited to 'gnuradio-core/src/lib/general')
-rw-r--r--gnuradio-core/src/lib/general/gr_throttle.cc9
1 files changed, 8 insertions, 1 deletions
diff --git a/gnuradio-core/src/lib/general/gr_throttle.cc b/gnuradio-core/src/lib/general/gr_throttle.cc
index 95c73c41c..f8bbc184b 100644
--- a/gnuradio-core/src/lib/general/gr_throttle.cc
+++ b/gnuradio-core/src/lib/general/gr_throttle.cc
@@ -32,6 +32,9 @@
#ifdef HAVE_TIME_H
#include <time.h>
#endif
+#if !defined(HAVE_NANOSLEEP) && defined(HAVE_SSLEEP)
+#include <windows.h>
+#endif
#ifdef HAVE_NANOSLEEP
@@ -80,7 +83,7 @@ gr_throttle::work (int noutput_items,
const char *in = (const char *) input_items[0];
char *out = (char *) output_items[0];
-#if defined(HAVE_GETTIMEOFDAY) && defined(HAVE_NANOSLEEP)
+#if defined(HAVE_GETTIMEOFDAY)
//
// If our average sample rate exceeds our target sample rate,
// delay long enough to reduce to our target rate.
@@ -96,10 +99,14 @@ gr_throttle::work (int noutput_items,
double actual_samples_per_sec = d_total_samples / t;
if (actual_samples_per_sec > d_samples_per_sec){ // need to delay
double delay = d_total_samples / d_samples_per_sec - t;
+#ifdef HAVE_NANOSLEEP
struct timespec ts;
ts.tv_sec = (time_t)floor(delay);
ts.tv_nsec = (long)((delay - floor(delay)) * 1e9);
gr_nanosleep(&ts);
+#elif HAVE_SSLEEP
+ Sleep( (DWORD)(delay*1000) );
+#endif
}
#endif