preliminary implementation

This commit is contained in:
Volker Fischer 2009-03-03 18:04:51 +00:00
parent 0982cb21ff
commit 2e81acfc3d
6 changed files with 66 additions and 18 deletions

View file

@ -110,8 +110,10 @@ public:
void SetSockBufSize ( const int iNumBlocks );
int GetSockBufSize() { return iCurSockBufSize; }
// TEST
void SetNetwBufSizeOut ( const int iNewAudioBlockSizeOut );
void SetNetwBufSizeOut ( const int iNewAudioBlockSizeOut );
int GetNetwBufSizeOut() { return iCurAudioBlockSizeOut; }
int GetAudioBlockSizeIn() { return iCurAudioBlockSizeIn; }
void SetNetwBufSizeFactOut ( const int iNewNetwBlSiFactOut );
int GetNetwBufSizeFactOut() { return iCurNetwOutBlSiFact; }

View file

@ -194,10 +194,8 @@ void CClient::Init ( const int iPrefMonoBlockSizeSamAtSndCrdSamRate )
iMonoBlockSizeSam = iSndCrdMonoBlockSizeSam * SYSTEM_SAMPLE_RATE / SND_CRD_SAMPLE_RATE;
iStereoBlockSizeSam = 2 * iMonoBlockSizeSam;
// TEST
Channel.SetNetwBufSizeOut ( iMonoBlockSizeSam );
// the channel works on the same block size as the sound interface
Channel.SetNetwBufSizeOut ( iMonoBlockSizeSam );
vecsAudioSndCrdStereo.Init ( iSndCrdStereoBlockSizeSam );
vecdAudioSndCrdMono.Init ( iSndCrdMonoBlockSizeSam );

View file

@ -114,6 +114,9 @@ public:
}
int GetSockBufSize() { return Channel.GetSockBufSize(); }
int GetNetwBufSizeOut() { return Channel.GetNetwBufSizeOut(); }
int GetAudioBlockSizeIn() { return Channel.GetAudioBlockSizeIn(); }
void SetAudioCompressionOut ( const EAudComprType eNewAudComprTypeOut )
{
Channel.SetAudioCompressionOut ( eNewAudComprTypeOut );

View file

@ -63,6 +63,10 @@ CClientSettingsDlg::CClientSettingsDlg ( CClient* pNCliP, QWidget* parent,
SliderNetBuf->setRange ( MIN_NET_BUF_SIZE_NUM_BL, MAX_NET_BUF_SIZE_NUM_BL );
UpdateJitterBufferFrame();
// sound card buffer size
SliderSndCrdBufferDelay->setRange ( 0,
CSndCrdBufferSizes::GetNumOfBufferSizes() - 1 );
// init combo box containing all available sound cards in the system
cbSoundcard->clear();
for ( int iSndDevIdx = 0; iSndDevIdx < pClient->GetSndInterface()->GetNumDev(); iSndDevIdx++ )
@ -108,8 +112,11 @@ CClientSettingsDlg::CClientSettingsDlg ( CClient* pNCliP, QWidget* parent,
QObject::connect ( &TimerPing, SIGNAL ( timeout() ),
this, SLOT ( OnTimerPing() ) );
// slider controls
QObject::connect ( SliderNetBuf, SIGNAL ( valueChanged ( int ) ),
this, SLOT ( OnSliderNetBuf ( int ) ) );
QObject::connect ( SliderSndCrdBufferDelay, SIGNAL ( valueChanged ( int ) ),
this, SLOT ( OnSliderSndCrdBufferDelay ( int ) ) );
// check boxes
QObject::connect ( cbOpenChatOnNewMessage, SIGNAL ( stateChanged ( int ) ),
@ -146,11 +153,16 @@ void CClientSettingsDlg::UpdateJitterBufferFrame()
TextNetBuf->setText ( "Size: " + QString().setNum ( iCurNumNetBuf ) );
// if auto setting is enabled, disable slider control
cbAutoJitBuf->setChecked ( pClient->GetDoAutoSockBufSize() );
cbAutoJitBuf->setChecked ( pClient->GetDoAutoSockBufSize() );
SliderNetBuf->setEnabled ( !pClient->GetDoAutoSockBufSize() );
TextNetBuf->setEnabled ( !pClient->GetDoAutoSockBufSize() );
}
void CClientSettingsDlg::UpdateSoundCardFrame()
{
// TODO
}
void CClientSettingsDlg::showEvent ( QShowEvent* showEvent )
{
// only activate ping timer if window is actually shown
@ -171,8 +183,20 @@ void CClientSettingsDlg::OnDriverSetupBut()
void CClientSettingsDlg::OnSliderNetBuf ( int value )
{
pClient->SetSockBufSize ( value );
TextNetBuf->setText ( "Size: " + QString().setNum ( value ) );
UpdateDisplay();
UpdateJitterBufferFrame();
}
void CClientSettingsDlg::OnSliderSndCrdBufferDelay ( int value )
{
// TODO
// TODO put this in the function "UpdateSoundCardFrame"
TextLabelPreferredSndCrdBufDelay->setText (
QString().setNum ( (double) CSndCrdBufferSizes::GetBufferSizeFromIndex ( value ) *
1000 / SND_CRD_SAMPLE_RATE, 'f', 2 ) + " ms (" +
QString().setNum ( CSndCrdBufferSizes::GetBufferSizeFromIndex ( value ) ) + ")" );
}
void CClientSettingsDlg::OnSoundCrdSelection ( int iSndDevIdx )
@ -238,15 +262,11 @@ void CClientSettingsDlg::OnPingTimeResult ( int iPingTime )
- the mean delay of a cyclic buffer is half the buffer size (since
for the average it is assumed that the buffer is half filled)
- consider the jitter buffer on the server side, too
- assume that the sound card introduces an additional delay of 2 * MIN_SERVER_BLOCK_DURATION_MS
*/
// TODO revise this
const int iTotalJitterBufferDelayMS = MIN_SERVER_BLOCK_DURATION_MS *
( 2 /* buffer at client and server */ * pClient->GetSockBufSize() ) / 2;
const int iTotalJitterBufferDelayMS = 0;
// const int iTotalJitterBufferDelayMS = MIN_SERVER_BLOCK_DURATION_MS *
// ( 2 * pClient->GetSockBufSize() + pClient->GetNetwBufSizeFactIn() +
// pClient->GetNetwBufSizeFactOut() ) / 2;
// TODO consider sound card interface block size
@ -255,9 +275,9 @@ const int iTotalSoundCardDelayMS = 0;
// MIN_SERVER_BLOCK_DURATION_MS * ( pClient->GetSndInterface()->GetInNumBuf() +
// pClient->GetSndInterface()->GetOutNumBuf() ) / 2;
// TODO
const int iDelayToFillNetworkPackets = 0;//MIN_SERVER_BLOCK_DURATION_MS *
// ( pClient->GetNetwBufSizeFactIn() + pClient->GetNetwBufSizeFactOut() );
const int iDelayToFillNetworkPackets =
( pClient->GetNetwBufSizeOut() + pClient->GetAudioBlockSizeIn() ) *
1000 / SYSTEM_SAMPLE_RATE;
const int iTotalBufferDelay = iDelayToFillNetworkPackets +
iTotalJitterBufferDelayMS + iTotalSoundCardDelayMS;

View file

@ -73,11 +73,13 @@ protected:
virtual void hideEvent ( QHideEvent* hideEvent );
void UpdateJitterBufferFrame();
void UpdateSoundCardFrame();
public slots:
void OnTimerStatus() { UpdateDisplay(); }
void OnTimerPing();
void OnSliderNetBuf ( int value );
void OnSliderSndCrdBufferDelay ( int value );
void OnAutoJitBuf ( int value );
void OnOpenChatOnNewMessageStateChanged ( int value );
void OnAudioCompressionButtonGroupClicked ( QAbstractButton* button );

View file

@ -436,6 +436,29 @@ public:
int iAudioCodingArg;
};
class CSndCrdBufferSizes
{
public:
static int GetNumOfBufferSizes() { return 30; }
static int GetBufferSizeFromIndex ( const int iIdx )
{
if ( ( iIdx >= 0 ) && ( iIdx < 30 ) )
{
const int pSizes[30] = {
96, 128, 160, 192, 224, 256, 288, 320, 352,
384, 416, 448, 480, 512, 544, 576, 608, 640,
672, 704, 736, 768, 800, 832, 864, 896, 928,
960, 992, 1024 };
return pSizes[iIdx];
}
else
{
return 0;
}
}
};
// Audio Reverbration ----------------------------------------------------------
class CAudioReverb