forked from sdr/gr-osmosdr
file: expose seek function in public API
This commit is contained in:
parent
74b9211cdc
commit
24d54c369f
|
@ -63,6 +63,15 @@ public:
|
||||||
*/
|
*/
|
||||||
virtual size_t get_num_channels( void ) = 0;
|
virtual size_t get_num_channels( void ) = 0;
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* \brief seek file to \p seek_point relative to \p whence
|
||||||
|
*
|
||||||
|
* \param seek_point sample offset in file
|
||||||
|
* \param whence one of SEEK_SET, SEEK_CUR, SEEK_END (man fseek)
|
||||||
|
* \return true on success
|
||||||
|
*/
|
||||||
|
virtual bool seek( long seek_point, int whence, size_t chan = 0 ) = 0;
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
* Get the possible sample rates for the underlying radio hardware.
|
* Get the possible sample rates for the underlying radio hardware.
|
||||||
* \return a range of rates in Sps
|
* \return a range of rates in Sps
|
||||||
|
|
|
@ -26,7 +26,6 @@
|
||||||
#include <boost/format.hpp>
|
#include <boost/format.hpp>
|
||||||
|
|
||||||
#include <gr_io_signature.h>
|
#include <gr_io_signature.h>
|
||||||
#include <gr_file_source.h>
|
|
||||||
|
|
||||||
#include "file_source_c.h"
|
#include "file_source_c.h"
|
||||||
|
|
||||||
|
@ -78,17 +77,17 @@ file_source_c::file_source_c(const std::string &args) :
|
||||||
|
|
||||||
_file_rate = _rate;
|
_file_rate = _rate;
|
||||||
|
|
||||||
gr_file_source_sptr src = gr_make_file_source( sizeof(gr_complex),
|
_source = gr_make_file_source( sizeof(gr_complex),
|
||||||
filename.c_str(),
|
filename.c_str(),
|
||||||
repeat );
|
repeat );
|
||||||
|
|
||||||
_throttle = gr_make_throttle( sizeof(gr_complex), _file_rate );
|
_throttle = gr_make_throttle( sizeof(gr_complex), _file_rate );
|
||||||
|
|
||||||
if (throttle) {
|
if (throttle) {
|
||||||
connect( src, 0, _throttle, 0 );
|
connect( _source, 0, _throttle, 0 );
|
||||||
connect( _throttle, 0, self(), 0 );
|
connect( _throttle, 0, self(), 0 );
|
||||||
} else {
|
} else {
|
||||||
connect( src, 0, self(), 0 );
|
connect( _source, 0, self(), 0 );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -121,6 +120,11 @@ size_t file_source_c::get_num_channels( void )
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool file_source_c::seek( long seek_point, int whence , size_t chan )
|
||||||
|
{
|
||||||
|
return _source->seek( seek_point, whence );
|
||||||
|
}
|
||||||
|
|
||||||
osmosdr::meta_range_t file_source_c::get_sample_rates( void )
|
osmosdr::meta_range_t file_source_c::get_sample_rates( void )
|
||||||
{
|
{
|
||||||
osmosdr::meta_range_t range;
|
osmosdr::meta_range_t range;
|
||||||
|
|
|
@ -21,6 +21,7 @@
|
||||||
#define FILE_SOURCE_C_H
|
#define FILE_SOURCE_C_H
|
||||||
|
|
||||||
#include <gr_hier_block2.h>
|
#include <gr_hier_block2.h>
|
||||||
|
#include <gr_file_source.h>
|
||||||
#include <gr_throttle.h>
|
#include <gr_throttle.h>
|
||||||
|
|
||||||
#include "osmosdr_src_iface.h"
|
#include "osmosdr_src_iface.h"
|
||||||
|
@ -49,6 +50,8 @@ public:
|
||||||
|
|
||||||
size_t get_num_channels( void );
|
size_t get_num_channels( void );
|
||||||
|
|
||||||
|
bool seek( long seek_point, int whence, size_t chan );
|
||||||
|
|
||||||
osmosdr::meta_range_t get_sample_rates( void );
|
osmosdr::meta_range_t get_sample_rates( void );
|
||||||
double set_sample_rate( double rate );
|
double set_sample_rate( double rate );
|
||||||
double get_sample_rate( void );
|
double get_sample_rate( void );
|
||||||
|
@ -72,7 +75,9 @@ public:
|
||||||
std::string get_antenna( size_t chan = 0 );
|
std::string get_antenna( size_t chan = 0 );
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
gr_file_source_sptr _source;
|
||||||
gr_throttle::sptr _throttle;
|
gr_throttle::sptr _throttle;
|
||||||
|
|
||||||
double _file_rate;
|
double _file_rate;
|
||||||
double _freq, _rate;
|
double _freq, _rate;
|
||||||
};
|
};
|
||||||
|
|
|
@ -375,6 +375,17 @@ size_t osmosdr_source_c_impl::get_num_channels()
|
||||||
return channels;
|
return channels;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool source_impl::seek( long seek_point, int whence, size_t chan )
|
||||||
|
{
|
||||||
|
size_t channel = 0;
|
||||||
|
BOOST_FOREACH( source_iface *dev, _devs )
|
||||||
|
for (size_t dev_chan = 0; dev_chan < dev->get_num_channels(); dev_chan++)
|
||||||
|
if ( chan == channel++ )
|
||||||
|
return dev->seek( seek_point, whence, dev_chan );
|
||||||
|
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
#define NO_DEVICES_MSG "FATAL: No device(s) available to work with."
|
#define NO_DEVICES_MSG "FATAL: No device(s) available to work with."
|
||||||
|
|
||||||
osmosdr::meta_range_t osmosdr_source_c_impl::get_sample_rates()
|
osmosdr::meta_range_t osmosdr_source_c_impl::get_sample_rates()
|
||||||
|
|
|
@ -36,6 +36,8 @@ class osmosdr_source_c_impl : public osmosdr_source_c
|
||||||
public:
|
public:
|
||||||
size_t get_num_channels( void );
|
size_t get_num_channels( void );
|
||||||
|
|
||||||
|
bool seek( long seek_point, int whence, size_t chan );
|
||||||
|
|
||||||
osmosdr::meta_range_t get_sample_rates( void );
|
osmosdr::meta_range_t get_sample_rates( void );
|
||||||
double set_sample_rate( double rate );
|
double set_sample_rate( double rate );
|
||||||
double get_sample_rate( void );
|
double get_sample_rate( void );
|
||||||
|
|
|
@ -41,6 +41,15 @@ public:
|
||||||
*/
|
*/
|
||||||
virtual size_t get_num_channels( void ) = 0;
|
virtual size_t get_num_channels( void ) = 0;
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* \brief seek file to \p seek_point relative to \p whence
|
||||||
|
*
|
||||||
|
* \param seek_point sample offset in file
|
||||||
|
* \param whence one of SEEK_SET, SEEK_CUR, SEEK_END (man fseek)
|
||||||
|
* \return true on success
|
||||||
|
*/
|
||||||
|
virtual bool seek( long seek_point, int whence, size_t chan = 0 ) { return false; }
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
* Get the possible sample rates for the underlying radio hardware.
|
* Get the possible sample rates for the underlying radio hardware.
|
||||||
* \return a range of rates in Sps
|
* \return a range of rates in Sps
|
||||||
|
|
Loading…
Reference in New Issue