kopia lustrzana https://gitlab.com/eliggett/wfview
Fix all audio formats and some compile warnings!
rodzic
03ebafae5b
commit
8a4b9f1934
|
@ -193,7 +193,7 @@ audioHandler::~audioHandler()
|
||||||
audioInput = new QAudioSource(setup.port, outFormat, this);
|
audioInput = new QAudioSource(setup.port, outFormat, this);
|
||||||
#endif
|
#endif
|
||||||
connect(audioInput, SIGNAL(stateChanged(QAudio::State)), SLOT(stateChanged(QAudio::State)));
|
connect(audioInput, SIGNAL(stateChanged(QAudio::State)), SLOT(stateChanged(QAudio::State)));
|
||||||
emit setupConverter(outFormat, codec, inFormat, codecType::LPCM, 7, setup.resampleQuality);
|
emit setupConverter(outFormat, codecType::LPCM, inFormat, codec, 7, setup.resampleQuality);
|
||||||
connect(converter, SIGNAL(converted(audioPacket)), this, SLOT(convertedInput(audioPacket)));
|
connect(converter, SIGNAL(converted(audioPacket)), this, SLOT(convertedInput(audioPacket)));
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
|
|
|
@ -69,6 +69,7 @@ bool paHandler::init(audioSetup setup)
|
||||||
// qDebug(logAudio()) << "Portaudio initialized";
|
// qDebug(logAudio()) << "Portaudio initialized";
|
||||||
//}
|
//}
|
||||||
|
|
||||||
|
|
||||||
codecType codec = LPCM;
|
codecType codec = LPCM;
|
||||||
if (setup.codec == 0x01 || setup.codec == 0x20)
|
if (setup.codec == 0x01 || setup.codec == 0x20)
|
||||||
codec = PCMU;
|
codec = PCMU;
|
||||||
|
@ -151,20 +152,23 @@ bool paHandler::init(audioSetup setup)
|
||||||
aParams.hostApiSpecificStreamInfo = NULL;
|
aParams.hostApiSpecificStreamInfo = NULL;
|
||||||
|
|
||||||
// Per channel chunk size.
|
// Per channel chunk size.
|
||||||
this->chunkSize = (outFormat.bytesForDuration(setup.blockSize * 1000) / sizeof(float)) * outFormat.channelCount();
|
this->chunkSize = outFormat.framesForDuration(setup.blockSize * 1000);
|
||||||
|
|
||||||
|
qInfo(logAudio()) << (setup.isinput ? "Input" : "Output") << "Chunk size" << this->chunkSize;
|
||||||
// Check the format is supported
|
// Check the format is supported
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
err = -1;
|
||||||
|
int errCount = 0;
|
||||||
|
while (err != paNoError) {
|
||||||
if (setup.isinput) {
|
if (setup.isinput) {
|
||||||
err = Pa_IsFormatSupported(&aParams, NULL, outFormat.sampleRate());
|
err = Pa_IsFormatSupported(&aParams, NULL, outFormat.sampleRate());
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
err = Pa_IsFormatSupported(NULL,&aParams, outFormat.sampleRate());
|
err = Pa_IsFormatSupported(NULL, &aParams, outFormat.sampleRate());
|
||||||
}
|
}
|
||||||
|
|
||||||
if (err != paNoError) {
|
|
||||||
if (err == paInvalidChannelCount)
|
if (err == paInvalidChannelCount)
|
||||||
{
|
{
|
||||||
qInfo(logAudio()) << (setup.isinput ? "Input" : "Output") << "Unsupported channel count" << aParams.channelCount;
|
qInfo(logAudio()) << (setup.isinput ? "Input" : "Output") << "Unsupported channel count" << aParams.channelCount;
|
||||||
|
@ -177,30 +181,26 @@ bool paHandler::init(audioSetup setup)
|
||||||
outFormat.setChannelCount(2);
|
outFormat.setChannelCount(2);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else if (err == paInvalidSampleRate)
|
if (err == paInvalidSampleRate)
|
||||||
{
|
{
|
||||||
qInfo(logAudio()) << (setup.isinput ? "Input" : "Output") << "Unsupported sample rate" << outFormat.sampleRate();
|
qInfo(logAudio()) << (setup.isinput ? "Input" : "Output") << "Unsupported sample rate" << outFormat.sampleRate();
|
||||||
outFormat.setSampleRate(44100);
|
outFormat.setSampleRate(44100);
|
||||||
}
|
}
|
||||||
else if (err == paSampleFormatNotSupported)
|
if (err == paSampleFormatNotSupported)
|
||||||
{
|
{
|
||||||
aParams.sampleFormat = paInt16;
|
aParams.sampleFormat = paInt16;
|
||||||
#if (QT_VERSION < QT_VERSION_CHECK(6,0,0))
|
#if (QT_VERSION < QT_VERSION_CHECK(6,0,0))
|
||||||
|
qInfo(logAudio()) << (setup.isinput ? "Input" : "Output") << "Unsupported sample Format" << outFormat.sampleType();
|
||||||
outFormat.setSampleType(QAudioFormat::SignedInt);
|
outFormat.setSampleType(QAudioFormat::SignedInt);
|
||||||
outFormat.setSampleSize(16);
|
outFormat.setSampleSize(16);
|
||||||
#else
|
#else
|
||||||
|
qInfo(logAudio()) << (setup.isinput ? "Input" : "Output") << "Unsupported sample Format" << outFormat.sampleFormat();
|
||||||
outFormat.setSampleFormat(QAudioFormat::Int16);
|
outFormat.setSampleFormat(QAudioFormat::Int16);
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
if (setup.isinput) {
|
errCount++;
|
||||||
err = Pa_IsFormatSupported(&aParams, NULL, outFormat.sampleRate());
|
if (errCount > 5) {
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
err = Pa_IsFormatSupported(NULL, &aParams, outFormat.sampleRate());
|
|
||||||
}
|
|
||||||
if (err != paNoError) {
|
|
||||||
qCritical(logAudio()) << (setup.isinput ? "Input" : "Output") << "Cannot find suitable format, aborting:" << Pa_GetErrorText(err);
|
qCritical(logAudio()) << (setup.isinput ? "Input" : "Output") << "Cannot find suitable format, aborting:" << Pa_GetErrorText(err);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
@ -209,7 +209,7 @@ bool paHandler::init(audioSetup setup)
|
||||||
if (setup.isinput) {
|
if (setup.isinput) {
|
||||||
|
|
||||||
err = Pa_OpenStream(&audio, &aParams, 0, outFormat.sampleRate(), this->chunkSize, paNoFlag, &paHandler::staticWrite, (void*)this);
|
err = Pa_OpenStream(&audio, &aParams, 0, outFormat.sampleRate(), this->chunkSize, paNoFlag, &paHandler::staticWrite, (void*)this);
|
||||||
emit setupConverter(outFormat, codec, inFormat, codecType::LPCM, 7, setup.resampleQuality);
|
emit setupConverter(outFormat, codecType::LPCM, inFormat, codec, 7, setup.resampleQuality);
|
||||||
connect(converter, SIGNAL(converted(audioPacket)), this, SLOT(convertedInput(audioPacket)));
|
connect(converter, SIGNAL(converted(audioPacket)), this, SLOT(convertedInput(audioPacket)));
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
|
@ -271,7 +271,7 @@ int paHandler::writeData(const void* inputBuffer, void* outputBuffer,
|
||||||
packet.sent = 0;
|
packet.sent = 0;
|
||||||
packet.volume = volume;
|
packet.volume = volume;
|
||||||
memcpy(&packet.guid, setup.guid, GUIDLEN);
|
memcpy(&packet.guid, setup.guid, GUIDLEN);
|
||||||
packet.data.append((char*)inputBuffer, nFrames*inFormat.channelCount()*sizeof(float));
|
packet.data.append((char*)inputBuffer, nFrames*outFormat.bytesPerFrame());
|
||||||
emit sendToConverter(packet);
|
emit sendToConverter(packet);
|
||||||
|
|
||||||
if (status == paInputUnderflow) {
|
if (status == paInputUnderflow) {
|
||||||
|
@ -296,7 +296,7 @@ void paHandler::convertedOutput(audioPacket packet) {
|
||||||
|
|
||||||
if (Pa_IsStreamActive(audio) == 1) {
|
if (Pa_IsStreamActive(audio) == 1) {
|
||||||
if (currentLatency < (setup.latency+latencyAllowance)) {
|
if (currentLatency < (setup.latency+latencyAllowance)) {
|
||||||
PaError err = Pa_WriteStream(audio, (char*)packet.data.data(), packet.data.size() / sizeof(float) / outFormat.channelCount());
|
PaError err = Pa_WriteStream(audio, (char*)packet.data.data(), packet.data.size() / outFormat.bytesPerFrame());
|
||||||
|
|
||||||
if (err != paNoError) {
|
if (err != paNoError) {
|
||||||
qDebug(logAudio()) << (setup.isinput ? "Input" : "Output") << "Error writing audio!";
|
qDebug(logAudio()) << (setup.isinput ? "Input" : "Output") << "Error writing audio!";
|
||||||
|
|
|
@ -232,19 +232,19 @@ bool rtHandler::init(audioSetup setup)
|
||||||
|
|
||||||
|
|
||||||
// Per channel chunk size.
|
// Per channel chunk size.
|
||||||
this->chunkSize = (outFormat.bytesForDuration(setup.blockSize * 1000) / outFormat.bytesPerFrame());
|
this->chunkSize = outFormat.framesForDuration(setup.blockSize * 1000);
|
||||||
|
|
||||||
#ifdef RT_EXCEPTION
|
#ifdef RT_EXCEPTION
|
||||||
try {
|
try {
|
||||||
#endif
|
#endif
|
||||||
if (setup.isinput) {
|
if (setup.isinput) {
|
||||||
audio->openStream(NULL, &aParams, sampleFormat, outFormat.sampleRate(), &this->chunkSize, &staticWrite, this, &options);
|
audio->openStream(NULL, &aParams, sampleFormat, outFormat.sampleRate(), &this->chunkSize, &staticWrite, this, &options);
|
||||||
emit setupConverter(outFormat, codec, inFormat, codecType::LPCM, 7, setup.resampleQuality);
|
emit setupConverter(outFormat, codecType::LPCM, inFormat, codec, 7, setup.resampleQuality);
|
||||||
connect(converter, SIGNAL(converted(audioPacket)), this, SLOT(convertedInput(audioPacket)));
|
connect(converter, SIGNAL(converted(audioPacket)), this, SLOT(convertedInput(audioPacket)));
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
audio->openStream(&aParams, NULL, sampleFormat, outFormat.sampleRate(), &this->chunkSize, &staticRead, this , &options);
|
audio->openStream(&aParams, NULL, sampleFormat, outFormat.sampleRate(), &this->chunkSize, &staticRead, this , &options);
|
||||||
emit setupConverter(inFormat, codecType::LPCM, outFormat, codec, 7, setup.resampleQuality);
|
emit setupConverter(inFormat, codec, outFormat, codecType::LPCM, 7, setup.resampleQuality);
|
||||||
connect(converter, SIGNAL(converted(audioPacket)), this, SLOT(convertedOutput(audioPacket)));
|
connect(converter, SIGNAL(converted(audioPacket)), this, SLOT(convertedOutput(audioPacket)));
|
||||||
}
|
}
|
||||||
audio->startStream();
|
audio->startStream();
|
||||||
|
@ -342,8 +342,8 @@ int rtHandler::writeData(void* outputBuffer, void* inputBuffer,
|
||||||
packet.volume = volume;
|
packet.volume = volume;
|
||||||
memcpy(&packet.guid, setup.guid, GUIDLEN);
|
memcpy(&packet.guid, setup.guid, GUIDLEN);
|
||||||
packet.data.append((char*)inputBuffer, nFrames * outFormat.bytesPerFrame());
|
packet.data.append((char*)inputBuffer, nFrames * outFormat.bytesPerFrame());
|
||||||
|
|
||||||
emit sendToConverter(packet);
|
emit sendToConverter(packet);
|
||||||
|
|
||||||
if (status == RTAUDIO_INPUT_OVERFLOW) {
|
if (status == RTAUDIO_INPUT_OVERFLOW) {
|
||||||
isUnderrun = true;
|
isUnderrun = true;
|
||||||
}
|
}
|
||||||
|
|
|
@ -127,7 +127,7 @@ void udpAudio::receiveAudioData(audioPacket audio) {
|
||||||
QByteArray partial = audio.data.mid(len, 1364);
|
QByteArray partial = audio.data.mid(len, 1364);
|
||||||
audio_packet p;
|
audio_packet p;
|
||||||
memset(p.packet, 0x0, sizeof(p)); // We can't be sure it is initialized with 0x00!
|
memset(p.packet, 0x0, sizeof(p)); // We can't be sure it is initialized with 0x00!
|
||||||
p.len = sizeof(p) + partial.length();
|
p.len = (quint32)sizeof(p) + partial.length();
|
||||||
p.sentid = myId;
|
p.sentid = myId;
|
||||||
p.rcvdid = remoteId;
|
p.rcvdid = remoteId;
|
||||||
if (partial.length() == 0xa0) {
|
if (partial.length() == 0xa0) {
|
||||||
|
|
|
@ -337,7 +337,7 @@ void udpBase::sendRetransmitRequest()
|
||||||
{
|
{
|
||||||
qInfo(logUdp()) << this->metaObject()->className() << ": sending request for multiple missing packets : " << missingSeqs.toHex(':');
|
qInfo(logUdp()) << this->metaObject()->className() << ": sending request for multiple missing packets : " << missingSeqs.toHex(':');
|
||||||
missingMutex.lock();
|
missingMutex.lock();
|
||||||
p.len = sizeof(p) + missingSeqs.size();
|
p.len = (quint32)sizeof(p) + missingSeqs.size();
|
||||||
missingSeqs.insert(0, p.packet, sizeof(p));
|
missingSeqs.insert(0, p.packet, sizeof(p));
|
||||||
missingMutex.unlock();
|
missingMutex.unlock();
|
||||||
|
|
||||||
|
|
|
@ -93,7 +93,7 @@ void udpCivData::send(QByteArray d)
|
||||||
//qInfo(logUdp()) << "Sending: (" << d.length() << ") " << d;
|
//qInfo(logUdp()) << "Sending: (" << d.length() << ") " << d;
|
||||||
data_packet p;
|
data_packet p;
|
||||||
memset(p.packet, 0x0, sizeof(p)); // We can't be sure it is initialized with 0x00!
|
memset(p.packet, 0x0, sizeof(p)); // We can't be sure it is initialized with 0x00!
|
||||||
p.len = sizeof(p) + d.length();
|
p.len = (quint32)sizeof(p) + d.length();
|
||||||
p.sentid = myId;
|
p.sentid = myId;
|
||||||
p.rcvdid = remoteId;
|
p.rcvdid = remoteId;
|
||||||
p.reply = (char)0xc1;
|
p.reply = (char)0xc1;
|
||||||
|
|
|
@ -1283,7 +1283,7 @@ void udpServer::sendCapabilities(CLIENT* c)
|
||||||
s.data.append(QByteArray::fromRawData((const char*)r.packet, sizeof(r)));
|
s.data.append(QByteArray::fromRawData((const char*)r.packet, sizeof(r)));
|
||||||
}
|
}
|
||||||
|
|
||||||
p.len = sizeof(p)+s.data.length();
|
p.len = (quint32)sizeof(p)+s.data.length();
|
||||||
p.payloadsize = qToBigEndian((quint16)(sizeof(p) + s.data.length() - 0x10));
|
p.payloadsize = qToBigEndian((quint16)(sizeof(p) + s.data.length() - 0x10));
|
||||||
|
|
||||||
s.data.insert(0,QByteArray::fromRawData((const char*)p.packet, sizeof(p)));
|
s.data.insert(0,QByteArray::fromRawData((const char*)p.packet, sizeof(p)));
|
||||||
|
@ -1688,7 +1688,7 @@ void udpServer::receiveAudioData(const audioPacket& d)
|
||||||
if (client != Q_NULLPTR && client->connected && (!memcmp(client->guid, guid, GUIDLEN) || config->rigs.size()== 1)) {
|
if (client != Q_NULLPTR && client->connected && (!memcmp(client->guid, guid, GUIDLEN) || config->rigs.size()== 1)) {
|
||||||
audio_packet p;
|
audio_packet p;
|
||||||
memset(p.packet, 0x0, sizeof(p)); // We can't be sure it is initialized with 0x00!
|
memset(p.packet, 0x0, sizeof(p)); // We can't be sure it is initialized with 0x00!
|
||||||
p.len = sizeof(p) + partial.length();
|
p.len = (quint32)sizeof(p) + partial.length();
|
||||||
p.sentid = client->myId;
|
p.sentid = client->myId;
|
||||||
p.rcvdid = client->remoteId;
|
p.rcvdid = client->remoteId;
|
||||||
p.ident = 0x0080; // audio is always this?
|
p.ident = 0x0080; // audio is always this?
|
||||||
|
@ -1823,7 +1823,7 @@ void udpServer::sendRetransmitRequest(CLIENT* c)
|
||||||
{
|
{
|
||||||
qInfo(logUdp()) << this->metaObject()->className() << ": sending request for multiple missing packets : " << missingSeqs.toHex();
|
qInfo(logUdp()) << this->metaObject()->className() << ": sending request for multiple missing packets : " << missingSeqs.toHex();
|
||||||
|
|
||||||
p.len = sizeof(p) + missingSeqs.size();
|
p.len = (quint32)sizeof(p) + missingSeqs.size();
|
||||||
missingSeqs.insert(0, p.packet, sizeof(p));
|
missingSeqs.insert(0, p.packet, sizeof(p));
|
||||||
|
|
||||||
if (udpMutex.try_lock_for(std::chrono::milliseconds(LOCK_PERIOD)))
|
if (udpMutex.try_lock_for(std::chrono::milliseconds(LOCK_PERIOD)))
|
||||||
|
|
|
@ -3364,7 +3364,7 @@ void wfmain::sendRadioCommandLoop()
|
||||||
if(haveRigCaps && !slowPollCmdQueue.empty())
|
if(haveRigCaps && !slowPollCmdQueue.empty())
|
||||||
{
|
{
|
||||||
|
|
||||||
int nCmds = slowPollCmdQueue.size();
|
int nCmds = (int)slowPollCmdQueue.size();
|
||||||
cmds sCmd = slowPollCmdQueue[(slowCmdNum++)%nCmds];
|
cmds sCmd = slowPollCmdQueue[(slowCmdNum++)%nCmds];
|
||||||
doCmd(sCmd);
|
doCmd(sCmd);
|
||||||
}
|
}
|
||||||
|
@ -3374,7 +3374,7 @@ void wfmain::sendRadioCommandLoop()
|
||||||
// s-meter or other metering
|
// s-meter or other metering
|
||||||
if(haveRigCaps && !periodicCmdQueue.empty())
|
if(haveRigCaps && !periodicCmdQueue.empty())
|
||||||
{
|
{
|
||||||
int nCmds = periodicCmdQueue.size();
|
int nCmds = (int)periodicCmdQueue.size();
|
||||||
cmds pcmd = periodicCmdQueue[ (pCmdNum++)%nCmds ];
|
cmds pcmd = periodicCmdQueue[ (pCmdNum++)%nCmds ];
|
||||||
doCmd(pcmd);
|
doCmd(pcmd);
|
||||||
}
|
}
|
||||||
|
|
Ładowanie…
Reference in New Issue