some renamings, store actual frame size factor

This commit is contained in:
Volker Fischer 2009-08-13 18:59:14 +00:00
parent d7781e160f
commit 94c27493c2
5 changed files with 31 additions and 26 deletions

View file

@ -36,7 +36,8 @@ CClient::CClient ( const quint16 iPortNumber ) :
vstrIPAddress ( MAX_NUM_SERVER_ADDR_ITEMS, "" ), strName ( "" ), vstrIPAddress ( MAX_NUM_SERVER_ADDR_ITEMS, "" ), strName ( "" ),
bOpenChatOnNewMessage ( true ), bOpenChatOnNewMessage ( true ),
bDoAutoSockBufSize ( true ), bDoAutoSockBufSize ( true ),
iSndCrdPrefMonoFrameSizeFactor ( FRAME_SIZE_FACTOR_DEFAULT ) iSndCrdPrefFrameSizeFactor ( FRAME_SIZE_FACTOR_DEFAULT ),
iSndCrdFrameSizeFactor ( FRAME_SIZE_FACTOR_DEFAULT )
{ {
// init audio endocder/decoder (mono) // init audio endocder/decoder (mono)
CeltMode = celt_mode_create ( CeltMode = celt_mode_create (
@ -154,7 +155,7 @@ bool CClient::SetServerAddr ( QString strNAddr )
return true; return true;
} }
void CClient::SetSndCrdPrefMonoFrameSizeFactor ( const int iNewFactor ) void CClient::SetSndCrdPrefFrameSizeFactor ( const int iNewFactor )
{ {
// right now we simply set the internal value // right now we simply set the internal value
if ( ( iNewFactor == FRAME_SIZE_FACTOR_PREFERRED ) || if ( ( iNewFactor == FRAME_SIZE_FACTOR_PREFERRED ) ||
@ -170,7 +171,7 @@ void CClient::SetSndCrdPrefMonoFrameSizeFactor ( const int iNewFactor )
} }
// set new parameter // set new parameter
iSndCrdPrefMonoFrameSizeFactor = iNewFactor; iSndCrdPrefFrameSizeFactor = iNewFactor;
// init with new block size index parameter // init with new block size index parameter
Init(); Init();
@ -272,12 +273,19 @@ void CClient::Init()
{ {
// translate block size index in actual block size // translate block size index in actual block size
const int iPrefMonoFrameSize = const int iPrefMonoFrameSize =
iSndCrdPrefMonoFrameSizeFactor * SYSTEM_FRAME_SIZE_SAMPLES; iSndCrdPrefFrameSizeFactor * SYSTEM_FRAME_SIZE_SAMPLES;
// get actual sound card buffer size using preferred size // get actual sound card buffer size using preferred size
iMonoBlockSizeSam = Sound.Init ( iPrefMonoFrameSize ); iMonoBlockSizeSam = Sound.Init ( iPrefMonoFrameSize );
iStereoBlockSizeSam = 2 * iMonoBlockSizeSam; iStereoBlockSizeSam = 2 * iMonoBlockSizeSam;
// TEST
// calculate actual frame size factor
iSndCrdFrameSizeFactor = iMonoBlockSizeSam / SYSTEM_FRAME_SIZE_SAMPLES;
vecsAudioSndCrdMono.Init ( iMonoBlockSizeSam ); vecsAudioSndCrdMono.Init ( iMonoBlockSizeSam );
vecsAudioSndCrdStereo.Init ( iStereoBlockSizeSam ); vecsAudioSndCrdStereo.Init ( iStereoBlockSizeSam );
vecdAudioStereo.Init ( iStereoBlockSizeSam ); vecdAudioStereo.Init ( iStereoBlockSizeSam );
@ -302,11 +310,8 @@ void CClient::Init()
vecbyNetwData.Init ( iCeltNumCodedBytes ); vecbyNetwData.Init ( iCeltNumCodedBytes );
// set the channel network properties // set the channel network properties
// TODO use the actual frame size factor if possible...
Channel.SetNetwFrameSizeAndFact ( iCeltNumCodedBytes, Channel.SetNetwFrameSizeAndFact ( iCeltNumCodedBytes,
iSndCrdPrefMonoFrameSizeFactor ); iSndCrdFrameSizeFactor );
} }
void CClient::ProcessAudioData ( CVector<int16_t>& vecsStereoSndCrd ) void CClient::ProcessAudioData ( CVector<int16_t>& vecsStereoSndCrd )
@ -391,7 +396,7 @@ void CClient::ProcessAudioData ( CVector<int16_t>& vecsStereoSndCrd )
// TEST // TEST
// TODO use actual frame size factor, not preferred one!!!! // TODO use actual frame size factor, not preferred one!!!!
for ( i = 0; i < iSndCrdPrefMonoFrameSizeFactor; i++ ) for ( i = 0; i < iSndCrdFrameSizeFactor; i++ )
{ {
// encode current audio frame with CELT encoder // encode current audio frame with CELT encoder
celt_encode ( CeltEncoder, celt_encode ( CeltEncoder,
@ -410,7 +415,7 @@ void CClient::ProcessAudioData ( CVector<int16_t>& vecsStereoSndCrd )
// TEST // TEST
// TODO use actual frame size factor, not preferred one!!!! // TODO use actual frame size factor, not preferred one!!!!
for ( i = 0; i < iSndCrdPrefMonoFrameSizeFactor; i++ ) for ( i = 0; i < iSndCrdFrameSizeFactor; i++ )
{ {
// receive a new block // receive a new block
const bool bReceiveDataOk = const bool bReceiveDataOk =

View file

@ -119,9 +119,9 @@ public:
int GetSndCrdDev() { return Sound.GetDev(); } int GetSndCrdDev() { return Sound.GetDev(); }
void OpenSndCrdDriverSetup() { Sound.OpenDriverSetup(); } void OpenSndCrdDriverSetup() { Sound.OpenDriverSetup(); }
void SetSndCrdPrefMonoFrameSizeFactor ( const int iNewFactor ); void SetSndCrdPrefFrameSizeFactor ( const int iNewFactor );
int GetSndCrdPrefMonoFrameSizeFactor() int GetSndCrdPrefFrameSizeFactor()
{ return iSndCrdPrefMonoFrameSizeFactor; } { return iSndCrdPrefFrameSizeFactor; }
int GetSndCrdActualMonoBlSize() { return iMonoBlockSizeSam; } int GetSndCrdActualMonoBlSize() { return iMonoBlockSizeSam; }
void SetRemoteChanGain ( const int iId, const double dGain ) void SetRemoteChanGain ( const int iId, const double dGain )
@ -172,7 +172,8 @@ protected:
int iReverbLevel; int iReverbLevel;
CAudioReverb AudioReverb; CAudioReverb AudioReverb;
int iSndCrdPrefMonoFrameSizeFactor; int iSndCrdPrefFrameSizeFactor;
int iSndCrdFrameSizeFactor;
int iMonoBlockSizeSam; int iMonoBlockSizeSam;
int iStereoBlockSizeSam; int iStereoBlockSizeSam;

View file

@ -169,7 +169,7 @@ void CClientSettingsDlg::UpdateSoundCardFrame()
{ {
// update slider value and text // update slider value and text
const int iCurPrefFrameSizeFactor = const int iCurPrefFrameSizeFactor =
pClient->GetSndCrdPrefMonoFrameSizeFactor(); pClient->GetSndCrdPrefFrameSizeFactor();
const int iCurActualBufSize = const int iCurActualBufSize =
pClient->GetSndCrdActualMonoBlSize(); pClient->GetSndCrdActualMonoBlSize();
@ -236,7 +236,7 @@ void CClientSettingsDlg::OnSliderNetBuf ( int value )
void CClientSettingsDlg::OnSliderSndCrdBufferDelay ( int value ) void CClientSettingsDlg::OnSliderSndCrdBufferDelay ( int value )
{ {
pClient->SetSndCrdPrefMonoFrameSizeFactor ( value ); pClient->SetSndCrdPrefFrameSizeFactor ( value );
UpdateDisplay(); UpdateDisplay();
} }
@ -273,17 +273,17 @@ void CClientSettingsDlg::OnSndCrdBufferDelayButtonGroupClicked ( QAbstractButton
{ {
if ( button == rButBufferDelayPreferred ) if ( button == rButBufferDelayPreferred )
{ {
pClient->SetSndCrdPrefMonoFrameSizeFactor ( FRAME_SIZE_FACTOR_PREFERRED ); pClient->SetSndCrdPrefFrameSizeFactor ( FRAME_SIZE_FACTOR_PREFERRED );
} }
if ( button == rButBufferDelayDefault ) if ( button == rButBufferDelayDefault )
{ {
pClient->SetSndCrdPrefMonoFrameSizeFactor ( FRAME_SIZE_FACTOR_DEFAULT ); pClient->SetSndCrdPrefFrameSizeFactor ( FRAME_SIZE_FACTOR_DEFAULT );
} }
if ( button == rButBufferDelaySafe ) if ( button == rButBufferDelaySafe )
{ {
pClient->SetSndCrdPrefMonoFrameSizeFactor ( FRAME_SIZE_FACTOR_SAFE ); pClient->SetSndCrdPrefFrameSizeFactor ( FRAME_SIZE_FACTOR_SAFE );
} }
UpdateDisplay(); UpdateDisplay();
@ -317,7 +317,7 @@ void CClientSettingsDlg::OnPingTimeResult ( int iPingTime )
const double dDelayToFillNetworkPackets = const double dDelayToFillNetworkPackets =
SYSTEM_BLOCK_DURATION_MS_FLOAT * SYSTEM_BLOCK_DURATION_MS_FLOAT *
pClient->GetSndCrdPrefMonoFrameSizeFactor(); pClient->GetSndCrdPrefFrameSizeFactor();
// CELT additional delay at small frame sizes is half a frame size // CELT additional delay at small frame sizes is half a frame size
const double dAdditionalAudioCodecDelay = const double dAdditionalAudioCodecDelay =

View file

@ -294,11 +294,10 @@ void CServer::OnTimer()
CVector<CVector<double> > vecvecdGains; CVector<CVector<double> > vecvecdGains;
CVector<CVector<int16_t> > vecvecsData; CVector<CVector<int16_t> > vecvecsData;
// Get data from all connected clients -------------------------------------
// get data from all connected clients -------------------------------------
bool bChannelIsNowDisconnected = false; bool bChannelIsNowDisconnected = false;
// make put and get calls thread safe. Do not forget to unlock mutex // Make put and get calls thread safe. Do not forget to unlock mutex
// afterwards! // afterwards!
Mutex.lock(); Mutex.lock();
{ {
@ -399,7 +398,7 @@ void CServer::OnTimer()
const int iNumClients = vecChanID.Size(); const int iNumClients = vecChanID.Size();
// Check if at least one client is connected. If not, stop server until // Check if at least one client is connected. If not, stop server until
// one client is connected // one client is connected.
if ( iNumClients != 0 ) if ( iNumClients != 0 )
{ {
for ( int i = 0; i < iNumClients; i++ ) for ( int i = 0; i < iNumClients; i++ )

View file

@ -118,7 +118,7 @@ void CSettings::ReadIniFile ( const QString& sFileName )
( iValue == FRAME_SIZE_FACTOR_DEFAULT ) || ( iValue == FRAME_SIZE_FACTOR_DEFAULT ) ||
( iValue == FRAME_SIZE_FACTOR_SAFE ) ) ( iValue == FRAME_SIZE_FACTOR_SAFE ) )
{ {
pClient->SetSndCrdPrefMonoFrameSizeFactor ( iValue ); pClient->SetSndCrdPrefFrameSizeFactor ( iValue );
} }
} }
@ -179,7 +179,7 @@ void CSettings::WriteIniFile ( const QString& sFileName )
// sound card preferred buffer size index // sound card preferred buffer size index
SetNumericIniSet ( IniXMLDocument, "client", "prefsndcrdbufidx", SetNumericIniSet ( IniXMLDocument, "client", "prefsndcrdbufidx",
pClient->GetSndCrdPrefMonoFrameSizeFactor() ); pClient->GetSndCrdPrefFrameSizeFactor() );
// automatic network jitter buffer size setting // automatic network jitter buffer size setting
SetFlagIniSet ( IniXMLDocument, "client", "autojitbuf", SetFlagIniSet ( IniXMLDocument, "client", "autojitbuf",