[AFV] Ref T739, we are checking "connected" already, no need to check it again

This commit is contained in:
Klaus Basan
2019-10-10 20:31:19 +02:00
committed by Mat Sutcliffe
parent e3ed71a919
commit f15674330f

View File

@@ -563,16 +563,16 @@ namespace BlackCore
return; return;
} }
if (! m_connection->isConnected()) { return; } {
QMutexLocker lock(&m_mutex);
if (!m_connection->isConnected()) { return; }
}
const QString callsign = this->getCallsign(); // threadsafe const QString callsign = this->getCallsign(); // threadsafe
const auto transmittingTransceivers = this->getTransmittingTransceivers(); // threadsafe const auto transmittingTransceivers = this->getTransmittingTransceivers(); // threadsafe
if (transmittingTransceivers.size() > 0) if (transmittingTransceivers.size() > 0)
{ {
if (transmit) if (transmit)
{
QMutexLocker lock(&m_mutex);
if (m_connection->isConnected())
{ {
AudioTxOnTransceiversDto dto; AudioTxOnTransceiversDto dto;
dto.callsign = callsign.toStdString(); dto.callsign = callsign.toStdString();
@@ -580,14 +580,11 @@ namespace BlackCore
dto.audio = std::vector<char>(args.audio.begin(), args.audio.end()); dto.audio = std::vector<char>(args.audio.begin(), args.audio.end());
dto.lastPacket = false; dto.lastPacket = false;
dto.transceivers = transmittingTransceivers.toStdVector(); dto.transceivers = transmittingTransceivers.toStdVector();
QMutexLocker lock(&m_mutex);
m_connection->sendToVoiceServer(dto); m_connection->sendToVoiceServer(dto);
} }
}
if (!transmit && transmitHistory) if (!transmit && transmitHistory)
{
QMutexLocker lock(&m_mutex);
if (m_connection->isConnected())
{ {
AudioTxOnTransceiversDto dto; AudioTxOnTransceiversDto dto;
dto.callsign = callsign.toStdString(); dto.callsign = callsign.toStdString();
@@ -595,9 +592,9 @@ namespace BlackCore
dto.audio = std::vector<char>(args.audio.begin(), args.audio.end()); dto.audio = std::vector<char>(args.audio.begin(), args.audio.end());
dto.lastPacket = true; dto.lastPacket = true;
dto.transceivers = transmittingTransceivers.toStdVector(); dto.transceivers = transmittingTransceivers.toStdVector();
QMutexLocker lock(&m_mutex);
m_connection->sendToVoiceServer(dto); m_connection->sendToVoiceServer(dto);
} }
}
m_transmitHistory = transmit; // threadsafe m_transmitHistory = transmit; // threadsafe
} }
} }