The Open Master Hearing Aid (openMHA)  openMHA
Open community platform for hearing aid algorithm research
io_alsa_t Class Reference

MHA IO interface class for ALSA IO. More...

Inheritance diagram for io_alsa_t:
Inheritance graph

Public Member Functions

 io_alsa_t (unsigned int fragsize, float samplerate, IOProcessEvent_t proc_event, void *proc_handle, IOStartedEvent_t start_event, void *start_handle, IOStoppedEvent_t stop_event, void *stop_handle)
 Constructor, receives the callback handles to interact with the MHA framework. More...
 
template<typename T = void>
void prepare (int, int)
 Called after the framework has perpared the processing plugins and the number of input and output channels are fixed. More...
 
void release ()
 MHA framework leaves prepared state. More...
 
void start ()
 MHA framework calls this function when signal processing should start. More...
 
void stop ()
 MHA framework calls this function when signal processing should stop. More...
 
template<>
void prepare (int nch_in, int nch_out)
 
- Public Member Functions inherited from MHAParser::parser_t
 parser_t (const std::string &help_text="")
 Construct detached node to be used in the configuration tree. More...
 
 ~parser_t ()
 
void insert_item (const std::string &, base_t *)
 Register a parser item into this sub-parser. More...
 
void remove_item (const std::string &)
 Remove an item by name. More...
 
void force_remove_item (const std::string &)
 Remove an item by name. More...
 
void remove_item (const base_t *)
 Remove an item by address. More...
 
- Public Member Functions inherited from MHAParser::base_t
 base_t (const std::string &)
 Constructor for base class of all parser nodes. More...
 
 base_t (const base_t &)
 Copy constructor for base_t. More...
 
base_toperator= (const base_t &)=default
 
 base_t (base_t &&)=delete
 
base_toperator= (base_t &&)=delete
 
virtual ~base_t ()
 
virtual std::string parse (const std::string &)
 Causes this node to process a command in the openMHA configuration language. More...
 
virtual void parse (const char *, char *, unsigned int)
 This function parses a command and writes the parsing result into a C character array. More...
 
virtual void parse (const std::vector< std::string > &, std::vector< std::string > &)
 
virtual std::string query_perm (const std::string &)
 
virtual std::string query_range (const std::string &)
 
std::string query_version (const std::string &)
 
std::string query_id (const std::string &)
 
std::string query_subst (const std::string &)
 
std::string query_addsubst (const std::string &)
 
std::string query_help (const std::string &)
 
std::string query_cmds (const std::string &)
 
void set_node_id (const std::string &)
 Set the identification string of this parser node. More...
 
void set_help (const std::string &)
 Set the help comment of a variable or parser. More...
 
void add_parent_on_insert (parser_t *, std::string)
 
void rm_parent_on_remove (parser_t *)
 
const std::string & fullname () const
 Return the full dot-separated path name of this parser node in the openMHA configuration tree. More...
 

Static Public Member Functions

static void * thread_start (void *h)
 MHAIOAlsa uses a separate thread that calls the alsa read and write functions to read and write audio samples, these functions are blocking until samples can be read or written. More...
 

Private Member Functions

void process ()
 

Private Attributes

bool b_process
 
unsigned int fw_fragsize
 
unsigned int fw_samplerate
 
IOProcessEvent_t proc_event
 
void * proc_handle
 
IOStartedEvent_t start_event
 
void * start_handle
 
IOStoppedEvent_t stop_event
 
void * stop_handle
 
alsa_base_tdev_in
 
alsa_base_tdev_out
 
pthread_t proc_thread
 
alsa_dev_par_parser_t p_in
 
alsa_dev_par_parser_t p_out
 
MHAParser::bool_t pcmlink
 
MHAParser::int_t priority
 
MHAParser::kw_t format
 
MHAParser::int_mon_t alsa_start_counter
 
MHAEvents::patchbay_t< io_alsa_tpatchbay
 

Additional Inherited Members

- Public Attributes inherited from MHAParser::base_t
MHAEvents::emitter_t writeaccess
 Event emitted on write access. More...
 
MHAEvents::emitter_t valuechanged
 Event emitted if the value has changed. More...
 
MHAEvents::emitter_t readaccess
 Event emitted on read access. More...
 
MHAEvents::emitter_t prereadaccess
 Event emitted on read access, before the data field is accessed. More...
 
- Protected Member Functions inherited from MHAParser::parser_t
std::string op_subparse (expression_t &)
 
std::string op_setval (expression_t &)
 
std::string op_query (expression_t &)
 
std::string query_type (const std::string &)
 
std::string query_dump (const std::string &)
 
std::string query_entries (const std::string &)
 
std::string query_readfile (const std::string &)
 
std::string query_savefile (const std::string &)
 
std::string query_savefile_compact (const std::string &)
 
std::string query_savemons (const std::string &)
 
std::string query_val (const std::string &)
 
std::string query_listids (const std::string &)
 
void set_id_string (const std::string &)
 
bool has_entry (const std::string &)
 
- Protected Member Functions inherited from MHAParser::base_t
void activate_query (const std::string &, query_t)
 
void notify ()
 
- Protected Attributes inherited from MHAParser::base_t
query_map_t queries
 
bool data_is_initialized
 

Detailed Description

MHA IO interface class for ALSA IO.

Constructor & Destructor Documentation

◆ io_alsa_t()

io_alsa_t::io_alsa_t ( unsigned int  fragsize,
float  samplerate,
IOProcessEvent_t  proc_event,
void *  proc_handle,
IOStartedEvent_t  start_event,
void *  start_handle,
IOStoppedEvent_t  stop_event,
void *  stop_handle 
)

Constructor, receives the callback handles to interact with the MHA framework.

Member Function Documentation

◆ prepare() [1/2]

template<typename T >
void io_alsa_t::prepare ( int  nch_in,
int  nch_out 
)

Called after the framework has perpared the processing plugins and the number of input and output channels are fixed.

open pcm streams

◆ release()

void io_alsa_t::release ( void  )

MHA framework leaves prepared state.

◆ start()

void io_alsa_t::start ( )

MHA framework calls this function when signal processing should start.

◆ stop()

void io_alsa_t::stop ( )

MHA framework calls this function when signal processing should stop.

◆ thread_start()

void * io_alsa_t::thread_start ( void *  h)
static

MHAIOAlsa uses a separate thread that calls the alsa read and write functions to read and write audio samples, these functions are blocking until samples can be read or written.

This is the start function of that thread.

◆ process()

void io_alsa_t::process ( void  )
private

◆ prepare() [2/2]

template<>
void io_alsa_t::prepare ( int  nch_in,
int  nch_out 
)

Member Data Documentation

◆ b_process

bool io_alsa_t::b_process
private

◆ fw_fragsize

unsigned int io_alsa_t::fw_fragsize
private

◆ fw_samplerate

unsigned int io_alsa_t::fw_samplerate
private

◆ proc_event

IOProcessEvent_t io_alsa_t::proc_event
private

◆ proc_handle

void* io_alsa_t::proc_handle
private

◆ start_event

IOStartedEvent_t io_alsa_t::start_event
private

◆ start_handle

void* io_alsa_t::start_handle
private

◆ stop_event

IOStoppedEvent_t io_alsa_t::stop_event
private

◆ stop_handle

void* io_alsa_t::stop_handle
private

◆ dev_in

alsa_base_t* io_alsa_t::dev_in
private

◆ dev_out

alsa_base_t* io_alsa_t::dev_out
private

◆ proc_thread

pthread_t io_alsa_t::proc_thread
private

◆ p_in

alsa_dev_par_parser_t io_alsa_t::p_in
private

◆ p_out

alsa_dev_par_parser_t io_alsa_t::p_out
private

◆ pcmlink

MHAParser::bool_t io_alsa_t::pcmlink
private

◆ priority

MHAParser::int_t io_alsa_t::priority
private

◆ format

MHAParser::kw_t io_alsa_t::format
private

◆ alsa_start_counter

MHAParser::int_mon_t io_alsa_t::alsa_start_counter
private

◆ patchbay

MHAEvents::patchbay_t<io_alsa_t> io_alsa_t::patchbay
private

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