some more work for sound card buffer size index implementation

This commit is contained in:
Volker Fischer 2009-03-04 07:57:44 +00:00
parent 78d518bf75
commit 5cbf5cfd13
5 changed files with 59 additions and 17 deletions

View file

@ -35,7 +35,8 @@ CClient::CClient ( const quint16 iPortNumber ) :
bReverbOnLeftChan ( false ),
strIPAddress ( "" ), strName ( "" ),
bOpenChatOnNewMessage ( true ),
bDoAutoSockBufSize ( true )
bDoAutoSockBufSize ( true ),
iSndCrdPreferredMonoBlSizeIndex ( CSndCrdBufferSizes::GetDefaultIndex() )
{
// connection for protocol
QObject::connect ( &Channel,
@ -149,6 +150,23 @@ bool CClient::SetServerAddr ( QString strNAddr )
return true;
}
void CClient::SetSndCrdPreferredMonoBlSizeIndex ( const int iNewIdx )
{
// right now we simply set the internal value
if ( ( iNewIdx >= 0 ) && ( CSndCrdBufferSizes::GetNumOfBufferSizes() ) )
{
iSndCrdPreferredMonoBlSizeIndex = iNewIdx;
}
// TODO take action on new parameter
}
void CClient::Start()
{
// init object

View file

@ -118,6 +118,10 @@ public:
int GetAudioBlockSizeIn() { return Channel.GetAudioBlockSizeIn(); }
int GetUploadRateKbps() { return Channel.GetUploadRateKbps(); }
void SetSndCrdPreferredMonoBlSizeIndex ( const int iNewIdx );
int GetSndCrdPreferredMonoBlSizeIndex()
{ return iSndCrdPreferredMonoBlSizeIndex; }
void SetAudioCompressionOut ( const EAudComprType eNewAudComprTypeOut )
{
Channel.SetAudioCompressionOut ( eNewAudComprTypeOut );
@ -172,6 +176,8 @@ protected:
int iReverbLevel;
CAudioReverb AudioReverb;
int iSndCrdPreferredMonoBlSizeIndex;
int iSndCrdMonoBlockSizeSam;
int iSndCrdStereoBlockSizeSam;
int iMonoBlockSizeSam;

View file

@ -52,11 +52,12 @@ CClientSettingsDlg::CClientSettingsDlg ( CClient* pNCliP, QWidget* parent,
ButtonDriverSetup->hide();
#endif
// init delay information controls
// init delay and other information controls
CLEDOverallDelay->SetUpdateTime ( 2 * PING_UPDATE_TIME );
CLEDOverallDelay->Reset();
TextLabelPingTime->setText ( "" );
TextLabelOverallDelay->setText ( "" );
TextUpstreamValue->setText ( "" );
// init slider controls ---
// network buffer
@ -160,7 +161,14 @@ void CClientSettingsDlg::UpdateJitterBufferFrame()
void CClientSettingsDlg::UpdateSoundCardFrame()
{
// TODO
// update slider value and text
const int iCurBufIdx = pClient->GetSndCrdPreferredMonoBlSizeIndex();
SliderSndCrdBufferDelay->setValue ( iCurBufIdx );
TextLabelPreferredSndCrdBufDelay->setText (
QString().setNum ( (double) CSndCrdBufferSizes::GetBufferSizeFromIndex ( iCurBufIdx ) *
1000 / SND_CRD_SAMPLE_RATE, 'f', 2 ) + " ms (" +
QString().setNum ( CSndCrdBufferSizes::GetBufferSizeFromIndex ( iCurBufIdx ) ) + ")" );
}
void CClientSettingsDlg::showEvent ( QShowEvent* showEvent )
@ -188,15 +196,8 @@ void CClientSettingsDlg::OnSliderNetBuf ( int value )
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 ) ) + ")" );
pClient->SetSndCrdPreferredMonoBlSizeIndex ( value );
UpdateSoundCardFrame();
}
void CClientSettingsDlg::OnSoundCrdSelection ( int iSndDevIdx )
@ -320,17 +321,19 @@ void CClientSettingsDlg::UpdateDisplay()
{
// update slider controls (settings might have been changed)
UpdateJitterBufferFrame();
// TEST
TextUpstreamValue->setText ( QString().setNum ( pClient->GetUploadRateKbps() ) + " kbps" );
UpdateSoundCardFrame();
if ( !pClient->IsRunning() )
{
// clear text labels with client parameters
TextLabelPingTime->setText ( "" );
TextLabelOverallDelay->setText ( "" );
TextUpstreamValue->setText ( "" );
}
else
{
// update upstream rate information label (only if client is running)
TextUpstreamValue->setText ( QString().setNum ( pClient->GetUploadRateKbps() ) + " kbps" );
}
}

View file

@ -93,6 +93,12 @@ void CSettings::ReadIniFile ( const QString& sFileName )
pClient->GetSndInterface()->SetDev ( INVALID_SNC_CARD_DEVICE );
}
// sound card preferred buffer size index
if ( GetNumericIniSet ( IniXMLDocument, "client", "prefsndcrdbufidx", 0, CSndCrdBufferSizes::GetNumOfBufferSizes(), iValue ) )
{
pClient->SetSndCrdPreferredMonoBlSizeIndex ( iValue );
}
// automatic network jitter buffer size setting
if ( GetFlagIniSet ( IniXMLDocument, "client", "autojitbuf", bValue ) )
{
@ -157,6 +163,9 @@ void CSettings::WriteIniFile ( const QString& sFileName )
// sound card selection
SetNumericIniSet ( IniXMLDocument, "client", "auddevidx", pClient->GetSndInterface()->GetDev() );
// sound card preferred buffer size index
SetNumericIniSet ( IniXMLDocument, "client", "prefsndcrdbufidx", pClient->GetSndCrdPreferredMonoBlSizeIndex() );
// automatic network jitter buffer size setting
SetFlagIniSet ( IniXMLDocument, "client", "autojitbuf", pClient->GetDoAutoSockBufSize() );

View file

@ -440,6 +440,12 @@ class CSndCrdBufferSizes
{
public:
static int GetNumOfBufferSizes() { return 30; }
// we use a conservative value as default, this value does not
// give perfekt latency results but should work ok on most
// sound cards and drivers
static int GetDefaultIndex() { return 5; }
static int GetBufferSizeFromIndex ( const int iIdx )
{
if ( ( iIdx >= 0 ) && ( iIdx < 30 ) )