fix for mutex in channel object
This commit is contained in:
parent
10aea73304
commit
c064b49576
3 changed files with 58 additions and 34 deletions
|
@ -36,7 +36,7 @@
|
||||||
|
|
||||||
// the number of periods is critical for latency
|
// the number of periods is critical for latency
|
||||||
#define NUM_PERIOD_BLOCKS_IN 2
|
#define NUM_PERIOD_BLOCKS_IN 2
|
||||||
#define NUM_PERIOD_BLOCKS_OUT 2
|
#define NUM_PERIOD_BLOCKS_OUT 1
|
||||||
|
|
||||||
#define MAX_SND_BUF_IN 200
|
#define MAX_SND_BUF_IN 200
|
||||||
#define MAX_SND_BUF_OUT 200
|
#define MAX_SND_BUF_OUT 200
|
||||||
|
|
|
@ -914,7 +914,6 @@ void CChannel::OnNetTranspPropsReceived ( CNetworkTransportProps NetworkTranspor
|
||||||
QMutexLocker locker ( &Mutex );
|
QMutexLocker locker ( &Mutex );
|
||||||
|
|
||||||
// TEST
|
// TEST
|
||||||
// TODO use mutex in Put function
|
|
||||||
// TODO check possiblity of received parameter -> error checking
|
// TODO check possiblity of received parameter -> error checking
|
||||||
// utilize, e.g., MAX_MONO_AUD_BUFF_SIZE_AT_48KHZ
|
// utilize, e.g., MAX_MONO_AUD_BUFF_SIZE_AT_48KHZ
|
||||||
vecNetwBufferInProps[0].iAudioBlockSize = NetworkTransportProps.iMonoAudioBlockSize;
|
vecNetwBufferInProps[0].iAudioBlockSize = NetworkTransportProps.iMonoAudioBlockSize;
|
||||||
|
@ -955,6 +954,12 @@ EPutDataStat CChannel::PutData ( const CVector<unsigned char>& vecbyData,
|
||||||
bool bIsProtocolPacket = false;
|
bool bIsProtocolPacket = false;
|
||||||
bool bIsAudioPacket = false;
|
bool bIsAudioPacket = false;
|
||||||
bool bNewConnection = false;
|
bool bNewConnection = false;
|
||||||
|
bool bReinitializeIn = false;
|
||||||
|
bool bReinitializeOut = false;
|
||||||
|
|
||||||
|
// intermediate storage for new parameters
|
||||||
|
int iNewAudioBlockSize;
|
||||||
|
EAudComprType eNewAudComprType;
|
||||||
|
|
||||||
if ( bIsEnabled )
|
if ( bIsEnabled )
|
||||||
{
|
{
|
||||||
|
@ -973,6 +978,8 @@ EPutDataStat CChannel::PutData ( const CVector<unsigned char>& vecbyData,
|
||||||
|
|
||||||
// only try to parse audio if it was not a protocol packet
|
// only try to parse audio if it was not a protocol packet
|
||||||
if ( !bIsProtocolPacket )
|
if ( !bIsProtocolPacket )
|
||||||
|
{
|
||||||
|
Mutex.lock();
|
||||||
{
|
{
|
||||||
// check if this is an audio packet by checking all possible lengths
|
// check if this is an audio packet by checking all possible lengths
|
||||||
const int iPossNetwSizes = vecNetwBufferInProps.Size();
|
const int iPossNetwSizes = vecNetwBufferInProps.Size();
|
||||||
|
@ -985,31 +992,48 @@ EPutDataStat CChannel::PutData ( const CVector<unsigned char>& vecbyData,
|
||||||
bIsAudioPacket = true;
|
bIsAudioPacket = true;
|
||||||
|
|
||||||
// check if we are correctly initialized
|
// check if we are correctly initialized
|
||||||
const int iNewAudioBlockSize =
|
iNewAudioBlockSize =
|
||||||
vecNetwBufferInProps[i].iAudioBlockSize;
|
vecNetwBufferInProps[i].iAudioBlockSize;
|
||||||
|
|
||||||
const EAudComprType eNewAudComprType =
|
eNewAudComprType =
|
||||||
vecNetwBufferInProps[i].eAudComprType;
|
vecNetwBufferInProps[i].eAudComprType;
|
||||||
|
|
||||||
if ( ( iNewAudioBlockSize != iCurAudioBlockSizeIn ) ||
|
if ( ( iNewAudioBlockSize != iCurAudioBlockSizeIn ) ||
|
||||||
( eNewAudComprType != AudioCompressionIn.GetType() ) )
|
( eNewAudComprType != AudioCompressionIn.GetType() ) )
|
||||||
{
|
{
|
||||||
// re-initialize to new value
|
bReinitializeIn = true;
|
||||||
SetAudioBlockSizeAndComprIn (
|
|
||||||
iNewAudioBlockSize, eNewAudComprType );
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// in case of a server channel, use the same audio
|
// in case of a server channel, use the same audio
|
||||||
// compression for output as for the input
|
// compression for output as for the input
|
||||||
if ( bIsServer )
|
if ( bIsServer )
|
||||||
{
|
{
|
||||||
if ( GetAudioCompressionOut() != vecNetwBufferInProps[i].eAudComprType )
|
if ( GetAudioCompressionOut() != eNewAudComprType )
|
||||||
{
|
{
|
||||||
SetAudioCompressionOut ( vecNetwBufferInProps[i].eAudComprType );
|
bReinitializeOut = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Mutex.unlock();
|
||||||
|
|
||||||
|
// actual initialization calls have to be made
|
||||||
|
// outside the mutex region since they internally
|
||||||
|
// use the same mutex, too
|
||||||
|
if ( bReinitializeIn )
|
||||||
|
{
|
||||||
|
// re-initialize to new value
|
||||||
|
SetAudioBlockSizeAndComprIn (
|
||||||
|
iNewAudioBlockSize, eNewAudComprType );
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
if ( bReinitializeOut )
|
||||||
|
{
|
||||||
|
SetAudioCompressionOut ( eNewAudComprType );
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
Mutex.lock();
|
Mutex.lock();
|
||||||
{
|
{
|
||||||
|
|
|
@ -161,7 +161,7 @@ void CClient::Start()
|
||||||
// init object
|
// init object
|
||||||
|
|
||||||
// TEST
|
// TEST
|
||||||
Init ( 192 );
|
Init ( 256 );
|
||||||
|
|
||||||
// enable channel
|
// enable channel
|
||||||
Channel.SetEnable ( true );
|
Channel.SetEnable ( true );
|
||||||
|
|
Loading…
Reference in a new issue