Lower latency without the conversion. Added needed thread destructor to

pa handler.
monitor
Elliott Liggett 2022-08-29 14:33:30 -07:00
rodzic 01afca7ca7
commit 49c423a7fb
3 zmienionych plików z 24 dodań i 4 usunięć

Wyświetl plik

@ -16,8 +16,7 @@ audioHandler::audioHandler(QObject* parent) : QObject(parent)
}
audioHandler::~audioHandler()
{
{
if (converterThread != Q_NULLPTR) {
converterThread->quit();
converterThread->wait();

Wyświetl plik

@ -13,7 +13,7 @@
#include <eigen3/Eigen/Eigen>
#endif
#define audioMonitorBufferSize (10)
#define audioMonitorBufferSize (8)
struct sharedAudioType

Wyświetl plik

@ -15,6 +15,12 @@ paHandler::paHandler(QObject* parent)
paHandler::~paHandler()
{
if (converterToMonitorThread != Q_NULLPTR)
{
converterToMonitorThread->quit();
converterToMonitorThread->wait();
}
if (converterThread != Q_NULLPTR) {
converterThread->quit();
converterThread->wait();
@ -255,7 +261,12 @@ void paHandler::incomingAudio(audioPacket packet)
{
// Try sending directly to the hardware:
//convertedOutput(packet);
emit sendToMonitorConverter(packet);
// Convert:
//emit sendToMonitorConverter(packet);
// if the formats are actually the same, no need to convert:
convertedMonitorAudio(packet);
}
return;
}
@ -312,6 +323,16 @@ void paHandler::convertedOutput(audioPacket packet) {
//int readPos = sharedAudioInfo->bufferReadPosition;
int readPos = (monitorBufferPosition++)%audioMonitorBufferSize;
/*
if( (readPos+2)%audioMonitorBufferSize == sharedAudioInfo->bufferWritePosition)
{
// then we are too close, let's step back
qDebug(logAudio()) << "Warning, monitor buffer read is too close, moving back. Write position: " << sharedAudioInfo->bufferWritePosition << ", read position: " << readPos;
monitorBufferPosition = (sharedAudioInfo->bufferWritePosition-3)%audioMonitorBufferSize;
readPos = monitorBufferPosition;
}
*/
// if(packet.data.size() != sharedAudioInfo->monitorAudioBuffer[readPos].data.size())
// {
// qDebug(logAudio()) << "ERROR, size mismatch. packet is " << packet.data.size() << "bytes, monitor audio is " << sharedAudioInfo->monitorAudioBuffer[readPos].data.size() << "bytes.";