- take care of NewConnection message in the socket context
- some changes in the Mutexs
This commit is contained in:
parent
4837dc88d4
commit
033e3adca4
1 changed files with 19 additions and 12 deletions
|
@ -162,6 +162,8 @@ void CChannel::SetAudioStreamProperties ( const EAudComprType eNewAudComprType,
|
||||||
CNetworkTransportProps NetworkTransportProps;
|
CNetworkTransportProps NetworkTransportProps;
|
||||||
|
|
||||||
Mutex.lock();
|
Mutex.lock();
|
||||||
|
MutexSocketBuf.lock();
|
||||||
|
MutexConvBuf.lock();
|
||||||
{
|
{
|
||||||
// store new values
|
// store new values
|
||||||
eAudioCompressionType = eNewAudComprType;
|
eAudioCompressionType = eNewAudComprType;
|
||||||
|
@ -179,6 +181,8 @@ void CChannel::SetAudioStreamProperties ( const EAudComprType eNewAudComprType,
|
||||||
NetworkTransportProps =
|
NetworkTransportProps =
|
||||||
GetNetworkTransportPropsFromCurrentSettings();
|
GetNetworkTransportPropsFromCurrentSettings();
|
||||||
}
|
}
|
||||||
|
MutexConvBuf.unlock();
|
||||||
|
MutexSocketBuf.unlock();
|
||||||
Mutex.unlock();
|
Mutex.unlock();
|
||||||
|
|
||||||
// tell the server about the new network settings
|
// tell the server about the new network settings
|
||||||
|
@ -198,7 +202,7 @@ bool CChannel::SetSockBufNumFrames ( const int iNewNumFrames,
|
||||||
// only apply parameter if new parameter is different from current one
|
// only apply parameter if new parameter is different from current one
|
||||||
if ( iCurSockBufNumFrames != iNewNumFrames )
|
if ( iCurSockBufNumFrames != iNewNumFrames )
|
||||||
{
|
{
|
||||||
Mutex.lock();
|
MutexSocketBuf.lock();
|
||||||
{
|
{
|
||||||
// store new value
|
// store new value
|
||||||
iCurSockBufNumFrames = iNewNumFrames;
|
iCurSockBufNumFrames = iNewNumFrames;
|
||||||
|
@ -216,7 +220,7 @@ bool CChannel::SetSockBufNumFrames ( const int iNewNumFrames,
|
||||||
|
|
||||||
ReturnValue = false; // -> no error
|
ReturnValue = false; // -> no error
|
||||||
}
|
}
|
||||||
Mutex.unlock();
|
MutexSocketBuf.unlock();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -381,6 +385,8 @@ void CChannel::OnNetTranspPropsReceived ( CNetworkTransportProps NetworkTranspor
|
||||||
if ( bIsServer )
|
if ( bIsServer )
|
||||||
{
|
{
|
||||||
Mutex.lock();
|
Mutex.lock();
|
||||||
|
MutexSocketBuf.lock();
|
||||||
|
MutexConvBuf.lock();
|
||||||
{
|
{
|
||||||
// store received parameters
|
// store received parameters
|
||||||
eAudioCompressionType = NetworkTransportProps.eAudioCodingType;
|
eAudioCompressionType = NetworkTransportProps.eAudioCodingType;
|
||||||
|
@ -396,6 +402,8 @@ void CChannel::OnNetTranspPropsReceived ( CNetworkTransportProps NetworkTranspor
|
||||||
// init conversion buffer
|
// init conversion buffer
|
||||||
ConvBuf.Init ( iNetwFrameSize * iNetwFrameSizeFact );
|
ConvBuf.Init ( iNetwFrameSize * iNetwFrameSizeFact );
|
||||||
}
|
}
|
||||||
|
MutexConvBuf.unlock();
|
||||||
|
MutexSocketBuf.unlock();
|
||||||
Mutex.unlock();
|
Mutex.unlock();
|
||||||
|
|
||||||
// if old CELT codec is used, inform the client that the new OPUS codec
|
// if old CELT codec is used, inform the client that the new OPUS codec
|
||||||
|
@ -531,7 +539,7 @@ EPutDataStat CChannel::PutData ( const CVector<uint8_t>& vecbyData,
|
||||||
// This seems to be an audio packet (only try to parse audio if it
|
// This seems to be an audio packet (only try to parse audio if it
|
||||||
// was not a protocol packet):
|
// was not a protocol packet):
|
||||||
|
|
||||||
Mutex.lock();
|
MutexSocketBuf.lock();
|
||||||
{
|
{
|
||||||
// only process audio if packet has correct size
|
// only process audio if packet has correct size
|
||||||
if ( iNumBytes == ( iNetwFrameSize * iNetwFrameSizeFact ) )
|
if ( iNumBytes == ( iNetwFrameSize * iNetwFrameSizeFact ) )
|
||||||
|
@ -568,18 +576,17 @@ EPutDataStat CChannel::PutData ( const CVector<uint8_t>& vecbyData,
|
||||||
// reset time-out counter
|
// reset time-out counter
|
||||||
ResetTimeOutCounter();
|
ResetTimeOutCounter();
|
||||||
}
|
}
|
||||||
Mutex.unlock();
|
MutexSocketBuf.unlock();
|
||||||
}
|
}
|
||||||
|
|
||||||
if ( bNewConnection )
|
if ( bNewConnection )
|
||||||
{
|
{
|
||||||
// inform other objects that new connection was established
|
// inform other objects that new connection was established
|
||||||
|
|
||||||
#ifdef ENABLE_RECEIVE_SOCKET_IN_SEPARATE_THREAD
|
#ifdef ENABLE_RECEIVE_SOCKET_IN_SEPARATE_THREAD
|
||||||
// TODO socket thread???
|
pSocket->EmitNewConnection();
|
||||||
#endif
|
#else
|
||||||
|
|
||||||
emit NewConnection();
|
emit NewConnection();
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -591,7 +598,7 @@ EGetDataStat CChannel::GetData ( CVector<uint8_t>& vecbyData,
|
||||||
{
|
{
|
||||||
EGetDataStat eGetStatus;
|
EGetDataStat eGetStatus;
|
||||||
|
|
||||||
Mutex.lock();
|
MutexSocketBuf.lock();
|
||||||
{
|
{
|
||||||
// the socket access must be inside a mutex
|
// the socket access must be inside a mutex
|
||||||
const bool bSockBufState = SockBuf.Get ( vecbyData, iNumBytes );
|
const bool bSockBufState = SockBuf.Get ( vecbyData, iNumBytes );
|
||||||
|
@ -638,7 +645,7 @@ EGetDataStat CChannel::GetData ( CVector<uint8_t>& vecbyData,
|
||||||
eGetStatus = GS_CHAN_NOT_CONNECTED;
|
eGetStatus = GS_CHAN_NOT_CONNECTED;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
Mutex.unlock();
|
MutexSocketBuf.unlock();
|
||||||
|
|
||||||
// in case we are just disconnected, we have to fire a message
|
// in case we are just disconnected, we have to fire a message
|
||||||
if ( eGetStatus == GS_CHAN_NOW_DISCONNECTED )
|
if ( eGetStatus == GS_CHAN_NOW_DISCONNECTED )
|
||||||
|
@ -656,7 +663,7 @@ void CChannel::PrepAndSendPacketHPS ( CHighPrioSocket* pSocket,
|
||||||
const int iNPacketLen )
|
const int iNPacketLen )
|
||||||
{
|
{
|
||||||
// TODO Doubled code!!! Same code as in PrepAndSendPacket (see below)!!!
|
// TODO Doubled code!!! Same code as in PrepAndSendPacket (see below)!!!
|
||||||
QMutexLocker locker ( &Mutex );
|
QMutexLocker locker ( &MutexConvBuf );
|
||||||
|
|
||||||
// use conversion buffer to convert sound card block size in network
|
// use conversion buffer to convert sound card block size in network
|
||||||
// block size
|
// block size
|
||||||
|
@ -671,7 +678,7 @@ void CChannel::PrepAndSendPacket ( CSocket* pSocket,
|
||||||
const CVector<uint8_t>& vecbyNPacket,
|
const CVector<uint8_t>& vecbyNPacket,
|
||||||
const int iNPacketLen )
|
const int iNPacketLen )
|
||||||
{
|
{
|
||||||
QMutexLocker locker ( &Mutex );
|
QMutexLocker locker ( &MutexConvBuf );
|
||||||
|
|
||||||
// use conversion buffer to convert sound card block size in network
|
// use conversion buffer to convert sound card block size in network
|
||||||
// block size
|
// block size
|
||||||
|
|
Loading…
Reference in a new issue