forked from sdr/gr-osmosdr
rtl: implement methods allowing runtime to control sampling process
This commit is contained in:
parent
2ae3fdbc22
commit
74b9211cdc
|
@ -84,7 +84,7 @@ rtl_source_c::rtl_source_c (const std::string &args)
|
|||
gr_make_io_signature (MIN_OUT, MAX_OUT, sizeof (gr_complex))),
|
||||
_dev(NULL),
|
||||
_buf(NULL),
|
||||
_running(true),
|
||||
_running(false),
|
||||
_no_tuner(false),
|
||||
_auto_gain(false),
|
||||
_if_gain(0),
|
||||
|
@ -236,8 +236,6 @@ rtl_source_c::rtl_source_c (const std::string &args)
|
|||
for(unsigned int i = 0; i < _buf_num; ++i)
|
||||
_buf[i] = (unsigned short *) malloc(_buf_len);
|
||||
}
|
||||
|
||||
_thread = gruel::thread(_rtlsdr_wait, this);
|
||||
}
|
||||
|
||||
/*
|
||||
|
@ -246,9 +244,13 @@ rtl_source_c::rtl_source_c (const std::string &args)
|
|||
rtl_source_c::~rtl_source_c ()
|
||||
{
|
||||
if (_dev) {
|
||||
_running = false;
|
||||
rtlsdr_cancel_async( _dev );
|
||||
_thread.join();
|
||||
if (_running)
|
||||
{
|
||||
_running = false;
|
||||
rtlsdr_cancel_async( _dev );
|
||||
_thread.join();
|
||||
}
|
||||
|
||||
rtlsdr_close( _dev );
|
||||
_dev = NULL;
|
||||
}
|
||||
|
@ -264,6 +266,24 @@ rtl_source_c::~rtl_source_c ()
|
|||
}
|
||||
}
|
||||
|
||||
bool rtl_source_c::start()
|
||||
{
|
||||
_running = true;
|
||||
_thread = gruel::thread(_rtlsdr_wait, this);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
bool rtl_source_c::stop()
|
||||
{
|
||||
_running = false;
|
||||
if (_dev)
|
||||
rtlsdr_cancel_async( _dev );
|
||||
_thread.join();
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
void rtl_source_c::_rtlsdr_callback(unsigned char *buf, uint32_t len, void *ctx)
|
||||
{
|
||||
rtl_source_c *obj = (rtl_source_c *)ctx;
|
||||
|
|
|
@ -112,6 +112,10 @@ public:
|
|||
std::string set_antenna( const std::string & antenna, size_t chan = 0 );
|
||||
std::string get_antenna( size_t chan = 0 );
|
||||
|
||||
protected:
|
||||
bool start();
|
||||
bool stop();
|
||||
|
||||
private:
|
||||
static void _rtlsdr_callback(unsigned char *buf, uint32_t len, void *ctx);
|
||||
void rtlsdr_callback(unsigned char *buf, uint32_t len);
|
||||
|
|
Loading…
Reference in New Issue