wfview/include/audiohandlerpaoutput.h
Elliott Liggett a1ba965ef6 This should fix issues with "robotic" self-monitoring audio.
It should also make RT audio more usable. Most users will still find
there are specific audio back-ends that work better than others, so it
remains essential to try each of the three (Qt Audio, Port Audio, and RT
Audio).
2026-03-16 10:06:45 -07:00

41 lines
1.3 KiB
C++

#ifndef AUDIOHANDLERPAOUTPUT_H
#define AUDIOHANDLERPAOUTPUT_H
#include "audiohandlerbase.h"
#include <portaudio.h>
#include <memory>
#include "bytering.h"
class audioHandlerPaOutput : public audioHandlerBase {
Q_OBJECT
public:
explicit audioHandlerPaOutput(QObject* parent=nullptr);
~audioHandlerPaOutput() override { dispose(); } // ensure close on destruction
QString role() const override { return QStringLiteral("Output"); }
public slots:
void incomingAudio(audioPacket packet);
protected:
bool openDevice() noexcept override;
void closeDevice() noexcept override;
virtual QAudioFormat getNativeFormat() override ;
virtual bool isFormatSupported(QAudioFormat f) override;
private slots:
void onConverted(audioPacket pkt);
private:
static int paCallback(const void* input, void* output, unsigned long frameCount, const PaStreamCallbackTimeInfo*, PaStreamCallbackFlags statusFlags, void* user);
void handleCallbackOutput(void* output, unsigned long frameCount, PaStreamCallbackFlags statusFlags);
void prefillRingBuffer();
QElapsedTimer lastRecovery;
PaStream* stream=nullptr;
unsigned bytesPerSample{2};
unsigned bytesPerFrame{2};
std::unique_ptr<ByteRing> outRB;
};
#endif // AUDIOHANDLERPAOUTPUT_H