kopia lustrzana https://gitlab.com/eliggett/wfview
udpserver fixes
rodzic
b9c5194867
commit
2bad85bb35
|
@ -131,8 +131,8 @@ bool audioHandler::init(const quint8 bits, const quint8 channels, const quint16
|
|||
|
||||
void audioHandler::setVolume(unsigned char volume)
|
||||
{
|
||||
qInfo(logAudio()) << (isInput ? "Input" : "Output") << "setVolume: " << volume << "(" << (qreal)(volume/255.0) << ")";
|
||||
this->volume = (qreal)(volume / 255.0);
|
||||
qInfo(logAudio()) << (isInput ? "Input" : "Output") << "setVolume: " << volume << "(" << (qreal)(volume / 255.0) << ")";
|
||||
this->volume = (qreal)(volume/255.0);
|
||||
}
|
||||
|
||||
|
||||
|
@ -267,13 +267,13 @@ void audioHandler::stateChanged(QAudio::State state)
|
|||
|
||||
|
||||
|
||||
int audioHandler::incomingAudio(audioPacket data)
|
||||
void audioHandler::incomingAudio(audioPacket data)
|
||||
{
|
||||
// No point buffering audio until stream is actually running.
|
||||
if (!audio.isStreamRunning())
|
||||
{
|
||||
qDebug(logAudio()) << "Packet received before stream was started";
|
||||
return currentLatency;
|
||||
return;
|
||||
}
|
||||
// Incoming data is 8bits?
|
||||
if (radioSampleBits == 8)
|
||||
|
@ -349,7 +349,7 @@ int audioHandler::incomingAudio(audioPacket data)
|
|||
{
|
||||
qDebug(logAudio()) << "Buffer full! capacity:" << ringBuf->capacity() << "length" << ringBuf->size();
|
||||
}
|
||||
return currentLatency;
|
||||
return;
|
||||
}
|
||||
|
||||
void audioHandler::changeLatency(const quint16 newSize)
|
||||
|
@ -358,9 +358,9 @@ void audioHandler::changeLatency(const quint16 newSize)
|
|||
audioLatency = newSize;
|
||||
}
|
||||
|
||||
void audioHandler::getLatency()
|
||||
int audioHandler::getLatency()
|
||||
{
|
||||
emit sendLatency(audioLatency);
|
||||
return currentLatency;
|
||||
}
|
||||
|
||||
bool audioHandler::isChunkAvailable()
|
||||
|
|
|
@ -13,6 +13,7 @@ typedef signed short MY_TYPE;
|
|||
#define FORMAT RTAUDIO_SINT16
|
||||
#define SCALE 32767.0
|
||||
|
||||
#define LOG100 4.60517018599
|
||||
|
||||
#include <QThread>
|
||||
#include <QTimer>
|
||||
|
@ -46,7 +47,7 @@ public:
|
|||
audioHandler(QObject* parent = 0);
|
||||
~audioHandler();
|
||||
|
||||
void getLatency();
|
||||
int getLatency();
|
||||
|
||||
bool setDevice(QAudioDeviceInfo deviceInfo);
|
||||
|
||||
|
@ -58,7 +59,6 @@ public:
|
|||
bool isSequential() const;
|
||||
void getNextAudioChunk(QByteArray &data);
|
||||
bool isChunkAvailable();
|
||||
int incomingAudio(const audioPacket data);
|
||||
|
||||
private slots:
|
||||
bool init(const quint8 bits, const quint8 channels, const quint16 samplerate, const quint16 latency, const bool isulaw, const bool isinput, int port, quint8 resampleQuality);
|
||||
|
@ -66,6 +66,7 @@ private slots:
|
|||
void notified();
|
||||
void stateChanged(QAudio::State state);
|
||||
void setVolume(unsigned char volume);
|
||||
void incomingAudio(const audioPacket data);
|
||||
|
||||
signals:
|
||||
void audioMessage(QString message);
|
||||
|
|
|
@ -748,7 +748,7 @@ udpAudio::udpAudio(QHostAddress local, QHostAddress ip, quint16 audioPort, quint
|
|||
connect(this, SIGNAL(setupRxAudio(quint8,quint8,quint16,quint16,bool,bool,int,quint8)), rxaudio, SLOT(init(quint8,quint8,quint16,quint16,bool,bool,int,quint8)));
|
||||
|
||||
// signal/slot not currently used.
|
||||
//connect(this, SIGNAL(haveAudioData(audioPacket)), rxaudio, SLOT(incomingAudio(audioPacket)));
|
||||
connect(this, SIGNAL(haveAudioData(audioPacket)), rxaudio, SLOT(incomingAudio(audioPacket)));
|
||||
connect(this, SIGNAL(haveChangeLatency(quint16)), rxaudio, SLOT(changeLatency(quint16)));
|
||||
connect(this, SIGNAL(haveSetVolume(unsigned char)), rxaudio, SLOT(setVolume(unsigned char)));
|
||||
connect(rxAudioThread, SIGNAL(finished()), rxaudio, SLOT(deleteLater()));
|
||||
|
@ -951,8 +951,9 @@ void udpAudio::dataReceived()
|
|||
tempAudio.data = r.mid(0x18);
|
||||
// Prefer signal/slot to forward audio as it is thread/safe
|
||||
// Need to do more testing but latency appears fine.
|
||||
audioLatency = rxaudio->incomingAudio(tempAudio);
|
||||
//audioLatency = rxaudio->incomingAudio(tempAudio);
|
||||
emit haveAudioData(tempAudio);
|
||||
audioLatency = rxaudio->getLatency();
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
|
|
@ -398,8 +398,7 @@ void udpServer::controlReceived()
|
|||
emit setupTxAudio(samples, channels, current->txSampleRate, current->txBufferLen, uLaw, false, config.audioOutput, config.resampleQuality);
|
||||
hasTxAudio=datagram.senderAddress();
|
||||
|
||||
// signal/slot not currently used.
|
||||
//connect(this, SIGNAL(haveAudioData(audioPacket)), txaudio, SLOT(incomingAudio(audioPacket)));
|
||||
connect(this, SIGNAL(haveAudioData(audioPacket)), txaudio, SLOT(incomingAudio(audioPacket)));
|
||||
|
||||
}
|
||||
if (rxaudio == Q_NULLPTR)
|
||||
|
@ -698,8 +697,7 @@ void udpServer::audioReceived()
|
|||
tempAudio.sent = 0;
|
||||
tempAudio.data = r.mid(0x18);
|
||||
//qInfo(logUdpServer()) << "sending tx audio " << in->seq;
|
||||
//emit haveAudioData(tempAudio);
|
||||
txaudio->incomingAudio(tempAudio);
|
||||
emit haveAudioData(tempAudio);
|
||||
}
|
||||
}
|
||||
break;
|
||||
|
|
Ładowanie…
Reference in New Issue