Zrythm v2.0.0-DEV
a highly automated and intuitive digital audio workstation
Loading...
Searching...
No Matches
zrythm::test_helpers::ThreadedMockHardwareAudioInterface Class Reference

Threaded mock hardware audio interface for integration tests. More...

#include <tests/helpers/mock_hardware_audio_interface_threaded.h>

Inheritance diagram for zrythm::test_helpers::ThreadedMockHardwareAudioInterface:
Collaboration diagram for zrythm::test_helpers::ThreadedMockHardwareAudioInterface:

Public Member Functions

 ThreadedMockHardwareAudioInterface (units::sample_rate_t sample_rate=units::sample_rate(48000), nframes_t block_length=256)
nframes_t get_block_length () const override
 Returns the current block length (buffer size) in frames.
units::sample_rate_t get_sample_rate () const override
 Returns the current sample rate.
std::size_t process_call_count () const
 Returns the number of times process_audio has been called.
void add_audio_callback (dsp::IAudioCallback *callback) override
 Adds an audio callback to receive audio I/O events.
void remove_audio_callback (dsp::IAudioCallback *callback) override
 Removes a previously added audio callback.

Detailed Description

Threaded mock hardware audio interface for integration tests.

Runs audio callbacks in a background thread to simulate real audio device behavior, required for tests that need to process audio asynchronously.

Definition at line 22 of file mock_hardware_audio_interface_threaded.h.

Constructor & Destructor Documentation

◆ ThreadedMockHardwareAudioInterface()

zrythm::test_helpers::ThreadedMockHardwareAudioInterface::ThreadedMockHardwareAudioInterface ( units::sample_rate_t sample_rate = units::sample_rate (48000),
nframes_t block_length = 256 )
inlineexplicit

Definition at line 25 of file mock_hardware_audio_interface_threaded.h.

◆ ~ThreadedMockHardwareAudioInterface()

zrythm::test_helpers::ThreadedMockHardwareAudioInterface::~ThreadedMockHardwareAudioInterface ( )
inlineoverride

Definition at line 32 of file mock_hardware_audio_interface_threaded.h.

Member Function Documentation

◆ add_audio_callback()

void zrythm::test_helpers::ThreadedMockHardwareAudioInterface::add_audio_callback ( dsp::IAudioCallback * callback)
inlineoverridevirtual

Adds an audio callback to receive audio I/O events.

The caller must ensure callback remains alive until after remove_audio_callback() is called with the same pointer.

Implements zrythm::dsp::IHardwareAudioInterface.

Definition at line 54 of file mock_hardware_audio_interface_threaded.h.

◆ get_block_length()

nframes_t zrythm::test_helpers::ThreadedMockHardwareAudioInterface::get_block_length ( ) const
inlinenodiscardoverridevirtual

Returns the current block length (buffer size) in frames.

Implements zrythm::dsp::IHardwareAudioInterface.

Definition at line 34 of file mock_hardware_audio_interface_threaded.h.

◆ get_sample_rate()

units::sample_rate_t zrythm::test_helpers::ThreadedMockHardwareAudioInterface::get_sample_rate ( ) const
inlinenodiscardoverridevirtual

Returns the current sample rate.

Implements zrythm::dsp::IHardwareAudioInterface.

Definition at line 38 of file mock_hardware_audio_interface_threaded.h.

◆ process_call_count()

std::size_t zrythm::test_helpers::ThreadedMockHardwareAudioInterface::process_call_count ( ) const
inlinenodiscard

Returns the number of times process_audio has been called.

Thread-safe: can be called from any thread (e.g., the test main thread) while the audio callback thread is running.

Definition at line 49 of file mock_hardware_audio_interface_threaded.h.

◆ remove_audio_callback()

void zrythm::test_helpers::ThreadedMockHardwareAudioInterface::remove_audio_callback ( dsp::IAudioCallback * callback)
inlineoverridevirtual

Removes a previously added audio callback.

callback must be the same pointer passed to add_audio_callback().

Implements zrythm::dsp::IHardwareAudioInterface.

Definition at line 105 of file mock_hardware_audio_interface_threaded.h.


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