66 unsigned long frames_per_buffer,
67 const PaStreamCallbackTimeInfo* time_info,
68 PaStreamCallbackFlags status_flags,
96 std::cerr <<
"PortAudio error: " << Pa_GetErrorText(
_pa_error ) << std::endl;
100 PaSampleFormat format;
101 if constexpr (std::is_same_v<T, int16_t>)
103 else if constexpr (std::is_same_v<T, float>)
123 std::cerr <<
"PortAudio error: " << Pa_GetErrorText(
_pa_error ) << std::endl;
132 std::cerr <<
"PortAudio error: " << Pa_GetErrorText(
_pa_error ) << std::endl;
138 std::cerr <<
"PortAudio error: " << Pa_GetErrorText(
_pa_error ) << std::endl;
149 std::cerr <<
"PortAudio error: " << Pa_GetErrorText(
_pa_error ) << std::endl;
158 std::cerr <<
"PortAudio error: " << Pa_GetErrorText(
_pa_error ) << std::endl;
167 std::cerr <<
"PortAudio error: " << Pa_GetErrorText(
_pa_error ) << std::endl;
173 std::cerr <<
"PortAudio error: " << Pa_GetErrorText(
_pa_error ) << std::endl;
182 return Pa_GetDefaultOutputDevice() == 0;
188 unsigned long frames_per_buffer,
189 const PaStreamCallbackTimeInfo* time_info,
190 PaStreamCallbackFlags status_flags,
192 T* out = (T*)output_buffer;
197 for( i=0; i<frames_per_buffer; i++ )
Abstracts PortAudio using a given audio sample data type.
static void start()
Starts the invokation of the PortAudio callback.
static PaStream * _pa_stream
The PortAudio stream.
static void init()
Initializes PortAudio.
static AudioOutput * _instance
The global AudioOutput instance.
static constexpr int SAMPLE_RATE
The AudioOutput sample rate, which is matched to the sample rate of CD audio.
static bool isDefault()
Returns whether the default audio output device is used. This indicates that a Bluetooth device is no...
static PaError _pa_error
The most recent PortAudio error.
static int pa_callback(const void *input_buffer, void *output_buffer, unsigned long frames_per_buffer, const PaStreamCallbackTimeInfo *time_info, PaStreamCallbackFlags status_flags, void *user_data)
The PortAudio callback.
static void destroy()
Tears down PortAudio.
static void restart()
Restarts PortAudio.
static AudioOutput * instance()
Factory method to return the AudioOutput. It may be called one or more times. Be sure to destroy() th...
static void stop()
Stops the invokation of the PortAudio callback.
Consumer()
Consumer constructor.