kopia lustrzana https://gitlab.com/eliggett/wfview
Backup out of last change
rodzic
0d529b4a1b
commit
1e51e36c9d
|
@ -189,10 +189,11 @@ void audioHandler::start()
|
||||||
qInfo(logAudio()) << (setup.isinput ? "Input" : "Output") << "start() running";
|
qInfo(logAudio()) << (setup.isinput ? "Input" : "Output") << "start() running";
|
||||||
|
|
||||||
if (setup.isinput) {
|
if (setup.isinput) {
|
||||||
this->open(QIODevice::WriteOnly | QIODevice::Unbuffered);
|
//this->open(QIODevice::WriteOnly);
|
||||||
audioInput->start(this);
|
//audioInput->start(this);
|
||||||
|
audioDevice = audioInput->start();
|
||||||
connect(audioInput, SIGNAL(destroyed()), audioDevice, SLOT(deleteLater()), Qt::UniqueConnection);
|
connect(audioInput, SIGNAL(destroyed()), audioDevice, SLOT(deleteLater()), Qt::UniqueConnection);
|
||||||
//connect(audioDevice, SIGNAL(readyRead()), this, SLOT(getNextAudioChunk()), Qt::UniqueConnection);
|
connect(audioDevice, SIGNAL(readyRead()), this, SLOT(getNextAudioChunk()), Qt::UniqueConnection);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
// Buffer size must be set before audio is started.
|
// Buffer size must be set before audio is started.
|
||||||
|
@ -228,6 +229,7 @@ void audioHandler::stop()
|
||||||
audioDevice = Q_NULLPTR;
|
audioDevice = Q_NULLPTR;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
qint64 audioHandler::readData(char* data, qint64 nBytes) {
|
qint64 audioHandler::readData(char* data, qint64 nBytes) {
|
||||||
return nBytes;
|
return nBytes;
|
||||||
}
|
}
|
||||||
|
@ -251,7 +253,7 @@ qint64 audioHandler::writeData(const char* data, qint64 nBytes) {
|
||||||
|
|
||||||
return nBytes;
|
return nBytes;
|
||||||
}
|
}
|
||||||
|
*/
|
||||||
|
|
||||||
void audioHandler::setVolume(unsigned char volume)
|
void audioHandler::setVolume(unsigned char volume)
|
||||||
{
|
{
|
||||||
|
@ -262,7 +264,7 @@ void audioHandler::setVolume(unsigned char volume)
|
||||||
|
|
||||||
void audioHandler::incomingAudio(audioPacket packet)
|
void audioHandler::incomingAudio(audioPacket packet)
|
||||||
{
|
{
|
||||||
QTime startProcessing = QTime::currentTime();
|
//QTime startProcessing = QTime::currentTime();
|
||||||
|
|
||||||
packet.volume = volume;
|
packet.volume = volume;
|
||||||
|
|
||||||
|
@ -274,22 +276,19 @@ void audioHandler::incomingAudio(audioPacket packet)
|
||||||
void audioHandler::convertedOutput(audioPacket packet) {
|
void audioHandler::convertedOutput(audioPacket packet) {
|
||||||
|
|
||||||
currentLatency = packet.time.msecsTo(QTime::currentTime()) + (format.durationForBytes(audioOutput->bufferSize() - audioOutput->bytesFree()) / 1000);
|
currentLatency = packet.time.msecsTo(QTime::currentTime()) + (format.durationForBytes(audioOutput->bufferSize() - audioOutput->bytesFree()) / 1000);
|
||||||
if (audioDevice != Q_NULLPTR && audioOutput != Q_NULLPTR) {
|
if (audioDevice != Q_NULLPTR) {
|
||||||
audioDevice->write(packet.data);
|
audioDevice->write(packet.data);
|
||||||
if (lastReceived.msecsTo(QTime::currentTime()) > 100) {
|
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;
|
qDebug(logAudio()) << (setup.isinput ? "Input" : "Output") << "Time since last audio packet" << lastReceived.msecsTo(QTime::currentTime()) << "Expected around" << setup.blockSize;
|
||||||
}
|
}
|
||||||
lastReceived = QTime::currentTime();
|
lastReceived = QTime::currentTime();
|
||||||
}
|
}
|
||||||
|
/*if ((packet.seq > lastSentSeq + 1) && (setup.codec == 0x40 || setup.codec == 0x80)) {
|
||||||
/*
|
|
||||||
if ((packet.seq > lastSentSeq + 1) && (setup.codec == 0x40 || setup.codec == 0x80)) {
|
|
||||||
qDebug(logAudio()) << (setup.isinput ? "Input" : "Output") << "Attempting FEC on packet" << packet.seq << "as last is" << lastSentSeq;
|
qDebug(logAudio()) << (setup.isinput ? "Input" : "Output") << "Attempting FEC on packet" << packet.seq << "as last is" << lastSentSeq;
|
||||||
lastSentSeq = packet.seq;
|
lastSentSeq = packet.seq;
|
||||||
incomingAudio(packet); // Call myself again to run the packet a second time (FEC)
|
incomingAudio(packet); // Call myself again to run the packet a second time (FEC)
|
||||||
}
|
}
|
||||||
*/
|
*/
|
||||||
|
|
||||||
lastSentSeq = packet.seq;
|
lastSentSeq = packet.seq;
|
||||||
emit haveLevels(getAmplitude(), setup.latency, currentLatency, isUnderrun);
|
emit haveLevels(getAmplitude(), setup.latency, currentLatency, isUnderrun);
|
||||||
|
|
||||||
|
@ -307,7 +306,7 @@ void audioHandler::getNextAudioChunk()
|
||||||
packet.sent = 0;
|
packet.sent = 0;
|
||||||
packet.volume = volume;
|
packet.volume = volume;
|
||||||
memcpy(&packet.guid, setup.guid, GUIDLEN);
|
memcpy(&packet.guid, setup.guid, GUIDLEN);
|
||||||
QTime startProcessing = QTime::currentTime();
|
//QTime startProcessing = QTime::currentTime();
|
||||||
packet.data.clear();
|
packet.data.clear();
|
||||||
packet.data = tempBuf.data.mid(0, format.bytesForDuration(setup.blockSize * 1000));
|
packet.data = tempBuf.data.mid(0, format.bytesForDuration(setup.blockSize * 1000));
|
||||||
tempBuf.data.remove(0, format.bytesForDuration(setup.blockSize * 1000));
|
tempBuf.data.remove(0, format.bytesForDuration(setup.blockSize * 1000));
|
||||||
|
@ -326,7 +325,6 @@ void audioHandler::convertedInput(audioPacket audio)
|
||||||
qDebug(logAudio()) << (setup.isinput ? "Input" : "Output") << "Time since last audio packet" << lastReceived.msecsTo(QTime::currentTime()) << "Expected around" << setup.blockSize ;
|
qDebug(logAudio()) << (setup.isinput ? "Input" : "Output") << "Time since last audio packet" << lastReceived.msecsTo(QTime::currentTime()) << "Expected around" << setup.blockSize ;
|
||||||
}
|
}
|
||||||
lastReceived = QTime::currentTime();
|
lastReceived = QTime::currentTime();
|
||||||
//ret = livePacket.data;
|
|
||||||
amplitude = audio.amplitude;
|
amplitude = audio.amplitude;
|
||||||
emit haveLevels(getAmplitude(), setup.latency, currentLatency, isUnderrun);
|
emit haveLevels(getAmplitude(), setup.latency, currentLatency, isUnderrun);
|
||||||
}
|
}
|
||||||
|
|
|
@ -72,7 +72,8 @@ struct audioSetup {
|
||||||
};
|
};
|
||||||
|
|
||||||
// For QtMultimedia, use a native QIODevice
|
// For QtMultimedia, use a native QIODevice
|
||||||
class audioHandler : public QIODevice
|
//class audioHandler : public QIODevice
|
||||||
|
class audioHandler : public QObject
|
||||||
{
|
{
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
|
|
||||||
|
@ -111,8 +112,8 @@ signals:
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
|
||||||
qint64 readData(char* data, qint64 nBytes);
|
//qint64 readData(char* data, qint64 nBytes);
|
||||||
qint64 writeData(const char* data, qint64 nBytes);
|
//qint64 writeData(const char* data, qint64 nBytes);
|
||||||
|
|
||||||
|
|
||||||
bool isUnderrun = false;
|
bool isUnderrun = false;
|
||||||
|
|
Ładowanie…
Reference in New Issue