fix for high prio socket
This commit is contained in:
parent
4b83fa6fe0
commit
e5aedf6998
4 changed files with 37 additions and 8 deletions
|
@ -51,6 +51,8 @@ CChannel::CChannel ( const bool bNIsServer ) :
|
|||
|
||||
|
||||
// Connections -------------------------------------------------------------
|
||||
|
||||
// TODO if we later do not fire vectors in the emits, we can remove this again
|
||||
qRegisterMetaType<CVector<uint8_t> > ( "CVector<uint8_t>" );
|
||||
qRegisterMetaType<CHostAddress> ( "CHostAddress" );
|
||||
|
||||
|
@ -477,6 +479,7 @@ EPutDataStat CChannel::PutData ( const CVector<uint8_t>& vecbyData,
|
|||
{
|
||||
// fire a signal so that an other class can process this type of
|
||||
// message
|
||||
// TODO a copy of the vector is used -> avoid malloc in real-time routine
|
||||
emit DetectedCLMessage ( vecbyMesBodyData, iRecID );
|
||||
|
||||
// set status flag
|
||||
|
@ -485,6 +488,7 @@ EPutDataStat CChannel::PutData ( const CVector<uint8_t>& vecbyData,
|
|||
else
|
||||
{
|
||||
// parse the message assuming this is a regular protocol message
|
||||
// TODO a copy of the vector is used -> avoid malloc in real-time routine
|
||||
emit ParseMessageBody ( vecbyMesBodyData, iRecCounter, iRecID );
|
||||
|
||||
// note that protocol OK is not correct here since we do not
|
||||
|
@ -625,6 +629,23 @@ EGetDataStat CChannel::GetData ( CVector<uint8_t>& vecbyData,
|
|||
return eGetStatus;
|
||||
}
|
||||
|
||||
#ifdef ENABLE_RECEIVE_SOCKET_IN_SEPARATE_THREAD
|
||||
void CChannel::PrepAndSendPacketHPS ( CHighPrioSocket* pSocket,
|
||||
const CVector<uint8_t>& vecbyNPacket,
|
||||
const int iNPacketLen )
|
||||
{
|
||||
// TODO Doubled code!!! Same code as in PrepAndSendPacket (see below)!!!
|
||||
QMutexLocker locker ( &Mutex );
|
||||
|
||||
// use conversion buffer to convert sound card block size in network
|
||||
// block size
|
||||
if ( ConvBuf.Put ( vecbyNPacket, iNPacketLen ) )
|
||||
{
|
||||
pSocket->SendPacket ( ConvBuf.Get(), GetAddress() );
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
void CChannel::PrepAndSendPacket ( CSocket* pSocket,
|
||||
const CVector<uint8_t>& vecbyNPacket,
|
||||
const int iNPacketLen )
|
||||
|
|
|
@ -68,10 +68,17 @@ public:
|
|||
EGetDataStat GetData ( CVector<uint8_t>& vecbyData,
|
||||
const int iNumBytes );
|
||||
|
||||
#ifdef ENABLE_RECEIVE_SOCKET_IN_SEPARATE_THREAD
|
||||
void PrepAndSendPacketHPS ( CHighPrioSocket* pSocket,
|
||||
const CVector<uint8_t>& vecbyNPacket,
|
||||
const int iNPacketLen );
|
||||
#endif
|
||||
|
||||
void PrepAndSendPacket ( CSocket* pSocket,
|
||||
const CVector<uint8_t>& vecbyNPacket,
|
||||
const int iNPacketLen );
|
||||
|
||||
|
||||
void ResetTimeOutCounter() { iConTimeOut = iConTimeOutStartVal; }
|
||||
bool IsConnected() const { return iConTimeOut > 0; }
|
||||
void Disconnect();
|
||||
|
|
|
@ -1093,9 +1093,15 @@ void CClient::ProcessAudioDataIntern ( CVector<int16_t>& vecsStereoSndCrd )
|
|||
}
|
||||
|
||||
// send coded audio through the network
|
||||
#ifdef ENABLE_RECEIVE_SOCKET_IN_SEPARATE_THREAD
|
||||
Channel.PrepAndSendPacketHPS ( &Socket,
|
||||
vecCeltData,
|
||||
iCeltNumCodedBytes );
|
||||
#else
|
||||
Channel.PrepAndSendPacket ( &Socket,
|
||||
vecCeltData,
|
||||
iCeltNumCodedBytes );
|
||||
#endif
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -110,11 +110,6 @@ public:
|
|||
CHighPrioSocket ( CChannel* pNewChannel,
|
||||
const quint16 iPortNumber )
|
||||
{
|
||||
// we have to register some classes to the Qt signal/slot mechanism
|
||||
// since we have thread crossings with the threaded code
|
||||
qRegisterMetaType<CVector<uint8_t> > ( "CVector<uint8_t>" );
|
||||
qRegisterMetaType<CHostAddress> ( "CHostAddress" );
|
||||
|
||||
// Creation of the new socket thread which has to have the highest
|
||||
// possible thread priority to make sure the jitter buffer is reliably
|
||||
// filled with the network audio packets and does not get interrupted
|
||||
|
@ -143,7 +138,7 @@ public:
|
|||
|
||||
bool GetAndResetbJitterBufferOKFlag()
|
||||
{
|
||||
pSocket->GetAndResetbJitterBufferOKFlag();
|
||||
return pSocket->GetAndResetbJitterBufferOKFlag();
|
||||
}
|
||||
|
||||
protected:
|
||||
|
|
Loading…
Reference in a new issue