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 ), bReverbOnLeftChan ( false ),
strIPAddress ( "" ), strName ( "" ), strIPAddress ( "" ), strName ( "" ),
bOpenChatOnNewMessage ( true ), bOpenChatOnNewMessage ( true ),
bDoAutoSockBufSize ( true ) bDoAutoSockBufSize ( true ),
iSndCrdPreferredMonoBlSizeIndex ( CSndCrdBufferSizes::GetDefaultIndex() )
{ {
// connection for protocol // connection for protocol
QObject::connect ( &Channel, QObject::connect ( &Channel,
@ -149,6 +150,23 @@ bool CClient::SetServerAddr ( QString strNAddr )
return true; 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() void CClient::Start()
{ {
// init object // init object

View file

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

View file

@ -52,11 +52,12 @@ CClientSettingsDlg::CClientSettingsDlg ( CClient* pNCliP, QWidget* parent,
ButtonDriverSetup->hide(); ButtonDriverSetup->hide();
#endif #endif
// init delay information controls // init delay and other information controls
CLEDOverallDelay->SetUpdateTime ( 2 * PING_UPDATE_TIME ); CLEDOverallDelay->SetUpdateTime ( 2 * PING_UPDATE_TIME );
CLEDOverallDelay->Reset(); CLEDOverallDelay->Reset();
TextLabelPingTime->setText ( "" ); TextLabelPingTime->setText ( "" );
TextLabelOverallDelay->setText ( "" ); TextLabelOverallDelay->setText ( "" );
TextUpstreamValue->setText ( "" );
// init slider controls --- // init slider controls ---
// network buffer // network buffer
@ -160,7 +161,14 @@ void CClientSettingsDlg::UpdateJitterBufferFrame()
void CClientSettingsDlg::UpdateSoundCardFrame() 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 ) void CClientSettingsDlg::showEvent ( QShowEvent* showEvent )
@ -188,15 +196,8 @@ void CClientSettingsDlg::OnSliderNetBuf ( int value )
void CClientSettingsDlg::OnSliderSndCrdBufferDelay ( int value ) void CClientSettingsDlg::OnSliderSndCrdBufferDelay ( int value )
{ {
// TODO pClient->SetSndCrdPreferredMonoBlSizeIndex ( value );
UpdateSoundCardFrame();
// 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 ) void CClientSettingsDlg::OnSoundCrdSelection ( int iSndDevIdx )
@ -320,17 +321,19 @@ void CClientSettingsDlg::UpdateDisplay()
{ {
// update slider controls (settings might have been changed) // update slider controls (settings might have been changed)
UpdateJitterBufferFrame(); UpdateJitterBufferFrame();
UpdateSoundCardFrame();
// TEST
TextUpstreamValue->setText ( QString().setNum ( pClient->GetUploadRateKbps() ) + " kbps" );
if ( !pClient->IsRunning() ) if ( !pClient->IsRunning() )
{ {
// clear text labels with client parameters // clear text labels with client parameters
TextLabelPingTime->setText ( "" ); TextLabelPingTime->setText ( "" );
TextLabelOverallDelay->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 ); 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 // automatic network jitter buffer size setting
if ( GetFlagIniSet ( IniXMLDocument, "client", "autojitbuf", bValue ) ) if ( GetFlagIniSet ( IniXMLDocument, "client", "autojitbuf", bValue ) )
{ {
@ -157,6 +163,9 @@ void CSettings::WriteIniFile ( const QString& sFileName )
// sound card selection // sound card selection
SetNumericIniSet ( IniXMLDocument, "client", "auddevidx", pClient->GetSndInterface()->GetDev() ); 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 // automatic network jitter buffer size setting
SetFlagIniSet ( IniXMLDocument, "client", "autojitbuf", pClient->GetDoAutoSockBufSize() ); SetFlagIniSet ( IniXMLDocument, "client", "autojitbuf", pClient->GetDoAutoSockBufSize() );

View file

@ -440,6 +440,12 @@ class CSndCrdBufferSizes
{ {
public: public:
static int GetNumOfBufferSizes() { return 30; } 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 ) static int GetBufferSizeFromIndex ( const int iIdx )
{ {
if ( ( iIdx >= 0 ) && ( iIdx < 30 ) ) if ( ( iIdx >= 0 ) && ( iIdx < 30 ) )