SpeakerAudioDriver class for handling audio output to a speaker.
More...
#include <speaker_audio_driver.hpp>
|
| static int | pa_output_callback (const void *input_buffer, void *output_buffer, unsigned long frames_per_buffer, const PaStreamCallbackTimeInfo *time_info, PaStreamCallbackFlags status_flags, void *user_data) |
| |
| static std::vector< int16_t > | resample_linear_interleaved (const std::vector< int16_t > &input, int channels, int input_rate, int output_rate) |
| |
SpeakerAudioDriver class for handling audio output to a speaker.
This class is responsible for managing the audio output to a speaker using PortAudio. It provides methods to start and stop the audio stream, as well as play audio data.
◆ SpeakerAudioDriver()
| fp_perception::SpeakerAudioDriver::SpeakerAudioDriver |
( |
| ) |
|
|
inline |
Constructor for SpeakerAudioDriver.
Initializes the PortAudio library and prepares the audio stream.
◆ ~SpeakerAudioDriver()
| fp_perception::SpeakerAudioDriver::~SpeakerAudioDriver |
( |
| ) |
|
|
inlineoverride |
Destructor for SpeakerAudioDriver.
Stops the audio stream and terminates the PortAudio library.
◆ deinitialize()
| void fp_perception::SpeakerAudioDriver::deinitialize |
( |
| ) |
|
|
inlineoverridevirtual |
Stop driver streaming. This function stops the audio stream and closes it. It also terminates the PortAudio library.
Implements fp_perception::DriverBase.
◆ enqueuePlayback()
| void fp_perception::SpeakerAudioDriver::enqueuePlayback |
( |
const audio_data & |
input_data | ) |
|
|
inlineoverridevirtual |
◆ fill_output_buffer()
| int fp_perception::SpeakerAudioDriver::fill_output_buffer |
( |
void * |
output_buffer, |
|
|
unsigned long |
frames_per_buffer, |
|
|
PaStreamCallbackFlags |
status_flags |
|
) |
| |
|
inlineprotected |
◆ initialize()
| void fp_perception::SpeakerAudioDriver::initialize |
( |
const rclcpp::Node::SharedPtr & |
node | ) |
|
|
inlineoverridevirtual |
Initialize the driver.
This function should be overridden in derived classes to provide specific initialization.
- Parameters
-
| node | Shared pointer to the ROS node |
Reimplemented from fp_perception::DriverBase.
◆ pa_output_callback()
| static int fp_perception::SpeakerAudioDriver::pa_output_callback |
( |
const void * |
input_buffer, |
|
|
void * |
output_buffer, |
|
|
unsigned long |
frames_per_buffer, |
|
|
const PaStreamCallbackTimeInfo * |
time_info, |
|
|
PaStreamCallbackFlags |
status_flags, |
|
|
void * |
user_data |
|
) |
| |
|
inlinestaticprotected |
◆ play()
| void fp_perception::SpeakerAudioDriver::play |
( |
const audio_data & |
input_data | ) |
|
|
inlineoverridevirtual |
Set the latest audio data to the driver. This function sends the latest audio data to the speaker driver.
- Parameters
-
| input | The latest audio data to the driver in the form of const std::vector<std::vector<int16_t>>&. |
- Exceptions
-
Implements fp_perception::AudioSinkDriver.
◆ play_internal()
| void fp_perception::SpeakerAudioDriver::play_internal |
( |
const audio_data & |
input_data, |
|
|
bool |
wait_for_drain |
|
) |
| |
|
inline |
◆ produce_diagnostics()
| void fp_perception::SpeakerAudioDriver::produce_diagnostics |
( |
diagnostic_updater::DiagnosticStatusWrapper & |
status | ) |
|
|
inlineprotected |
◆ queue_data()
| void fp_perception::SpeakerAudioDriver::queue_data |
( |
audio_data |
input_data, |
|
|
const std::string & |
stream_key, |
|
|
bool |
wait_for_drain |
|
) |
| |
|
inlineprotected |
◆ resample_linear_interleaved()
| static std::vector< int16_t > fp_perception::SpeakerAudioDriver::resample_linear_interleaved |
( |
const std::vector< int16_t > & |
input, |
|
|
int |
channels, |
|
|
int |
input_rate, |
|
|
int |
output_rate |
|
) |
| |
|
inlinestaticprotected |
◆ setup_diagnostics()
| void fp_perception::SpeakerAudioDriver::setup_diagnostics |
( |
| ) |
|
|
inlineprotected |
◆ stopPlayback()
| void fp_perception::SpeakerAudioDriver::stopPlayback |
( |
| ) |
|
|
inlineoverridevirtual |
◆ test()
| void fp_perception::SpeakerAudioDriver::test |
( |
| ) |
|
|
inlineoverridevirtual |
◆ wait_for_playback_drain()
| void fp_perception::SpeakerAudioDriver::wait_for_playback_drain |
( |
| ) |
|
|
inlineprotected |
◆ callback_lock_miss_count_
| std::atomic<uint64_t> fp_perception::SpeakerAudioDriver::callback_lock_miss_count_ { 0 } |
|
protected |
◆ channels_
| int fp_perception::SpeakerAudioDriver::channels_ |
|
protected |
◆ device_id_
| int fp_perception::SpeakerAudioDriver::device_id_ |
|
protected |
◆ device_name_
| std::string fp_perception::SpeakerAudioDriver::device_name_ |
|
protected |
◆ err
| PaError fp_perception::SpeakerAudioDriver::err = paNoError |
|
protected |
◆ playback_cv_
| std::condition_variable fp_perception::SpeakerAudioDriver::playback_cv_ |
|
protected |
◆ playback_mutex_
| std::mutex fp_perception::SpeakerAudioDriver::playback_mutex_ |
|
protected |
◆ playback_queue_
| std::deque<int16_t> fp_perception::SpeakerAudioDriver::playback_queue_ |
|
protected |
◆ sample_rate_
| int fp_perception::SpeakerAudioDriver::sample_rate_ |
|
protected |
◆ stream_dict_
| std::map<std::string, PaStream*> fp_perception::SpeakerAudioDriver::stream_dict_ |
|
protected |
◆ test_file_path_
| std::string fp_perception::SpeakerAudioDriver::test_file_path_ |
|
protected |
◆ underrun_count_
| std::atomic<uint64_t> fp_perception::SpeakerAudioDriver::underrun_count_ { 0 } |
|
protected |
The documentation for this class was generated from the following file: