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

Generic asynchronous JACK client. More...

Inheritance diagram for MHAJack::client_t:
Inheritance graph

Public Member Functions

 client_t (IOProcessEvent_t proc_event, void *proc_handle=NULL, IOStartedEvent_t start_event=NULL, void *start_handle=NULL, IOStoppedEvent_t stop_event=NULL, void *stop_handle=NULL, bool use_jack_transport=false)
 
void prepare (const std::string &client_name, const unsigned int &nchannels_in, const unsigned int &nchannels_out)
 Allocate buffers, activate JACK client and install internal ports. More...
 
void prepare (const std::string &server_name, const std::string &client_name, const unsigned int &nchannels_in, const unsigned int &nchannels_out)
 Allocate buffers, ports, and activates JACK client. More...
 
void release ()
 Remove JACK client and deallocate internal ports and buffers. More...
 
void start (bool fail_on_async_jack_error=true)
 
void stop ()
 
void connect_input (const std::vector< std::string > &)
 Connect the input ports when connection variable is accessed. More...
 
void connect_output (const std::vector< std::string > &)
 Connect the output ports when connection variable is accessed. More...
 
unsigned int get_fragsize () const
 
float get_srate () const
 
unsigned long get_xruns ()
 
unsigned long get_xruns_reset ()
 
std::string str_error (int err)
 
void get_ports (std::vector< std::string > &, unsigned long jack_flags)
 Get a list of Jack ports. More...
 
std::vector< std::string > get_my_input_ports ()
 
std::vector< std::string > get_my_output_ports ()
 
void set_input_portnames (const std::vector< std::string > &)
 
void set_output_portnames (const std::vector< std::string > &)
 
float get_cpu_load ()
 
void set_use_jack_transport (bool ut)
 
bool is_prepared () const
 

Protected Attributes

jack_client_t * jc
 

Private Member Functions

void prepare_impl (const char *server_name, const char *client_name, const unsigned int &nchannels_in, const unsigned int &nchannels_out)
 Allocate buffers, activate JACK client and allocates jack ports Registers the jack client with the given server and activates it. More...
 
void internal_start ()
 
void internal_stop ()
 
void stopped (int, int)
 
int jack_proc_cb (jack_nframes_t)
 This is the main processing callback. More...
 
int jack_xrun_cb ()
 

Static Private Member Functions

static int jack_proc_cb (jack_nframes_t, void *)
 
static int jack_xrun_cb (void *)
 

Private Attributes

unsigned long num_xruns
 
unsigned int fragsize
 
float samplerate
 
unsigned int nchannels_in
 
unsigned int nchannels_out
 
IOProcessEvent_t proc_event
 
void * proc_handle
 
IOStartedEvent_t start_event
 
void * start_handle
 
IOStoppedEvent_t stop_event
 
void * stop_handle
 
MHASignal::waveform_ts_in
 
mha_wave_ts_out
 
MHAJack::port_t ** inch
 
MHAJack::port_t ** outch
 
unsigned int flags
 
bool b_prepared
 
bool use_jack_transport
 
jack_transport_state_t jstate_prev
 
std::vector< std::string > input_portnames
 
std::vector< std::string > output_portnames
 
bool fail_on_async_jackerror
 

Detailed Description

Generic asynchronous JACK client.

Constructor & Destructor Documentation

◆ client_t()

MHAJack::client_t::client_t ( IOProcessEvent_t  proc_event,
void *  proc_handle = NULL,
IOStartedEvent_t  start_event = NULL,
void *  start_handle = NULL,
IOStoppedEvent_t  stop_event = NULL,
void *  stop_handle = NULL,
bool  use_jack_transport = false 
)

Member Function Documentation

◆ prepare() [1/2]

void MHAJack::client_t::prepare ( const std::string &  client_name,
const unsigned int &  nch_in,
const unsigned int &  nch_out 
)

Allocate buffers, activate JACK client and install internal ports.

Registers the jack client with the default jack server and activates it.

Parameters
client_nameName of this jack client
nch_inInput ports to register
nch_outOutput ports to register

◆ prepare() [2/2]

void MHAJack::client_t::prepare ( const std::string &  server_name,
const std::string &  client_name,
const unsigned int &  nch_in,
const unsigned int &  nch_out 
)

Allocate buffers, ports, and activates JACK client.

Registers the jack client with specified jack server and activates it.

Parameters
server_nameName of the jack server to register with
client_nameName of this jack client
nch_inInput ports to register
nch_outOutput ports to register

◆ release()

void MHAJack::client_t::release ( void  )

Remove JACK client and deallocate internal ports and buffers.

◆ start()

void MHAJack::client_t::start ( bool  fail_on_async_jack_error = true)

◆ stop()

void MHAJack::client_t::stop ( )

◆ connect_input()

void MHAJack::client_t::connect_input ( const std::vector< std::string > &  con)

Connect the input ports when connection variable is accessed.

◆ connect_output()

void MHAJack::client_t::connect_output ( const std::vector< std::string > &  con)

Connect the output ports when connection variable is accessed.

◆ get_fragsize()

unsigned int MHAJack::client_t::get_fragsize ( ) const
inline

◆ get_srate()

float MHAJack::client_t::get_srate ( ) const
inline

◆ get_xruns()

unsigned long MHAJack::client_t::get_xruns ( )
inline

◆ get_xruns_reset()

unsigned long MHAJack::client_t::get_xruns_reset ( )

◆ str_error()

std::string MHAJack::client_t::str_error ( int  err)

◆ get_ports()

void MHAJack::client_t::get_ports ( std::vector< std::string > &  res,
unsigned long  jack_flags 
)

Get a list of Jack ports.

Parameters
resResult string vector
jack_flagsJack port flags (JackPortInput etc.)

◆ get_my_input_ports()

std::vector< std::string > MHAJack::client_t::get_my_input_ports ( )

◆ get_my_output_ports()

std::vector< std::string > MHAJack::client_t::get_my_output_ports ( )

◆ set_input_portnames()

void MHAJack::client_t::set_input_portnames ( const std::vector< std::string > &  names)

◆ set_output_portnames()

void MHAJack::client_t::set_output_portnames ( const std::vector< std::string > &  names)

◆ get_cpu_load()

float MHAJack::client_t::get_cpu_load ( )

◆ set_use_jack_transport()

void MHAJack::client_t::set_use_jack_transport ( bool  ut)
inline

◆ is_prepared()

bool MHAJack::client_t::is_prepared ( ) const
inline

◆ prepare_impl()

void MHAJack::client_t::prepare_impl ( const char *  server_name,
const char *  client_name,
const unsigned int &  nch_in,
const unsigned int &  nch_out 
)
private

Allocate buffers, activate JACK client and allocates jack ports Registers the jack client with the given server and activates it.

Parameters
server_nameName of the jack server to register with
client_nameName of this jack client
nch_inInput ports to register
nch_outOutput ports to register

◆ internal_start()

void MHAJack::client_t::internal_start ( )
private

◆ internal_stop()

void MHAJack::client_t::internal_stop ( )
private

◆ stopped()

void MHAJack::client_t::stopped ( int  proc_err,
int  io_err 
)
private

◆ jack_proc_cb() [1/2]

int MHAJack::client_t::jack_proc_cb ( jack_nframes_t  n,
void *  h 
)
staticprivate

◆ jack_proc_cb() [2/2]

int MHAJack::client_t::jack_proc_cb ( jack_nframes_t  n)
private

This is the main processing callback.

Here happens double buffering and downsampling.

◆ jack_xrun_cb() [1/2]

int MHAJack::client_t::jack_xrun_cb ( void *  h)
staticprivate

◆ jack_xrun_cb() [2/2]

int MHAJack::client_t::jack_xrun_cb ( )
inlineprivate

Member Data Documentation

◆ num_xruns

unsigned long MHAJack::client_t::num_xruns
private

◆ fragsize

unsigned int MHAJack::client_t::fragsize
private

◆ samplerate

float MHAJack::client_t::samplerate
private

◆ nchannels_in

unsigned int MHAJack::client_t::nchannels_in
private

◆ nchannels_out

unsigned int MHAJack::client_t::nchannels_out
private

◆ proc_event

IOProcessEvent_t MHAJack::client_t::proc_event
private

◆ proc_handle

void* MHAJack::client_t::proc_handle
private

◆ start_event

IOStartedEvent_t MHAJack::client_t::start_event
private

◆ start_handle

void* MHAJack::client_t::start_handle
private

◆ stop_event

IOStoppedEvent_t MHAJack::client_t::stop_event
private

◆ stop_handle

void* MHAJack::client_t::stop_handle
private

◆ s_in

MHASignal::waveform_t* MHAJack::client_t::s_in
private

◆ s_out

mha_wave_t* MHAJack::client_t::s_out
private

◆ inch

MHAJack::port_t** MHAJack::client_t::inch
private

◆ outch

MHAJack::port_t** MHAJack::client_t::outch
private

◆ jc

jack_client_t* MHAJack::client_t::jc
protected

◆ flags

unsigned int MHAJack::client_t::flags
private

◆ b_prepared

bool MHAJack::client_t::b_prepared
private

◆ use_jack_transport

bool MHAJack::client_t::use_jack_transport
private

◆ jstate_prev

jack_transport_state_t MHAJack::client_t::jstate_prev
private

◆ input_portnames

std::vector<std::string> MHAJack::client_t::input_portnames
private

◆ output_portnames

std::vector<std::string> MHAJack::client_t::output_portnames
private

◆ fail_on_async_jackerror

bool MHAJack::client_t::fail_on_async_jackerror
private

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