Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 16 additions & 6 deletions src/librtlsdr.c
Original file line number Diff line number Diff line change
Expand Up @@ -1298,14 +1298,16 @@ static rtlsdr_dongle_t *find_known_device(uint16_t vid, uint16_t pid)

uint32_t rtlsdr_get_device_count(void)
{
int i;
int i,r;
libusb_context *ctx;
libusb_device **list;
uint32_t device_count = 0;
struct libusb_device_descriptor dd;
ssize_t cnt;

libusb_init(&ctx);
r = libusb_init(&ctx);
if(r < 0)
return 0;

cnt = libusb_get_device_list(ctx, &list);

Expand All @@ -1325,15 +1327,17 @@ uint32_t rtlsdr_get_device_count(void)

const char *rtlsdr_get_device_name(uint32_t index)
{
int i;
int i,r;
libusb_context *ctx;
libusb_device **list;
struct libusb_device_descriptor dd;
rtlsdr_dongle_t *device = NULL;
uint32_t device_count = 0;
ssize_t cnt;

libusb_init(&ctx);
r = libusb_init(&ctx);
if(r < 0)
return "";

cnt = libusb_get_device_list(ctx, &list);

Expand Down Expand Up @@ -1373,7 +1377,9 @@ int rtlsdr_get_device_usb_strings(uint32_t index, char *manufact,
uint32_t device_count = 0;
ssize_t cnt;

libusb_init(&ctx);
r = libusb_init(&ctx);
if(r < 0)
return r;

cnt = libusb_get_device_list(ctx, &list);

Expand Down Expand Up @@ -1447,7 +1453,11 @@ int rtlsdr_open(rtlsdr_dev_t **out_dev, uint32_t index)
memset(dev, 0, sizeof(rtlsdr_dev_t));
memcpy(dev->fir, fir_default, sizeof(fir_default));

libusb_init(&dev->ctx);
r = libusb_init(&dev->ctx);
if(r < 0){
free(dev);
return -1;
}

dev->dev_lost = 1;

Expand Down
2 changes: 2 additions & 0 deletions src/rtl_adsb.c
Original file line number Diff line number Diff line change
Expand Up @@ -45,8 +45,10 @@

#ifdef _WIN32
#define sleep Sleep
#if defined(_MSC_VER) && (_MSC_VER < 1800)
#define round(x) (x > 0.0 ? floor(x + 0.5): ceil(x - 0.5))
#endif
#endif

#define ADSB_RATE 2000000
#define ADSB_FREQ 1090000000
Expand Down
24 changes: 17 additions & 7 deletions src/rtl_fm.c
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,6 @@
#include <string.h>
#include <stdio.h>
#include <stdlib.h>

#ifndef _WIN32
#include <unistd.h>
#else
Expand All @@ -62,7 +61,7 @@
#include <io.h>
#include "getopt/getopt.h"
#define usleep(x) Sleep(x/1000)
#ifdef _MSC_VER
#if defined(_MSC_VER) && (_MSC_VER < 1800)
#define round(x) (x > 0.0 ? floor(x + 0.5): ceil(x - 0.5))
#endif
#define _USE_MATH_DEFINES
Expand Down Expand Up @@ -271,7 +270,7 @@ int cic_9_tables[][10] = {
{9, -199, -362, 5303, -25505, 77489, -25505, 5303, -362, -199},
};

#ifdef _MSC_VER
#if defined(_MSC_VER) && (_MSC_VER < 1800)
double log2(double n)
{
return log(n) / log(2.0);
Expand Down Expand Up @@ -718,10 +717,19 @@ void arbitrary_downsample(int16_t *buf1, int16_t *buf2, int len1, int len2)

void arbitrary_resample(int16_t *buf1, int16_t *buf2, int len1, int len2)
/* up to you to calculate lengths and make sure it does not go OOB
* okay for buffers to overlap, if you are downsampling */
* okay for buffers to overlap, if you are downsampling
* fix overlapping buffers when upsampling */
{
static int16_t *buftemp=NULL;
if (len1 < len2) {
arbitrary_upsample(buf1, buf2, len1, len2);
if(buf1!=buf2)
arbitrary_upsample(buf1, buf2, len1, len2);
else
{
buftemp=realloc(buftemp,2*len2); /* FIXME: Handle out of memory */
arbitrary_upsample(buf1, buftemp, len1, len2);
memcpy(buf2,buftemp,2*len2);
}
} else {
arbitrary_downsample(buf1, buf2, len1, len2);
}
Expand Down Expand Up @@ -772,8 +780,10 @@ void full_demod(struct demod_state *d)
if (d->dc_block) {
dc_block_filter(d);}
if (d->rate_out2 > 0) {
low_pass_real(d);
//arbitrary_resample(d->result, d->result, d->result_len, d->result_len * d->rate_out2 / d->rate_out);
// low_pass_real(d);
arbitrary_resample(d->result, d->result, d->result_len, d->result_len * d->rate_out2 / d->rate_out);
d->result_len*=d->rate_out2;
d->result_len/=d->rate_out;
}
}

Expand Down
4 changes: 2 additions & 2 deletions src/rtl_power.c
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@
#include <io.h>
#include "getopt/getopt.h"
#define usleep(x) Sleep(x/1000)
#ifdef _MSC_VER
#if defined(_MSC_VER) && (_MSC_VER < 1800)
#define round(x) (x > 0.0 ? floor(x + 0.5): ceil(x - 0.5))
#endif
#define _USE_MATH_DEFINES
Expand Down Expand Up @@ -220,7 +220,7 @@ int cic_9_tables[][10] = {
{9, -199, -362, 5303, -25505, 77489, -25505, 5303, -362, -199},
};

#ifdef _MSC_VER
#if defined(_MSC_VER) && (_MSC_VER < 1800)
double log2(double n)
{
return log(n) / log(2.0);
Expand Down