Decouple QAudioDevice buffer size from AFV 20 ms frame size

Different QAudioDevice plugins have different default buffer sizes. In 
order to cope with bigger buffer sizes than the expected 20 ms,
let the buffer be filled and push from it every 20 ms via timer.
This commit is contained in:
Roland Rossgotterer
2019-09-20 21:17:26 +02:00
committed by Mat Sutcliffe
parent 1deaf1ca8b
commit cf6d60348e
2 changed files with 28 additions and 13 deletions

View File

@@ -32,7 +32,7 @@ namespace BlackCore
Q_OBJECT
public:
AudioInputBuffer() {}
AudioInputBuffer(QObject *parent = nullptr);
void start();
void stop();
@@ -43,9 +43,13 @@ namespace BlackCore
signals:
void frameAvailable(const QByteArray &frame);
protected:
void timerEvent(QTimerEvent *event) override;
private:
static constexpr qint64 frameSize = 960;
QByteArray m_buffer;
int m_timerId = 0;
};
struct OpusDataAvailableArgs
@@ -97,7 +101,7 @@ namespace BlackCore
int m_opusBytesEncoded = 0;
double m_volume = 1.0;
int m_sampleCount = 0;
qint16 m_maxSampleInput = 0;
qint16 m_maxSampleInput = 0.0;
const int c_sampleCountPerEvent = 4800;
const float maxDb = 0;