diff --git a/linux/sound.cpp b/linux/sound.cpp index cb30d148..80ec1ff0 100755 --- a/linux/sound.cpp +++ b/linux/sound.cpp @@ -243,7 +243,7 @@ bool CSound::Write ( CVector& psData ) // Common *********************************************************************** -bool CSound::SetHWParams ( snd_pcm_t* handle, const int iBufferSizeIn, +bool CSound::SetHWParams ( snd_pcm_t* handle, const int iDesiredBufferSize, const int iNumPeriodBlocks ) { int err; @@ -301,21 +301,39 @@ bool CSound::SetHWParams ( snd_pcm_t* handle, const int iBufferSizeIn, return true; } + // set the period size + snd_pcm_uframes_t PeriodSize = iDesiredBufferSize; + if ( err = snd_pcm_hw_params_set_period_size_near ( handle, hwparams, &PeriodSize, 0 ) < 0 ) + { + qDebug ( "cannot set period size (%s)\n", snd_strerror ( err ) ); + return true; + } + // set the buffer size and period size - snd_pcm_uframes_t BufferFrames = iBufferSizeIn * iNumPeriodBlocks; + snd_pcm_uframes_t BufferFrames = iDesiredBufferSize * iNumPeriodBlocks; if ( err = snd_pcm_hw_params_set_buffer_size_near ( handle, hwparams, &BufferFrames ) < 0 ) { qDebug ( "cannot set buffer size (%s)\n", snd_strerror ( err ) ); return true; } - // set the period size - snd_pcm_uframes_t PeriodSize = iBufferSizeIn; - if ( err = snd_pcm_hw_params_set_period_size_near ( handle, hwparams, &PeriodSize, 0 ) < 0 ) - { - qDebug ( "cannot set period size (%s)\n", snd_strerror ( err ) ); - return true; - } +// check period and buffer size +snd_pcm_uframes_t period_size; +err = snd_pcm_hw_params_get_period_size ( hwparams, &period_size, 0 ); +if ( err < 0 ) +{ + qDebug ( "Unable to get period size: %s\n", snd_strerror ( err ) ); +} +qDebug ( "frame size: %d (desired: %d)", (int) period_size, iDesiredBufferSize ); + +snd_pcm_uframes_t buffer_size; +if ( err = snd_pcm_hw_params_get_buffer_size(hwparams, &buffer_size ) < 0 ) +{ + qDebug ( "Unable to get buffer size: %s\n", snd_strerror ( err ) ); +} +qDebug ( "buffer size: %d (desired: %d)", (int) buffer_size, iDesiredBufferSize * iNumPeriodBlocks ); + + // write the parameters to device if ( err = snd_pcm_hw_params ( handle, hwparams ) < 0 ) @@ -324,24 +342,6 @@ bool CSound::SetHWParams ( snd_pcm_t* handle, const int iBufferSizeIn, return true; } - -// check period and buffer size -snd_pcm_uframes_t buffer_size; -if ( err = snd_pcm_hw_params_get_buffer_size(hwparams, &buffer_size ) < 0 ) -{ - qDebug ( "Unable to get buffer size for playback: %s\n", snd_strerror ( err ) ); -} -qDebug ( "buffer size: %d (desired: %d)", (int) buffer_size, iBufferSizeIn * iNumPeriodBlocks ); - -snd_pcm_uframes_t period_size; -err = snd_pcm_hw_params_get_period_size ( hwparams, &period_size, 0 ); -if ( err < 0 ) -{ - qDebug ( "Unable to get period size for playback: %s\n", snd_strerror ( err ) ); -} -qDebug ( "frame size: %d (desired: %d)", (int) period_size, iBufferSizeIn ); - - // clean-up snd_pcm_hw_params_free ( hwparams ); diff --git a/src/channel.cpp b/src/channel.cpp index 9b643d49..bb7c1b91 100755 --- a/src/channel.cpp +++ b/src/channel.cpp @@ -648,10 +648,6 @@ CChannel::CChannel ( const bool bNIsServer ) : bIsServer ( bNIsServer ), SIGNAL ( ConClientListMesReceived ( CVector ) ), SIGNAL ( ConClientListMesReceived ( CVector ) ) ); - QObject::connect ( &Protocol, - SIGNAL ( ChangeNetwBlSiFact ( int ) ), - this, SLOT ( OnNetwBlSiFactChange ( int ) ) ); - QObject::connect( &Protocol, SIGNAL ( ChangeChanGain ( int, double ) ), this, SLOT ( OnChangeChanGain ( int, double ) ) ); @@ -867,11 +863,6 @@ void CChannel::OnSendProtMessage ( CVector vecMessage ) } } -void CChannel::OnNetwBlSiFactChange ( int iNewNetwBlSiFact ) -{ - SetNetwBufSizeFactOut ( iNewNetwBlSiFact ); -} - void CChannel::OnJittBufSizeChange ( int iNewJitBufSize ) { SetSockBufSize ( iNewJitBufSize ); diff --git a/src/channel.h b/src/channel.h index 4d846665..4901a8d5 100755 --- a/src/channel.h +++ b/src/channel.h @@ -203,7 +203,6 @@ protected: public slots: void OnSendProtMessage ( CVector vecMessage ); void OnJittBufSizeChange ( int iNewJitBufSize ); - void OnNetwBlSiFactChange ( int iNewNetwBlSiFact ); void OnChangeChanGain ( int iChanID, double dNewGain ); void OnChangeChanName ( QString strName ); void OnNetTranspPropsReceived ( CNetworkTransportProps NetworkTransportProps ); diff --git a/src/client.cpp b/src/client.cpp index 3b864b16..ae7295a8 100755 --- a/src/client.cpp +++ b/src/client.cpp @@ -33,7 +33,6 @@ CClient::CClient ( const quint16 iPortNumber ) : iAudioInFader ( AUD_FADER_IN_MIDDLE ), iReverbLevel ( 0 ), bReverbOnLeftChan ( false ), - iNetwBufSizeFactIn ( DEF_NET_BLOCK_SIZE_FACTOR ), strIPAddress ( "" ), strName ( "" ), bOpenChatOnNewMessage ( true ), bDoAutoSockBufSize ( true ) @@ -77,14 +76,8 @@ for ( int i = 0; i < vecMessage.Size(); i++ ) { void CClient::OnReqJittBufSize() { - // TODO cant we implement this OnReqJjittBufSize inside the channel object? - Channel.CreateJitBufMes ( Channel.GetSockBufSize() ); - -// FIXME: we set the network buffer size factor here, too -> in the -// future a separate request function for this parameter should be created - Channel.CreateNetwBlSiFactMes ( iNetwBufSizeFactIn ); } void CClient::OnNewConnection() diff --git a/src/client.h b/src/client.h index 5d37d48c..19cb37d6 100755 --- a/src/client.h +++ b/src/client.h @@ -114,18 +114,6 @@ public: } int GetSockBufSize() { return Channel.GetSockBufSize(); } - void SetNetwBufSizeFactIn ( const int iNewNetNetwBlSiFactIn ) - { - // store value and tell the server about new value - iNetwBufSizeFactIn = iNewNetNetwBlSiFactIn; - Channel.CreateNetwBlSiFactMes ( iNewNetNetwBlSiFactIn ); - } - int GetNetwBufSizeFactIn() { return iNetwBufSizeFactIn; } - - void SetNetwBufSizeFactOut ( const int iNetNetwBlSiFact ) - { Channel.SetNetwBufSizeFactOut ( iNetNetwBlSiFact ); } - int GetNetwBufSizeFactOut() { return Channel.GetNetwBufSizeFactOut(); } - void SetAudioCompressionOut ( const EAudComprType eNewAudComprTypeOut ) { Channel.SetAudioCompressionOut ( eNewAudComprTypeOut ); @@ -185,8 +173,6 @@ protected: int iMonoBlockSizeSam; int iStereoBlockSizeSam; - int iNetwBufSizeFactIn; - bool bOpenChatOnNewMessage; CVector vecsAudioSndCrdStereo; diff --git a/src/clientsettingsdlg.cpp b/src/clientsettingsdlg.cpp index ed1fddb1..13b4b255 100755 --- a/src/clientsettingsdlg.cpp +++ b/src/clientsettingsdlg.cpp @@ -43,11 +43,19 @@ CClientSettingsDlg::CClientSettingsDlg ( CClient* pNCliP, QWidget* parent, TextNetBuf->setWhatsThis ( strJitterBufferSize ); GroupBoxJitterBuffer->setWhatsThis ( strJitterBufferSize ); + // init driver button +#ifdef _WIN32 + ButtonDriverSetup->setText ( "ASIO Setup" ); +#else + // no use for this button for Linux right now, maybe later used + // for Jack + ButtonDriverSetup->hide(); +#endif + // init delay information controls CLEDOverallDelay->SetUpdateTime ( 2 * PING_UPDATE_TIME ); CLEDOverallDelay->Reset(); TextLabelPingTime->setText ( "" ); - TextLabelBufferDelay->setText ( "" ); TextLabelOverallDelay->setText ( "" ); // init slider controls --- @@ -55,14 +63,6 @@ CClientSettingsDlg::CClientSettingsDlg ( CClient* pNCliP, QWidget* parent, SliderNetBuf->setRange ( MIN_NET_BUF_SIZE_NUM_BL, MAX_NET_BUF_SIZE_NUM_BL ); UpdateJitterBufferFrame(); - // network buffer size factor in - SliderNetBufSiFactIn->setRange ( 1, MAX_NET_BLOCK_SIZE_FACTOR ); - const int iCurNetBufSiFactIn = pClient->GetNetwBufSizeFactIn(); - SliderNetBufSiFactIn->setValue ( iCurNetBufSiFactIn ); - TextNetBufSiFactIn->setText ( "In:\n" + QString().setNum ( - double ( iCurNetBufSiFactIn * MIN_SERVER_BLOCK_DURATION_MS ), 'f', 2 ) + - " ms" ); - // init combo box containing all available sound cards in the system cbSoundcard->clear(); for ( int iSndDevIdx = 0; iSndDevIdx < pClient->GetSndInterface()->GetNumDev(); iSndDevIdx++ ) @@ -111,9 +111,6 @@ CClientSettingsDlg::CClientSettingsDlg ( CClient* pNCliP, QWidget* parent, QObject::connect ( SliderNetBuf, SIGNAL ( valueChanged ( int ) ), this, SLOT ( OnSliderNetBuf ( int ) ) ); - QObject::connect ( SliderNetBufSiFactIn, SIGNAL ( valueChanged ( int ) ), - this, SLOT ( OnSliderNetBufSiFactIn ( int ) ) ); - // check boxes QObject::connect ( cbOpenChatOnNewMessage, SIGNAL ( stateChanged ( int ) ), this, SLOT ( OnOpenChatOnNewMessageStateChanged ( int ) ) ); @@ -124,6 +121,10 @@ CClientSettingsDlg::CClientSettingsDlg ( CClient* pNCliP, QWidget* parent, QObject::connect ( cbSoundcard, SIGNAL ( activated ( int ) ), this, SLOT ( OnSoundCrdSelection ( int ) ) ); + // buttons + QObject::connect ( ButtonDriverSetup, SIGNAL ( clicked() ), + this, SLOT ( OnDriverSetupBut() ) ); + // misc QObject::connect ( pClient, SIGNAL ( PingTimeReceived ( int ) ), this, SLOT ( OnPingTimeResult ( int ) ) ); @@ -162,6 +163,11 @@ void CClientSettingsDlg::hideEvent ( QHideEvent* hideEvent ) TimerPing.stop(); } +void CClientSettingsDlg::OnDriverSetupBut() +{ + // TODO write function in Windows sound interface +} + void CClientSettingsDlg::OnSliderNetBuf ( int value ) { pClient->SetSockBufSize ( value ); @@ -169,15 +175,6 @@ void CClientSettingsDlg::OnSliderNetBuf ( int value ) UpdateDisplay(); } -void CClientSettingsDlg::OnSliderNetBufSiFactIn ( int value ) -{ - pClient->SetNetwBufSizeFactIn ( value ); - TextNetBufSiFactIn->setText ( "In:\n" + QString().setNum ( - double ( value * MIN_SERVER_BLOCK_DURATION_MS ), 'f', 2 ) + - " ms" ); - UpdateDisplay(); -} - void CClientSettingsDlg::OnSoundCrdSelection ( int iSndDevIdx ) { try @@ -243,9 +240,13 @@ void CClientSettingsDlg::OnPingTimeResult ( int iPingTime ) - 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 */ - const int iTotalJitterBufferDelayMS = MIN_SERVER_BLOCK_DURATION_MS * - ( 2 * pClient->GetSockBufSize() + pClient->GetNetwBufSizeFactIn() + - pClient->GetNetwBufSizeFactOut() ) / 2; + +// TODO revise this + +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 @@ -254,8 +255,9 @@ const int iTotalSoundCardDelayMS = 0; // MIN_SERVER_BLOCK_DURATION_MS * ( pClient->GetSndInterface()->GetInNumBuf() + // pClient->GetSndInterface()->GetOutNumBuf() ) / 2; - const int iDelayToFillNetworkPackets = MIN_SERVER_BLOCK_DURATION_MS * - ( pClient->GetNetwBufSizeFactIn() + pClient->GetNetwBufSizeFactOut() ); +// TODO + const int iDelayToFillNetworkPackets = 0;//MIN_SERVER_BLOCK_DURATION_MS * +// ( pClient->GetNetwBufSizeFactIn() + pClient->GetNetwBufSizeFactOut() ); const int iTotalBufferDelay = iDelayToFillNetworkPackets + iTotalJitterBufferDelayMS + iTotalSoundCardDelayMS; @@ -264,7 +266,6 @@ const int iTotalSoundCardDelayMS = 0; // apply values to GUI labels, take special care if ping time exceeds // a certain value - TextLabelBufferDelay->setText ( QString().setNum ( iTotalBufferDelay ) + " ms" ); if ( iPingTime > 500 ) { const QString sErrorText = ">500 ms"; @@ -304,7 +305,6 @@ void CClientSettingsDlg::UpdateDisplay() { // clear text labels with client parameters TextLabelPingTime->setText ( "" ); - TextLabelBufferDelay->setText ( "" ); TextLabelOverallDelay->setText ( "" ); } } diff --git a/src/clientsettingsdlg.h b/src/clientsettingsdlg.h index be5304db..942aabc0 100755 --- a/src/clientsettingsdlg.h +++ b/src/clientsettingsdlg.h @@ -78,10 +78,10 @@ public slots: void OnTimerStatus() { UpdateDisplay(); } void OnTimerPing(); void OnSliderNetBuf ( int value ); - void OnSliderNetBufSiFactIn ( int value ); void OnAutoJitBuf ( int value ); void OnOpenChatOnNewMessageStateChanged ( int value ); void OnAudioCompressionButtonGroupClicked ( QAbstractButton* button ); void OnPingTimeResult ( int iPingTime ); void OnSoundCrdSelection ( int iSndDevIdx ); + void OnDriverSetupBut(); }; diff --git a/src/clientsettingsdlgbase.ui b/src/clientsettingsdlgbase.ui index c5ed368b..131269b1 100755 --- a/src/clientsettingsdlgbase.ui +++ b/src/clientsettingsdlgbase.ui @@ -5,8 +5,8 @@ 0 0 - 421 - 313 + 562 + 310 @@ -73,9 +73,12 @@ Qt::Horizontal + + QSizePolicy::Minimum + - 40 + 0 20 @@ -99,9 +102,12 @@ Qt::Horizontal + + QSizePolicy::Minimum + - 40 + 0 20 @@ -116,9 +122,12 @@ Qt::Horizontal + + QSizePolicy::Minimum + - 16 + 0 20 @@ -134,14 +143,14 @@ - 13 - 13 + 20 + 20 - 13 - 13 + 20 + 20 @@ -151,9 +160,12 @@ Qt::Horizontal + + QSizePolicy::Minimum + - 16 + 0 20 @@ -165,116 +177,15 @@ - + - Block Size - - - - 6 - - - 9 - - - 9 - - - 9 - - - 9 - - - - - - 50 - 0 - - - - Size - - - Qt::AlignCenter - - - false - - - - - - - 6 - - - 0 - - - 0 - - - 0 - - - 0 - - - - - Qt::Horizontal - - - - 40 - 20 - - - - - - - - 1 - - - Qt::Vertical - - - QSlider::TicksBothSides - - - - - - - Qt::Horizontal - - - - 40 - 20 - - - - - - - - - - - - - Misc + Soundcard - + - Soundcard + Device @@ -294,6 +205,112 @@ + + + + Qt::Vertical + + + + 201 + 20 + + + + + + + + Buffer Delay + + + + + + Qt::Horizontal + + + QSlider::TicksBelow + + + + + + + + + Preferred + + + true + + + + + + + QFrame::Panel + + + QFrame::Sunken + + + val + + + + + + + + + + + Actual + + + + + + + QFrame::Panel + + + QFrame::Sunken + + + val + + + + + + + + + Driver Setup + + + + + + + + + + + + + Misc + + + + + + Open chat on new message + + + @@ -324,13 +341,6 @@ - - - - Open chat on new message - - - @@ -338,7 +348,7 @@ - 116 + 201 16 @@ -346,84 +356,53 @@ - - 2 - - - - 0 - - - - - Buffer Delay - - - Qt::AlignCenter - - - true - - - - - - - - 0 - 0 - - - - - 40 - 0 - - - - QFrame::Panel - - - QFrame::Sunken - - - val - - - Qt::AlignCenter - - - - - - - + - + + Ping Time - - - 0 + + + + 0 + 0 + + + + 50 + 0 + + + + QFrame::Panel + + + QFrame::Sunken + + + val + + + + + + + + + + + Overall Delay + + + + + - - - Ping Time - - - Qt::AlignCenter - - - true - - - - - + 0 @@ -436,6 +415,12 @@ 0 + + + 75 + true + + QFrame::Panel @@ -445,99 +430,61 @@ val - - Qt::AlignCenter + + + + + + + 0 + 0 + + + + + 20 + 20 + + + + + 20 + 20 + + + + + - + - = + Upstream - - - 2 + + + + 75 + true + - - - - Overall Delay - - - Qt::AlignCenter - - - true - - - - - - - - - - 0 - 0 - - - - - 50 - 0 - - - - - 75 - true - - - - QFrame::Panel - - - QFrame::Sunken - - - val - - - Qt::AlignCenter - - - - - - - - 0 - 0 - - - - - 13 - 13 - - - - - 13 - 13 - - - - - - - + + QFrame::Panel + + + QFrame::Sunken + + + val + + diff --git a/src/global.h b/src/global.h index cb9575f6..6d431cc6 100755 --- a/src/global.h +++ b/src/global.h @@ -78,8 +78,8 @@ // maximum value of factor for network block size #define MAX_NET_BLOCK_SIZE_FACTOR 3 -// default network block size factor -#define DEF_NET_BLOCK_SIZE_FACTOR 3 +// default network block size factor (only used for server) +#define DEF_NET_BLOCK_SIZE_FACTOR 2 // minimum/maximum network buffer size (which can be chosen by slider) #define MIN_NET_BUF_SIZE_NUM_BL 1 // number of blocks @@ -111,7 +111,7 @@ #define LEN_MOV_AV_RESPONSE ( TIME_MOV_AV_RESPONSE * 1000 / MIN_SERVER_BLOCK_DURATION_MS ) // GUI definition: width/heigth size of LED pixmaps -#define LED_WIDTH_HEIGHT_SIZE_PIXEL 13 +#define LED_WIDTH_HEIGHT_SIZE_PIXEL 20 #define _MAXSHORT 32767 diff --git a/src/llconclientdlgbase.ui b/src/llconclientdlgbase.ui index 61287050..bcfc7eeb 100755 --- a/src/llconclientdlgbase.ui +++ b/src/llconclientdlgbase.ui @@ -348,14 +348,14 @@ - 13 - 13 + 20 + 20 - 13 - 13 + 20 + 20 diff --git a/src/settings.cpp b/src/settings.cpp index e6541ccf..2e8198bc 100755 --- a/src/settings.cpp +++ b/src/settings.cpp @@ -105,18 +105,6 @@ void CSettings::ReadIniFile ( const QString& sFileName ) pClient->SetSockBufSize ( iValue ); } - // network buffer size factor in - if ( GetNumericIniSet ( IniXMLDocument, "client", "netwbusifactin", 1, MAX_NET_BLOCK_SIZE_FACTOR, iValue ) ) - { - pClient->SetNetwBufSizeFactIn ( iValue ); - } - - // network buffer size factor out - if ( GetNumericIniSet ( IniXMLDocument, "client", "netwbusifactout", 1, MAX_NET_BLOCK_SIZE_FACTOR, iValue ) ) - { - pClient->SetNetwBufSizeFactOut ( iValue ); - } - // flag whether the chat window shall be opened on a new chat message if ( GetFlagIniSet ( IniXMLDocument, "client", "openchatonnewmessage", bValue ) ) { @@ -175,12 +163,6 @@ void CSettings::WriteIniFile ( const QString& sFileName ) // network jitter buffer size SetNumericIniSet ( IniXMLDocument, "client", "jitbuf", pClient->GetSockBufSize() ); - // network buffer size factor in - SetNumericIniSet ( IniXMLDocument, "client", "netwbusifactin", pClient->GetNetwBufSizeFactIn() ); - - // network buffer size factor out - SetNumericIniSet ( IniXMLDocument, "client", "netwbusifactout", pClient->GetNetwBufSizeFactOut() ); - // flag whether the chat window shall be opened on a new chat message SetFlagIniSet ( IniXMLDocument, "client", "openchatonnewmessage", pClient->GetOpenChatOnNewMessage() );