diff options
author | Dimitri Stolnikov <horiz0n@gmx.net> | 2013-04-26 21:50:50 +0200 |
---|---|---|
committer | Dimitri Stolnikov <horiz0n@gmx.net> | 2013-04-26 21:50:50 +0200 |
commit | 37f6383c7c7383a5ee5402f2ad0d260db250bb7b (patch) | |
tree | 229b31cf35e7697aaa2bb5e04084f8f7e3b8ee09 /lib/hackrf/hackrf_source_c.cc | |
parent | 9bd7cbf4e180c176b7b8e8418b6f2a2b0626ca48 (diff) |
hackf: implement start & stop methods
This allows a block to enable an associated driver to begin
transfering data just before we start to execute the scheduler.
The end result is that this reduces latency in the pipeline
when dealing with audio devices, usrps, etc.
Diffstat (limited to 'lib/hackrf/hackrf_source_c.cc')
-rw-r--r-- | lib/hackrf/hackrf_source_c.cc | 39 |
1 files changed, 32 insertions, 7 deletions
diff --git a/lib/hackrf/hackrf_source_c.cc b/lib/hackrf/hackrf_source_c.cc index 51268c9..2b74afb 100644 --- a/lib/hackrf/hackrf_source_c.cc +++ b/lib/hackrf/hackrf_source_c.cc @@ -176,12 +176,6 @@ hackrf_source_c::hackrf_source_c (const std::string &args) _buf[i] = (unsigned short *) malloc(_buf_len); } - ret = hackrf_start_rx( _dev, _hackrf_rx_callback, (void *)this ); - if (ret != HACKRF_SUCCESS) - std::cerr << "Failed to start streaming (" << ret << ")" << std::endl; - - while ( ! hackrf_is_streaming( _dev ) ); - // _thread = gruel::thread(_hackrf_wait, this); } @@ -191,7 +185,6 @@ hackrf_source_c::hackrf_source_c (const std::string &args) hackrf_source_c::~hackrf_source_c () { if (_dev) { - hackrf_stop_rx( _dev ); // _thread.join(); hackrf_close( _dev ); _dev = NULL; @@ -253,6 +246,38 @@ void hackrf_source_c::hackrf_wait() { } +bool hackrf_source_c::start() +{ + if ( ! _dev ) + return false; + + int ret = hackrf_start_rx( _dev, _hackrf_rx_callback, (void *)this ); + if (ret != HACKRF_SUCCESS) { + std::cerr << "Failed to start RX streaming (" << ret << ")" << std::endl; + return false; + } + + while ( ! hackrf_is_streaming( _dev ) ); + + return (bool) hackrf_is_streaming( _dev ); +} + +bool hackrf_source_c::stop() +{ + if ( ! _dev ) + return false; + + int ret = hackrf_stop_rx( _dev ); + if (ret != HACKRF_SUCCESS) { + std::cerr << "Failed to stop RX streaming (" << ret << ")" << std::endl; + return false; + } + + while ( hackrf_is_streaming( _dev ) ); + + return ! (bool) hackrf_is_streaming( _dev ); +} + int hackrf_source_c::work( int noutput_items, gr_vector_const_void_star &input_items, gr_vector_void_star &output_items ) |