small improvement for the mutexes
This commit is contained in:
parent
9e4dbd861a
commit
e004ed6964
1 changed files with 25 additions and 17 deletions
|
@ -154,8 +154,6 @@ 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;
|
||||||
|
@ -163,18 +161,24 @@ void CChannel::SetAudioStreamProperties ( const EAudComprType eNewAudComprType,
|
||||||
iNetwFrameSize = iNewNetwFrameSize;
|
iNetwFrameSize = iNewNetwFrameSize;
|
||||||
iNetwFrameSizeFact = iNewNetwFrameSizeFact;
|
iNetwFrameSizeFact = iNewNetwFrameSizeFact;
|
||||||
|
|
||||||
// init socket buffer
|
MutexSocketBuf.lock();
|
||||||
SockBuf.Init ( iNetwFrameSize, iCurSockBufNumFrames );
|
{
|
||||||
|
// init socket buffer
|
||||||
|
SockBuf.Init ( iNetwFrameSize, iCurSockBufNumFrames );
|
||||||
|
}
|
||||||
|
MutexSocketBuf.unlock();
|
||||||
|
|
||||||
// init conversion buffer
|
MutexConvBuf.lock();
|
||||||
ConvBuf.Init ( iNetwFrameSize * iNetwFrameSizeFact );
|
{
|
||||||
|
// init conversion buffer
|
||||||
|
ConvBuf.Init ( iNetwFrameSize * iNetwFrameSizeFact );
|
||||||
|
}
|
||||||
|
MutexConvBuf.unlock();
|
||||||
|
|
||||||
// fill network transport properties struct
|
// fill network transport properties struct
|
||||||
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
|
||||||
|
@ -377,8 +381,6 @@ 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;
|
||||||
|
@ -387,15 +389,21 @@ void CChannel::OnNetTranspPropsReceived ( CNetworkTransportProps NetworkTranspor
|
||||||
iNetwFrameSize =
|
iNetwFrameSize =
|
||||||
NetworkTransportProps.iBaseNetworkPacketSize;
|
NetworkTransportProps.iBaseNetworkPacketSize;
|
||||||
|
|
||||||
// update socket buffer (the network block size is a multiple of the
|
MutexSocketBuf.lock();
|
||||||
// minimum network frame size
|
{
|
||||||
SockBuf.Init ( iNetwFrameSize, iCurSockBufNumFrames );
|
// update socket buffer (the network block size is a multiple of the
|
||||||
|
// minimum network frame size
|
||||||
|
SockBuf.Init ( iNetwFrameSize, iCurSockBufNumFrames );
|
||||||
|
}
|
||||||
|
MutexSocketBuf.unlock();
|
||||||
|
|
||||||
// init conversion buffer
|
MutexConvBuf.lock();
|
||||||
ConvBuf.Init ( iNetwFrameSize * iNetwFrameSizeFact );
|
{
|
||||||
|
// init conversion buffer
|
||||||
|
ConvBuf.Init ( iNetwFrameSize * iNetwFrameSizeFact );
|
||||||
|
}
|
||||||
|
MutexConvBuf.unlock();
|
||||||
}
|
}
|
||||||
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
|
||||||
|
|
Loading…
Reference in a new issue