LASP 1.0
Library for Acoustic Signal Processing
Loading...
Searching...
No Matches
PyIndataHandler Class Reference

Wraps the ThreadedInDataHandler such that it calls a Python callback with a buffer of sample data. Converts DaqData objects to Numpy arrays and calls Python given as argument to the constructor. More...

Inheritance diagram for PyIndataHandler:
Collaboration diagram for PyIndataHandler:

Public Member Functions

 PyIndataHandler (SmgrHandle mgr, py::function cb, py::function reset_callback)
 Initialize PyIndataHandler.
 
 ~PyIndataHandler ()
 
void reset (const Daq *daq)
 Calls the reset callback in Python.
 
void inCallback (const DaqData &d)
 Calls the Python callback method / function with a Numpy array of stream data.
 
- Public Member Functions inherited from ThreadedInDataHandler< PyIndataHandler >
 ThreadedInDataHandler (SmgrHandle mgr)
 
void _reset (const Daq *daq)
 
void _inCallback (const DaqData &data)
 
- Public Member Functions inherited from ThreadedInDataHandlerBase
 ThreadedInDataHandlerBase (SmgrHandle mgr, InCallbackType cb, InResetType reset)
 
 ~ThreadedInDataHandlerBase ()
 
void startThread ()
 This method should be called from the derived class' constructor, to start the thread and data is incoming.
 
void stopThread ()
 This method SHOULD be called from all classes that derive on ThreadedInDataHandler. It is to make sure the inCallback_threaded() function is no longer called when the destructor of the derived class is called. Not calling this function is regarded as a BUG.
 

Detailed Description

Wraps the ThreadedInDataHandler such that it calls a Python callback with a buffer of sample data. Converts DaqData objects to Numpy arrays and calls Python given as argument to the constructor.

Definition at line 103 of file lasp_pyindatahandler.cpp.

Constructor & Destructor Documentation

◆ PyIndataHandler()

PyIndataHandler::PyIndataHandler ( SmgrHandle  mgr,
py::function  cb,
py::function  reset_callback 
)
inline

Initialize PyIndataHandler.

Parameters
mgrStreamMgr handle
cbPython callback that is called with Numpy input data from device
reset_callbackPython callback that is called with a Daq pointer. Careful: do not store this handle, as it is only valid as long as reset() is called, when a stream stops, this pointer / handle will dangle.

Start should be called externally, as at constructor time no virtual functions should be called.

Definition at line 119 of file lasp_pyindatahandler.cpp.

◆ ~PyIndataHandler()

PyIndataHandler::~PyIndataHandler ( )
inline

Callback cannot be called, which results in a deadlock on the GIL without this release.

Definition at line 128 of file lasp_pyindatahandler.cpp.

Member Function Documentation

◆ inCallback()

void PyIndataHandler::inCallback ( const DaqData d)
inline

Calls the Python callback method / function with a Numpy array of stream data.

Definition at line 167 of file lasp_pyindatahandler.cpp.

◆ reset()

void PyIndataHandler::reset ( const Daq daq)
inline

Calls the reset callback in Python.

Parameters
daqDaq device, or nullptr in case no input stream is running.

Throwing a runtime error here does not work out one way or another. Therefore, it is better to dive out and prevent undefined behaviour

Definition at line 140 of file lasp_pyindatahandler.cpp.


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