mirror of
https://github.com/wf-group/wfview
synced 2026-08-13 17:32:59 -04:00
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).
41 lines
1.3 KiB
C++
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
|