summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorChristian Vogel <vogelchr@vogel.cx>2012-05-17 21:54:24 +0200
committerSteve Markgraf <steve@steve-m.de>2012-05-17 21:58:53 +0200
commit589e96e8d8e40e84061bca07474787bfd3f505eb (patch)
treea97695e11fbf4fbe0c4c70c576e172d4d6789a8e /src
parentc426e94093ef4b30620f88236077706abe4b6832 (diff)
Using a #define for constant 2^22 (not pow())
pow() might require the math library to be linked with rtl-sdl (e.g. when compiling with clang), even though it's actually constant. Signed-off-by: Steve Markgraf <steve@steve-m.de>
Diffstat (limited to 'src')
-rw-r--r--src/librtlsdr.c7
1 files changed, 5 insertions, 2 deletions
diff --git a/src/librtlsdr.c b/src/librtlsdr.c
index 6a9539b..da79acb 100644
--- a/src/librtlsdr.c
+++ b/src/librtlsdr.c
@@ -675,6 +675,9 @@ int rtlsdr_set_tuner_gain_mode(rtlsdr_dev_t *dev, int mode)
return r;
}
+/* two raised to the power of n */
+#define TWO_POW(n) ((double)(1ULL<<(n)))
+
int rtlsdr_set_sample_rate(rtlsdr_dev_t *dev, uint32_t samp_rate)
{
uint16_t tmp;
@@ -688,10 +691,10 @@ int rtlsdr_set_sample_rate(rtlsdr_dev_t *dev, uint32_t samp_rate)
if (samp_rate > MAX_SAMP_RATE)
samp_rate = MAX_SAMP_RATE;
- rsamp_ratio = (dev->rtl_xtal * pow(2, 22)) / samp_rate;
+ rsamp_ratio = (dev->rtl_xtal * TWO_POW(22)) / samp_rate;
rsamp_ratio &= ~3;
- real_rate = (dev->rtl_xtal * pow(2, 22)) / rsamp_ratio;
+ real_rate = (dev->rtl_xtal * TWO_POW(22)) / rsamp_ratio;
if ( ((double)samp_rate) != real_rate )
fprintf(stderr, "Exact sample rate is: %f Hz\n", real_rate);