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);
|
||||
#endif
|
||||
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)));
|
||||
}
|
||||
else {
|
||||
|
|
|
@ -69,6 +69,7 @@ bool paHandler::init(audioSetup setup)
|
|||
// qDebug(logAudio()) << "Portaudio initialized";
|
||||
//}
|
||||
|
||||
|
||||
codecType codec = LPCM;
|
||||
if (setup.codec == 0x01 || setup.codec == 0x20)
|
||||
codec = PCMU;
|
||||
|
@ -151,20 +152,23 @@ bool paHandler::init(audioSetup setup)
|
|||
aParams.hostApiSpecificStreamInfo = NULL;
|
||||
|
||||
// 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
|
||||
|
||||
|
||||
if (setup.isinput) {
|
||||
err = Pa_IsFormatSupported(&aParams, NULL, outFormat.sampleRate());
|
||||
}
|
||||
else
|
||||
{
|
||||
err = Pa_IsFormatSupported(NULL,&aParams, outFormat.sampleRate());
|
||||
}
|
||||
|
||||
if (err != paNoError) {
|
||||
err = -1;
|
||||
int errCount = 0;
|
||||
while (err != paNoError) {
|
||||
if (setup.isinput) {
|
||||
err = Pa_IsFormatSupported(&aParams, NULL, outFormat.sampleRate());
|
||||
}
|
||||
else
|
||||
{
|
||||
err = Pa_IsFormatSupported(NULL, &aParams, outFormat.sampleRate());
|
||||
}
|
||||
if (err == paInvalidChannelCount)
|
||||
{
|
||||
qInfo(logAudio()) << (setup.isinput ? "Input" : "Output") << "Unsupported channel count" << aParams.channelCount;
|
||||
|
@ -177,30 +181,26 @@ bool paHandler::init(audioSetup setup)
|
|||
outFormat.setChannelCount(2);
|
||||
}
|
||||
}
|
||||
else if (err == paInvalidSampleRate)
|
||||
if (err == paInvalidSampleRate)
|
||||
{
|
||||
qInfo(logAudio()) << (setup.isinput ? "Input" : "Output") << "Unsupported sample rate" << outFormat.sampleRate();
|
||||
outFormat.setSampleRate(44100);
|
||||
}
|
||||
else if (err == paSampleFormatNotSupported)
|
||||
if (err == paSampleFormatNotSupported)
|
||||
{
|
||||
aParams.sampleFormat = paInt16;
|
||||
#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.setSampleSize(16);
|
||||
#else
|
||||
qInfo(logAudio()) << (setup.isinput ? "Input" : "Output") << "Unsupported sample Format" << outFormat.sampleFormat();
|
||||
outFormat.setSampleFormat(QAudioFormat::Int16);
|
||||
#endif
|
||||
}
|
||||
|
||||
if (setup.isinput) {
|
||||
err = Pa_IsFormatSupported(&aParams, NULL, outFormat.sampleRate());
|
||||
}
|
||||
else
|
||||
{
|
||||
err = Pa_IsFormatSupported(NULL, &aParams, outFormat.sampleRate());
|
||||
}
|
||||
if (err != paNoError) {
|
||||
errCount++;
|
||||
if (errCount > 5) {
|
||||
qCritical(logAudio()) << (setup.isinput ? "Input" : "Output") << "Cannot find suitable format, aborting:" << Pa_GetErrorText(err);
|
||||
return false;
|
||||
}
|
||||
|
@ -209,7 +209,7 @@ bool paHandler::init(audioSetup setup)
|
|||
if (setup.isinput) {
|
||||
|
||||
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)));
|
||||
}
|
||||
else {
|
||||
|
@ -271,7 +271,7 @@ int paHandler::writeData(const void* inputBuffer, void* outputBuffer,
|
|||
packet.sent = 0;
|
||||
packet.volume = volume;
|
||||
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);
|
||||
|
||||
if (status == paInputUnderflow) {
|
||||
|
@ -296,7 +296,7 @@ void paHandler::convertedOutput(audioPacket packet) {
|
|||
|
||||
if (Pa_IsStreamActive(audio) == 1) {
|
||||
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) {
|
||||
qDebug(logAudio()) << (setup.isinput ? "Input" : "Output") << "Error writing audio!";
|
||||
|
|
|
@ -232,19 +232,19 @@ bool rtHandler::init(audioSetup setup)
|
|||
|
||||
|
||||
// Per channel chunk size.
|
||||
this->chunkSize = (outFormat.bytesForDuration(setup.blockSize * 1000) / outFormat.bytesPerFrame());
|
||||
this->chunkSize = outFormat.framesForDuration(setup.blockSize * 1000);
|
||||
|
||||
#ifdef RT_EXCEPTION
|
||||
try {
|
||||
#endif
|
||||
if (setup.isinput) {
|
||||
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)));
|
||||
}
|
||||
else {
|
||||
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)));
|
||||
}
|
||||
audio->startStream();
|
||||
|
@ -342,8 +342,8 @@ int rtHandler::writeData(void* outputBuffer, void* inputBuffer,
|
|||
packet.volume = volume;
|
||||
memcpy(&packet.guid, setup.guid, GUIDLEN);
|
||||
packet.data.append((char*)inputBuffer, nFrames * outFormat.bytesPerFrame());
|
||||
|
||||
emit sendToConverter(packet);
|
||||
|
||||
if (status == RTAUDIO_INPUT_OVERFLOW) {
|
||||
isUnderrun = true;
|
||||
}
|
||||
|
|
|
@ -127,7 +127,7 @@ void udpAudio::receiveAudioData(audioPacket audio) {
|
|||
QByteArray partial = audio.data.mid(len, 1364);
|
||||
audio_packet p;
|
||||
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.rcvdid = remoteId;
|
||||
if (partial.length() == 0xa0) {
|
||||
|
|
|
@ -337,7 +337,7 @@ void udpBase::sendRetransmitRequest()
|
|||
{
|
||||
qInfo(logUdp()) << this->metaObject()->className() << ": sending request for multiple missing packets : " << missingSeqs.toHex(':');
|
||||
missingMutex.lock();
|
||||
p.len = sizeof(p) + missingSeqs.size();
|
||||
p.len = (quint32)sizeof(p) + missingSeqs.size();
|
||||
missingSeqs.insert(0, p.packet, sizeof(p));
|
||||
missingMutex.unlock();
|
||||
|
||||
|
|
|
@ -93,7 +93,7 @@ void udpCivData::send(QByteArray d)
|
|||
//qInfo(logUdp()) << "Sending: (" << d.length() << ") " << d;
|
||||
data_packet p;
|
||||
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.rcvdid = remoteId;
|
||||
p.reply = (char)0xc1;
|
||||
|
|
|
@ -1283,7 +1283,7 @@ void udpServer::sendCapabilities(CLIENT* c)
|
|||
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));
|
||||
|
||||
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)) {
|
||||
audio_packet p;
|
||||
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.rcvdid = client->remoteId;
|
||||
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();
|
||||
|
||||
p.len = sizeof(p) + missingSeqs.size();
|
||||
p.len = (quint32)sizeof(p) + missingSeqs.size();
|
||||
missingSeqs.insert(0, p.packet, sizeof(p));
|
||||
|
||||
if (udpMutex.try_lock_for(std::chrono::milliseconds(LOCK_PERIOD)))
|
||||
|
|
|
@ -3364,7 +3364,7 @@ void wfmain::sendRadioCommandLoop()
|
|||
if(haveRigCaps && !slowPollCmdQueue.empty())
|
||||
{
|
||||
|
||||
int nCmds = slowPollCmdQueue.size();
|
||||
int nCmds = (int)slowPollCmdQueue.size();
|
||||
cmds sCmd = slowPollCmdQueue[(slowCmdNum++)%nCmds];
|
||||
doCmd(sCmd);
|
||||
}
|
||||
|
@ -3374,7 +3374,7 @@ void wfmain::sendRadioCommandLoop()
|
|||
// s-meter or other metering
|
||||
if(haveRigCaps && !periodicCmdQueue.empty())
|
||||
{
|
||||
int nCmds = periodicCmdQueue.size();
|
||||
int nCmds = (int)periodicCmdQueue.size();
|
||||
cmds pcmd = periodicCmdQueue[ (pCmdNum++)%nCmds ];
|
||||
doCmd(pcmd);
|
||||
}
|
||||
|
|
Ładowanie…
Reference in New Issue