SDRAngel  4.11.5
Developer docs for <a href="https://github.com/f4exb/sdrangel">SDRangel<\a>, an Open Source Qt5 / OpenGL 3.0+ SDR and signal analyzer frontend to various hardware.
Public Member Functions | Public Attributes | Private Attributes | List of all members
leansdr::file_printer< T > Struct Template Reference

#include <generic.h>

+ Inheritance diagram for leansdr::file_printer< T >:
+ Collaboration diagram for leansdr::file_printer< T >:

Public Member Functions

 file_printer (scheduler *sch, const char *_format, pipebuf< T > &_in, int _fdout, int _decimation=1)
 
void run ()
 
- Public Member Functions inherited from leansdr::runnable
 runnable (scheduler *_sch, const char *name)
 
- Public Member Functions inherited from leansdr::runnable_common
 runnable_common (const char *_name)
 
virtual ~runnable_common ()
 
virtual void shutdown ()
 

Public Attributes

scale
 
int decimation
 
- Public Attributes inherited from leansdr::runnable_common
const char * name
 

Private Attributes

pipereader< T > in
 
const char * format
 
int fdout
 
int phase
 

Additional Inherited Members

- Protected Attributes inherited from leansdr::runnable
schedulersch
 

Detailed Description

template<typename T>
struct leansdr::file_printer< T >

Definition at line 149 of file generic.h.

Constructor & Destructor Documentation

◆ file_printer()

template<typename T >
leansdr::file_printer< T >::file_printer ( scheduler sch,
const char *  _format,
pipebuf< T > &  _in,
int  _fdout,
int  _decimation = 1 
)
inline

Definition at line 151 of file generic.h.

153  : runnable(sch, _in.name),
154  scale(1), decimation(_decimation),
155  in(_in), format(_format), fdout(_fdout), phase(0)
156  {
157  }
const char * format
Definition: generic.h:183
pipereader< T > in
Definition: generic.h:182
runnable(scheduler *_sch, const char *name)
Definition: framework.h:193
scheduler * sch
Definition: framework.h:199

Member Function Documentation

◆ run()

template<typename T >
void leansdr::file_printer< T >::run ( )
inlinevirtual

Reimplemented from leansdr::runnable_common.

Definition at line 158 of file generic.h.

References decimation(), and leansdr::fatal().

159  {
160  int n = in.readable();
161  T *pin = in.rd(), *pend = pin + n;
162  for (; pin < pend; ++pin)
163  {
164  if (++phase >= decimation)
165  {
166  phase -= decimation;
167  char buf[256];
168  int len = snprintf(buf, sizeof(buf), format, (*pin) * scale);
169  if (len < 0)
170  fatal("obsolete glibc");
171  int nw = write(fdout, buf, len);
172  if (nw != len)
173  fatal("partial write");
174  }
175  }
176  in.read(n);
177  }
const char * format
Definition: generic.h:183
pipereader< T > in
Definition: generic.h:182
void fatal(const char *s)
Definition: framework.cpp:6
+ Here is the call graph for this function:

Member Data Documentation

◆ decimation

template<typename T >
int leansdr::file_printer< T >::decimation

Definition at line 179 of file generic.h.

◆ fdout

template<typename T >
int leansdr::file_printer< T >::fdout
private

Definition at line 184 of file generic.h.

◆ format

template<typename T >
const char* leansdr::file_printer< T >::format
private

Definition at line 183 of file generic.h.

◆ in

template<typename T >
pipereader<T> leansdr::file_printer< T >::in
private

Definition at line 182 of file generic.h.

◆ phase

template<typename T >
int leansdr::file_printer< T >::phase
private

Definition at line 185 of file generic.h.

◆ scale

template<typename T >
T leansdr::file_printer< T >::scale

Definition at line 178 of file generic.h.


The documentation for this struct was generated from the following file: