fix for high prio socket
This commit is contained in:
parent
4b83fa6fe0
commit
e5aedf6998
4 changed files with 37 additions and 8 deletions
|
@ -51,8 +51,10 @@ CChannel::CChannel ( const bool bNIsServer ) :
|
||||||
|
|
||||||
|
|
||||||
// Connections -------------------------------------------------------------
|
// Connections -------------------------------------------------------------
|
||||||
qRegisterMetaType<CVector<uint8_t> > ( "CVector<uint8_t>" );
|
|
||||||
qRegisterMetaType<CHostAddress> ( "CHostAddress" );
|
// 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" );
|
||||||
|
|
||||||
QObject::connect ( &Protocol,
|
QObject::connect ( &Protocol,
|
||||||
SIGNAL ( MessReadyForSending ( CVector<uint8_t> ) ),
|
SIGNAL ( MessReadyForSending ( CVector<uint8_t> ) ),
|
||||||
|
@ -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
|
// fire a signal so that an other class can process this type of
|
||||||
// message
|
// message
|
||||||
|
// TODO a copy of the vector is used -> avoid malloc in real-time routine
|
||||||
emit DetectedCLMessage ( vecbyMesBodyData, iRecID );
|
emit DetectedCLMessage ( vecbyMesBodyData, iRecID );
|
||||||
|
|
||||||
// set status flag
|
// set status flag
|
||||||
|
@ -485,6 +488,7 @@ EPutDataStat CChannel::PutData ( const CVector<uint8_t>& vecbyData,
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
// parse the message assuming this is a regular protocol message
|
// 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 );
|
emit ParseMessageBody ( vecbyMesBodyData, iRecCounter, iRecID );
|
||||||
|
|
||||||
// note that protocol OK is not correct here since we do not
|
// 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;
|
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,
|
void CChannel::PrepAndSendPacket ( CSocket* pSocket,
|
||||||
const CVector<uint8_t>& vecbyNPacket,
|
const CVector<uint8_t>& vecbyNPacket,
|
||||||
const int iNPacketLen )
|
const int iNPacketLen )
|
||||||
|
|
|
@ -68,10 +68,17 @@ public:
|
||||||
EGetDataStat GetData ( CVector<uint8_t>& vecbyData,
|
EGetDataStat GetData ( CVector<uint8_t>& vecbyData,
|
||||||
const int iNumBytes );
|
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,
|
void PrepAndSendPacket ( CSocket* pSocket,
|
||||||
const CVector<uint8_t>& vecbyNPacket,
|
const CVector<uint8_t>& vecbyNPacket,
|
||||||
const int iNPacketLen );
|
const int iNPacketLen );
|
||||||
|
|
||||||
|
|
||||||
void ResetTimeOutCounter() { iConTimeOut = iConTimeOutStartVal; }
|
void ResetTimeOutCounter() { iConTimeOut = iConTimeOutStartVal; }
|
||||||
bool IsConnected() const { return iConTimeOut > 0; }
|
bool IsConnected() const { return iConTimeOut > 0; }
|
||||||
void Disconnect();
|
void Disconnect();
|
||||||
|
|
|
@ -1093,9 +1093,15 @@ void CClient::ProcessAudioDataIntern ( CVector<int16_t>& vecsStereoSndCrd )
|
||||||
}
|
}
|
||||||
|
|
||||||
// send coded audio through the network
|
// send coded audio through the network
|
||||||
|
#ifdef ENABLE_RECEIVE_SOCKET_IN_SEPARATE_THREAD
|
||||||
|
Channel.PrepAndSendPacketHPS ( &Socket,
|
||||||
|
vecCeltData,
|
||||||
|
iCeltNumCodedBytes );
|
||||||
|
#else
|
||||||
Channel.PrepAndSendPacket ( &Socket,
|
Channel.PrepAndSendPacket ( &Socket,
|
||||||
vecCeltData,
|
vecCeltData,
|
||||||
iCeltNumCodedBytes );
|
iCeltNumCodedBytes );
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -110,11 +110,6 @@ public:
|
||||||
CHighPrioSocket ( CChannel* pNewChannel,
|
CHighPrioSocket ( CChannel* pNewChannel,
|
||||||
const quint16 iPortNumber )
|
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
|
// Creation of the new socket thread which has to have the highest
|
||||||
// possible thread priority to make sure the jitter buffer is reliably
|
// possible thread priority to make sure the jitter buffer is reliably
|
||||||
// filled with the network audio packets and does not get interrupted
|
// filled with the network audio packets and does not get interrupted
|
||||||
|
@ -143,7 +138,7 @@ public:
|
||||||
|
|
||||||
bool GetAndResetbJitterBufferOKFlag()
|
bool GetAndResetbJitterBufferOKFlag()
|
||||||
{
|
{
|
||||||
pSocket->GetAndResetbJitterBufferOKFlag();
|
return pSocket->GetAndResetbJitterBufferOKFlag();
|
||||||
}
|
}
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
|
|
Loading…
Reference in a new issue