kopia lustrzana https://gitlab.com/eliggett/wfview
Bit of code-tidying and minor fixes
rodzic
6a5f9ce988
commit
b78f613ef2
|
@ -82,7 +82,7 @@ private:
|
||||||
|
|
||||||
|
|
||||||
bool isUnderrun = false;
|
bool isUnderrun = false;
|
||||||
bool isOverrun = true;
|
bool isOverrun = false;
|
||||||
bool isInitialized=false;
|
bool isInitialized=false;
|
||||||
bool isReady = false;
|
bool isReady = false;
|
||||||
bool audioBuffered = false;
|
bool audioBuffered = false;
|
||||||
|
|
|
@ -217,7 +217,11 @@ bool paHandler::init(audioSetup setup)
|
||||||
void paHandler::setVolume(unsigned char volume)
|
void paHandler::setVolume(unsigned char volume)
|
||||||
{
|
{
|
||||||
|
|
||||||
|
#ifdef Q_OS_WIN
|
||||||
|
this->volume = audiopot[volume] * 5;
|
||||||
|
#else
|
||||||
this->volume = audiopot[volume];
|
this->volume = audiopot[volume];
|
||||||
|
#endif
|
||||||
|
|
||||||
qInfo(logAudio()) << (setup.isinput ? "Input" : "Output") << "setVolume: " << volume << "(" << this->volume << ")";
|
qInfo(logAudio()) << (setup.isinput ? "Input" : "Output") << "setVolume: " << volume << "(" << this->volume << ")";
|
||||||
}
|
}
|
||||||
|
@ -246,6 +250,18 @@ int paHandler::writeData(const void* inputBuffer, void* outputBuffer,
|
||||||
packet.data.append((char*)inputBuffer, nFrames*inFormat.channelCount()*sizeof(float));
|
packet.data.append((char*)inputBuffer, nFrames*inFormat.channelCount()*sizeof(float));
|
||||||
emit sendToConverter(packet);
|
emit sendToConverter(packet);
|
||||||
|
|
||||||
|
if (status == paInputUnderflow) {
|
||||||
|
isUnderrun = true;
|
||||||
|
}
|
||||||
|
else if (status == paInputOverflow) {
|
||||||
|
isOverrun = true;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
isUnderrun = false;
|
||||||
|
isOverrun = false;
|
||||||
|
}
|
||||||
|
|
||||||
return paContinue;
|
return paContinue;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -261,44 +277,24 @@ void paHandler::convertedOutput(audioPacket packet) {
|
||||||
qDebug(logAudio()) << (setup.isinput ? "Input" : "Output") << "Error writing audio!";
|
qDebug(logAudio()) << (setup.isinput ? "Input" : "Output") << "Error writing audio!";
|
||||||
}
|
}
|
||||||
const PaStreamInfo* info = Pa_GetStreamInfo(audio);
|
const PaStreamInfo* info = Pa_GetStreamInfo(audio);
|
||||||
|
currentLatency = packet.time.msecsTo(QTime::currentTime()) + (info->outputLatency * 1000);
|
||||||
//currentLatency = packet.time.msecsTo(QTime::currentTime()) + (info->outputLatency * 1000);
|
|
||||||
currentLatency = (info->outputLatency * 1000);
|
|
||||||
|
|
||||||
}
|
|
||||||
/*
|
|
||||||
currentLatency = packet.time.msecsTo(QTime::currentTime()) + (outFormat.durationForBytes(audioOutput->bufferSize() - audioOutput->bytesFree()) / 1000);
|
|
||||||
|
|
||||||
if (audioDevice != Q_NULLPTR) {
|
|
||||||
if (audioDevice->write(packet.data) < packet.data.size()) {
|
|
||||||
qDebug(logAudio()) << (setup.isinput ? "Input" : "Output") << "Buffer full!";
|
|
||||||
isOverrun = true;
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
isOverrun = false;
|
|
||||||
}
|
|
||||||
if (lastReceived.msecsTo(QTime::currentTime()) > 100) {
|
|
||||||
qDebug(logAudio()) << (setup.isinput ? "Input" : "Output") << "Time since last audio packet" << lastReceived.msecsTo(QTime::currentTime()) << "Expected around" << setup.blockSize;
|
|
||||||
}
|
|
||||||
lastReceived = QTime::currentTime();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
lastSentSeq = packet.seq;
|
|
||||||
|
|
||||||
*/
|
|
||||||
amplitude = packet.amplitude;
|
amplitude = packet.amplitude;
|
||||||
emit haveLevels(getAmplitude(), setup.latency, currentLatency, false, false);
|
emit haveLevels(getAmplitude(), setup.latency, currentLatency, isUnderrun, isOverrun);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
void paHandler::convertedInput(audioPacket audio)
|
void paHandler::convertedInput(audioPacket packet)
|
||||||
{
|
{
|
||||||
if (audio.data.size() > 0) {
|
if (packet.data.size() > 0) {
|
||||||
emit haveAudioData(audio);
|
emit haveAudioData(packet);
|
||||||
amplitude = audio.amplitude;
|
amplitude = packet.amplitude;
|
||||||
emit haveLevels(getAmplitude(), setup.latency, currentLatency, false,false);
|
const PaStreamInfo* info = Pa_GetStreamInfo(audio);
|
||||||
|
currentLatency = packet.time.msecsTo(QTime::currentTime()) + (info->inputLatency * 1000);
|
||||||
|
emit haveLevels(getAmplitude(), setup.latency, currentLatency, isUnderrun, isOverrun);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -88,6 +88,8 @@ private:
|
||||||
QAudioFormat outFormat;
|
QAudioFormat outFormat;
|
||||||
audioConverter* converter = Q_NULLPTR;
|
audioConverter* converter = Q_NULLPTR;
|
||||||
QThread* converterThread = Q_NULLPTR;
|
QThread* converterThread = Q_NULLPTR;
|
||||||
|
bool isUnderrun = false;
|
||||||
|
bool isOverrun = false;
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif // PAHANDLER_H
|
#endif // PAHANDLER_H
|
||||||
|
|
|
@ -106,7 +106,7 @@ private:
|
||||||
QThread* converterThread = Q_NULLPTR;
|
QThread* converterThread = Q_NULLPTR;
|
||||||
QByteArray arrayBuffer;
|
QByteArray arrayBuffer;
|
||||||
bool isUnderrun = false;
|
bool isUnderrun = false;
|
||||||
bool isOverrun = true;
|
bool isOverrun = false;
|
||||||
QMutex audioMutex;
|
QMutex audioMutex;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
Ładowanie…
Reference in New Issue