some renamings, store actual frame size factor
This commit is contained in:
parent
d7781e160f
commit
94c27493c2
5 changed files with 31 additions and 26 deletions
|
@ -36,7 +36,8 @@ CClient::CClient ( const quint16 iPortNumber ) :
|
|||
vstrIPAddress ( MAX_NUM_SERVER_ADDR_ITEMS, "" ), strName ( "" ),
|
||||
bOpenChatOnNewMessage ( true ),
|
||||
bDoAutoSockBufSize ( true ),
|
||||
iSndCrdPrefMonoFrameSizeFactor ( FRAME_SIZE_FACTOR_DEFAULT )
|
||||
iSndCrdPrefFrameSizeFactor ( FRAME_SIZE_FACTOR_DEFAULT ),
|
||||
iSndCrdFrameSizeFactor ( FRAME_SIZE_FACTOR_DEFAULT )
|
||||
{
|
||||
// init audio endocder/decoder (mono)
|
||||
CeltMode = celt_mode_create (
|
||||
|
@ -154,7 +155,7 @@ bool CClient::SetServerAddr ( QString strNAddr )
|
|||
return true;
|
||||
}
|
||||
|
||||
void CClient::SetSndCrdPrefMonoFrameSizeFactor ( const int iNewFactor )
|
||||
void CClient::SetSndCrdPrefFrameSizeFactor ( const int iNewFactor )
|
||||
{
|
||||
// right now we simply set the internal value
|
||||
if ( ( iNewFactor == FRAME_SIZE_FACTOR_PREFERRED ) ||
|
||||
|
@ -170,7 +171,7 @@ void CClient::SetSndCrdPrefMonoFrameSizeFactor ( const int iNewFactor )
|
|||
}
|
||||
|
||||
// set new parameter
|
||||
iSndCrdPrefMonoFrameSizeFactor = iNewFactor;
|
||||
iSndCrdPrefFrameSizeFactor = iNewFactor;
|
||||
|
||||
// init with new block size index parameter
|
||||
Init();
|
||||
|
@ -272,12 +273,19 @@ void CClient::Init()
|
|||
{
|
||||
// translate block size index in actual block size
|
||||
const int iPrefMonoFrameSize =
|
||||
iSndCrdPrefMonoFrameSizeFactor * SYSTEM_FRAME_SIZE_SAMPLES;
|
||||
iSndCrdPrefFrameSizeFactor * SYSTEM_FRAME_SIZE_SAMPLES;
|
||||
|
||||
// get actual sound card buffer size using preferred size
|
||||
iMonoBlockSizeSam = Sound.Init ( iPrefMonoFrameSize );
|
||||
iStereoBlockSizeSam = 2 * iMonoBlockSizeSam;
|
||||
|
||||
|
||||
// TEST
|
||||
// calculate actual frame size factor
|
||||
iSndCrdFrameSizeFactor = iMonoBlockSizeSam / SYSTEM_FRAME_SIZE_SAMPLES;
|
||||
|
||||
|
||||
|
||||
vecsAudioSndCrdMono.Init ( iMonoBlockSizeSam );
|
||||
vecsAudioSndCrdStereo.Init ( iStereoBlockSizeSam );
|
||||
vecdAudioStereo.Init ( iStereoBlockSizeSam );
|
||||
|
@ -302,11 +310,8 @@ void CClient::Init()
|
|||
vecbyNetwData.Init ( iCeltNumCodedBytes );
|
||||
|
||||
// set the channel network properties
|
||||
|
||||
// TODO use the actual frame size factor if possible...
|
||||
|
||||
Channel.SetNetwFrameSizeAndFact ( iCeltNumCodedBytes,
|
||||
iSndCrdPrefMonoFrameSizeFactor );
|
||||
iSndCrdFrameSizeFactor );
|
||||
}
|
||||
|
||||
void CClient::ProcessAudioData ( CVector<int16_t>& vecsStereoSndCrd )
|
||||
|
@ -391,7 +396,7 @@ void CClient::ProcessAudioData ( CVector<int16_t>& vecsStereoSndCrd )
|
|||
|
||||
// TEST
|
||||
// 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
|
||||
celt_encode ( CeltEncoder,
|
||||
|
@ -410,7 +415,7 @@ void CClient::ProcessAudioData ( CVector<int16_t>& vecsStereoSndCrd )
|
|||
|
||||
// TEST
|
||||
// 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
|
||||
const bool bReceiveDataOk =
|
||||
|
|
|
@ -119,9 +119,9 @@ public:
|
|||
int GetSndCrdDev() { return Sound.GetDev(); }
|
||||
void OpenSndCrdDriverSetup() { Sound.OpenDriverSetup(); }
|
||||
|
||||
void SetSndCrdPrefMonoFrameSizeFactor ( const int iNewFactor );
|
||||
int GetSndCrdPrefMonoFrameSizeFactor()
|
||||
{ return iSndCrdPrefMonoFrameSizeFactor; }
|
||||
void SetSndCrdPrefFrameSizeFactor ( const int iNewFactor );
|
||||
int GetSndCrdPrefFrameSizeFactor()
|
||||
{ return iSndCrdPrefFrameSizeFactor; }
|
||||
int GetSndCrdActualMonoBlSize() { return iMonoBlockSizeSam; }
|
||||
|
||||
void SetRemoteChanGain ( const int iId, const double dGain )
|
||||
|
@ -172,7 +172,8 @@ protected:
|
|||
int iReverbLevel;
|
||||
CAudioReverb AudioReverb;
|
||||
|
||||
int iSndCrdPrefMonoFrameSizeFactor;
|
||||
int iSndCrdPrefFrameSizeFactor;
|
||||
int iSndCrdFrameSizeFactor;
|
||||
|
||||
int iMonoBlockSizeSam;
|
||||
int iStereoBlockSizeSam;
|
||||
|
|
|
@ -169,7 +169,7 @@ void CClientSettingsDlg::UpdateSoundCardFrame()
|
|||
{
|
||||
// update slider value and text
|
||||
const int iCurPrefFrameSizeFactor =
|
||||
pClient->GetSndCrdPrefMonoFrameSizeFactor();
|
||||
pClient->GetSndCrdPrefFrameSizeFactor();
|
||||
|
||||
const int iCurActualBufSize =
|
||||
pClient->GetSndCrdActualMonoBlSize();
|
||||
|
@ -236,7 +236,7 @@ void CClientSettingsDlg::OnSliderNetBuf ( int value )
|
|||
|
||||
void CClientSettingsDlg::OnSliderSndCrdBufferDelay ( int value )
|
||||
{
|
||||
pClient->SetSndCrdPrefMonoFrameSizeFactor ( value );
|
||||
pClient->SetSndCrdPrefFrameSizeFactor ( value );
|
||||
UpdateDisplay();
|
||||
}
|
||||
|
||||
|
@ -273,17 +273,17 @@ void CClientSettingsDlg::OnSndCrdBufferDelayButtonGroupClicked ( QAbstractButton
|
|||
{
|
||||
if ( button == rButBufferDelayPreferred )
|
||||
{
|
||||
pClient->SetSndCrdPrefMonoFrameSizeFactor ( FRAME_SIZE_FACTOR_PREFERRED );
|
||||
pClient->SetSndCrdPrefFrameSizeFactor ( FRAME_SIZE_FACTOR_PREFERRED );
|
||||
}
|
||||
|
||||
if ( button == rButBufferDelayDefault )
|
||||
{
|
||||
pClient->SetSndCrdPrefMonoFrameSizeFactor ( FRAME_SIZE_FACTOR_DEFAULT );
|
||||
pClient->SetSndCrdPrefFrameSizeFactor ( FRAME_SIZE_FACTOR_DEFAULT );
|
||||
}
|
||||
|
||||
if ( button == rButBufferDelaySafe )
|
||||
{
|
||||
pClient->SetSndCrdPrefMonoFrameSizeFactor ( FRAME_SIZE_FACTOR_SAFE );
|
||||
pClient->SetSndCrdPrefFrameSizeFactor ( FRAME_SIZE_FACTOR_SAFE );
|
||||
}
|
||||
|
||||
UpdateDisplay();
|
||||
|
@ -317,7 +317,7 @@ void CClientSettingsDlg::OnPingTimeResult ( int iPingTime )
|
|||
|
||||
const double dDelayToFillNetworkPackets =
|
||||
SYSTEM_BLOCK_DURATION_MS_FLOAT *
|
||||
pClient->GetSndCrdPrefMonoFrameSizeFactor();
|
||||
pClient->GetSndCrdPrefFrameSizeFactor();
|
||||
|
||||
// CELT additional delay at small frame sizes is half a frame size
|
||||
const double dAdditionalAudioCodecDelay =
|
||||
|
|
|
@ -294,11 +294,10 @@ void CServer::OnTimer()
|
|||
CVector<CVector<double> > vecvecdGains;
|
||||
CVector<CVector<int16_t> > vecvecsData;
|
||||
|
||||
|
||||
// get data from all connected clients -------------------------------------
|
||||
// Get data from all connected clients -------------------------------------
|
||||
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!
|
||||
Mutex.lock();
|
||||
{
|
||||
|
@ -399,7 +398,7 @@ void CServer::OnTimer()
|
|||
const int iNumClients = vecChanID.Size();
|
||||
|
||||
// Check if at least one client is connected. If not, stop server until
|
||||
// one client is connected
|
||||
// one client is connected.
|
||||
if ( iNumClients != 0 )
|
||||
{
|
||||
for ( int i = 0; i < iNumClients; i++ )
|
||||
|
|
|
@ -118,7 +118,7 @@ void CSettings::ReadIniFile ( const QString& sFileName )
|
|||
( iValue == FRAME_SIZE_FACTOR_DEFAULT ) ||
|
||||
( 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
|
||||
SetNumericIniSet ( IniXMLDocument, "client", "prefsndcrdbufidx",
|
||||
pClient->GetSndCrdPrefMonoFrameSizeFactor() );
|
||||
pClient->GetSndCrdPrefFrameSizeFactor() );
|
||||
|
||||
// automatic network jitter buffer size setting
|
||||
SetFlagIniSet ( IniXMLDocument, "client", "autojitbuf",
|
||||
|
|
Loading…
Reference in a new issue