Fix for crashing pty on mac

audioplugins
Phil Taylor 2021-05-31 17:55:01 +01:00
rodzic 6a103d051f
commit 35dd0c9c62
3 zmienionych plików z 22 dodań i 8 usunięć

Wyświetl plik

@ -145,6 +145,7 @@ bool audioHandler::init(const quint8 bits, const quint8 radioChan, const quint16
wf_resampler_get_ratio(resampler, &ratioNum, &ratioDen);
qInfo(logAudio()) << (isInput ? "Input" : "Output") << "wf_resampler_init() returned: " << resample_error << " ratioNum" << ratioNum << " ratioDen" << ratioDen;
qInfo(logAudio()) << (isInput ? "Input" : "Output") << "thread id" << QThread::currentThreadId();
return isInitialized;
}

Wyświetl plik

@ -15,7 +15,7 @@
pttyHandler::pttyHandler(QString pty)
{
//constructor
if (pty == "" || pty == "None")
if (pty == "" || pty.toLower() == "none")
{
// Just return if pty is not configured.
return;
@ -94,7 +94,7 @@ void pttyHandler::openPort()
#ifndef Q_OS_WIN
ptDevSlave = QString::fromLocal8Bit(ptsname(ptfd));
if (portName != "" && portName != "None")
if (portName != "" && portName.toLower() != "none")
{
if (!QFile::link(ptDevSlave, portName))
{
@ -115,7 +115,16 @@ pttyHandler::~pttyHandler()
void pttyHandler::receiveDataFromRigToPtty(const QByteArray& data)
{
if (isConnected && (unsigned char)data[2] != (unsigned char)0xE1 && (unsigned char)data[3] != (unsigned char)0xE1)
int fePos=data.lastIndexOf((char)0xfe);
if (fePos>0)
fePos=fePos-1;
else
{
qDebug(logSerial()) << "Invalid command";
printHex(data,false,true);
}
if (isConnected && (unsigned char)data.mid(fePos)[2] != (unsigned char)0xE1 && (unsigned char)data.mid(fePos)[3] != (unsigned char)0xE1)
{
// send to the pseudo port as well
// index 2 is dest, 0xE1 is wfview, 0xE0 is assumed to be the other device.
@ -124,7 +133,7 @@ void pttyHandler::receiveDataFromRigToPtty(const QByteArray& data)
// 0xE0 = pseudo-term host
// 0x00 = broadcast to all
//qInfo(logSerial()) << "Sending data from radio to pseudo-terminal";
sendDataOut(data);
sendDataOut(data.mid(fePos));
}
}
@ -258,7 +267,7 @@ void pttyHandler::closePort()
delete port;
}
#else
if (isConnected && portName != "" && portName != "None")
if (isConnected && portName != "" && portName.toLower() != "none")
{
QFile::remove(portName);
}

Wyświetl plik

@ -590,7 +590,7 @@ void udpCivData::watchdog()
void udpCivData::send(QByteArray d)
{
// qInfo(logUdp()) << "Sending: (" << d.length() << ") " << 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();
@ -642,6 +642,7 @@ void udpCivData::dataReceived()
//qInfo(logUdp()) << "Received: " << datagram.data();
QByteArray r = datagram.data();
switch (r.length())
{
case (CONTROL_SIZE): // Control packet
@ -678,7 +679,9 @@ void udpCivData::dataReceived()
lastReceived = QTime::currentTime();
if (quint16(in->datalen + 0x15) == (quint16)in->len)
{
emit receive(r.mid(0x15));
//if (r.mid(0x15).length() != 157)
emit receive(r.mid(0x15));
//qDebug(logUdp()) << "Got incoming CIV datagram" << r.mid(0x15).length();
}
}
@ -687,6 +690,7 @@ void udpCivData::dataReceived()
}
}
udpBase::dataReceived(r); // Call parent function to process the rest.
r.clear();
datagram.clear();
@ -852,7 +856,7 @@ void udpAudio::watchdog()
/* Just log it at the moment, maybe try signalling the control channel that it needs to
try requesting civ/audio again? */
qInfo(logUdp()) << " Audio Watchdog: no audio data received for 2s, restart required";
qInfo(logUdp()) << " Audio Watchdog: no audio data received for 2s, restart required?";
alerted = true;
}
}