![]() |
The Open Master Hearing Aid (openMHA)
openMHA
Open community platform for hearing aid algorithm research
|

Public Member Functions | |
| acwriter_t (bool active, unsigned fifosize, unsigned minwrite, const std::string &varname, double sampling_rate, output_file_t *outfile, uint32_t stream_id) | |
| Constructor allocates fifo and disk output buffer. More... | |
| acwriter_t (const acwriter_t &)=delete | |
| acwriter_t (acwriter_t &&)=delete | |
| virtual | ~acwriter_t ()=default |
| Deallocates memory but does not terminate the write_thread. More... | |
| void | process (comm_var_t &s) override |
| void | exit_request () override |
| Terminate output thread. More... | |
| const char * | get_varname () const override |
Public Member Functions inherited from ac2xdf::acwriter_base_t | |
| virtual | ~acwriter_base_t ()=default |
Private Member Functions | |
| void | write_thread () |
| Main method of the disk writer thread. More... | |
Private Attributes | |
| std::atomic< bool > | close_session |
| cross-thread-synchronization. More... | |
| const bool | active |
| The writer thread and the output file will only be created when active is true. More... | |
| std::unique_ptr< mha_fifo_lf_t< T > > | fifo |
| Fifo for decoupling signal processing thread from disk writer thread. More... | |
| const unsigned int | disk_write_threshold_min_num_samples |
| Minimum number of samples that need to be waiting in the fifo before the disk writer thread writes them to disk. More... | |
| std::thread | writethread |
| The thread that writes to disk. More... | |
| std::unique_ptr< T[]> | diskbuffer |
| Intermediate buffer to receive data from fifo and store on disk. More... | |
| output_file_t * | outfile |
| Ouput file. More... | |
| unsigned | num_channels = 0U |
| Number of channels of AC variable using stride. More... | |
| bool | is_num_channels_known = false |
| The number of channels is determined during the first process callback. More... | |
| bool | is_complex = false |
| If the AC variable is of complex valued type or not. More... | |
| unsigned int | data_type = MHA_AC_UNKNOWN |
| Data type of the ac variable. Used to protect against data type change during processing. More... | |
| const std::string | varname |
| The name of the ac variable to publish. More... | |
| const uint32_t | stream_id |
| bool | is_stream_initialized =false |
| double | sampling_rate |
| ac2xdf::acwriter_t< T >::acwriter_t | ( | bool | active, |
| unsigned | fifosize, | ||
| unsigned | minwrite, | ||
| const std::string & | varname, | ||
| double | sampling_rate, | ||
| output_file_t * | outfile, | ||
| uint32_t | stream_id | ||
| ) |
Constructor allocates fifo and disk output buffer.
It spawns a new thread for writing data to disk when active==true. In order to terminate the thread, method exit_request must be called before this object is destroyed.
| active | Only write data to disk when this is true. |
| fifosize | Capacity of both the fifo pipeline and of the disk buffer. |
| minwrite | Wait for a fifo fill count of at least minwrite doubles before flushing the contents of the fifo to disk. Fifo is also flushed before this object is destroyed. |
| varname | Name of AC variable to save into file. Can be accessed through getter method get_varname(). Stored here to avoid races between processing thread and configuration thread. |
| outfile | Handle to the output file |
| stream_id | Numerical id of the stream. |
|
delete |
|
delete |
|
virtualdefault |
Deallocates memory but does not terminate the write_thread.
write_thread must be terminated before the destructor executes by calling exit_request.
|
overridevirtual |
Implements ac2xdf::acwriter_base_t.
|
overridevirtual |
Terminate output thread.
Implements ac2xdf::acwriter_base_t.
|
inlineoverridevirtual |
Implements ac2xdf::acwriter_base_t.
|
private |
Main method of the disk writer thread.
Periodically wakes up and checks if data needs to be written to disk.
|
private |
cross-thread-synchronization.
write_thread() terminates after this is set to true by exit_request().
|
private |
The writer thread and the output file will only be created when active is true.
|
private |
Fifo for decoupling signal processing thread from disk writer thread.
|
private |
Minimum number of samples that need to be waiting in the fifo before the disk writer thread writes them to disk.
|
private |
The thread that writes to disk.
|
private |
Intermediate buffer to receive data from fifo and store on disk.
|
private |
Ouput file.
|
private |
Number of channels of AC variable using stride.
If the number of channels changes during processing, an exception is thrown.
|
private |
The number of channels is determined during the first process callback.
is_num_channels_known is set to true after the first process callback.
|
private |
If the AC variable is of complex valued type or not.
If this changes during processing, then an exception is thrown.
|
private |
Data type of the ac variable. Used to protect against data type change during processing.
|
private |
The name of the ac variable to publish.
|
private |
|
private |
|
private |