diff --git a/src/client.cpp b/src/client.cpp index 4e5a75dd..103b206c 100755 --- a/src/client.cpp +++ b/src/client.cpp @@ -39,6 +39,9 @@ CClient::CClient ( const quint16 iPortNumber ) : bDoAutoSockBufSize ( true ), iSndCrdPrefFrameSizeFactor ( FRAME_SIZE_FACTOR_DEFAULT ), iSndCrdFrameSizeFactor ( FRAME_SIZE_FACTOR_DEFAULT ), + bFraSiFactPrefSupported ( false ), + bFraSiFactDefSupported ( false ), + bFraSiFactSafeSupported ( false ), iCeltNumCodedBytes ( CELT_NUM_BYTES_NORMAL_QUALITY ), bCeltDoHighQuality ( false ) { @@ -375,6 +378,25 @@ void CClient::AudioCallback ( CVector& psData, void* arg ) bool CClient::Init() { + // check if possible frame size factors are supported + const int iFraSizePreffered = + FRAME_SIZE_FACTOR_PREFERRED * SYSTEM_FRAME_SIZE_SAMPLES; + + bFraSiFactPrefSupported = + ( Sound.Init ( iFraSizePreffered ) == iFraSizePreffered ); + + const int iFraSizeDefault = + FRAME_SIZE_FACTOR_DEFAULT * SYSTEM_FRAME_SIZE_SAMPLES; + + bFraSiFactDefSupported = + ( Sound.Init ( iFraSizeDefault ) == iFraSizeDefault ); + + const int iFraSizeSafe = + FRAME_SIZE_FACTOR_SAFE * SYSTEM_FRAME_SIZE_SAMPLES; + + bFraSiFactSafeSupported = + ( Sound.Init ( iFraSizeSafe ) == iFraSizeSafe ); + // translate block size index in actual block size const int iPrefMonoFrameSize = iSndCrdPrefFrameSizeFactor * SYSTEM_FRAME_SIZE_SAMPLES; diff --git a/src/client.h b/src/client.h index fb124e59..44bb2079 100755 --- a/src/client.h +++ b/src/client.h @@ -136,6 +136,10 @@ public: { return iSndCrdPrefFrameSizeFactor; } int GetSndCrdActualMonoBlSize() { return iMonoBlockSizeSam; } + bool GetFraSiFactPrefSupported() { return bFraSiFactPrefSupported; } + bool GetFraSiFactDefSupported() { return bFraSiFactDefSupported; } + bool GetFraSiFactSafeSupported() { return bFraSiFactSafeSupported; } + void SetRemoteChanGain ( const int iId, const double dGain ) { Channel.SetRemoteChanGain ( iId, dGain ); } @@ -188,6 +192,10 @@ protected: int iSndCrdPrefFrameSizeFactor; int iSndCrdFrameSizeFactor; + bool bFraSiFactPrefSupported; + bool bFraSiFactDefSupported; + bool bFraSiFactSafeSupported; + int iMonoBlockSizeSam; int iStereoBlockSizeSam; diff --git a/src/clientsettingsdlg.cpp b/src/clientsettingsdlg.cpp index 8d068e01..ed441470 100755 --- a/src/clientsettingsdlg.cpp +++ b/src/clientsettingsdlg.cpp @@ -309,59 +309,29 @@ QString CClientSettingsDlg::GenSndCrdBufferDelayString ( const int iFrameSize, void CClientSettingsDlg::UpdateSoundCardFrame() { - // update slider value and text - const int iCurPrefFrameSizeFactor = - pClient->GetSndCrdPrefFrameSizeFactor(); - + // get current actual buffer size value const int iCurActualBufSize = pClient->GetSndCrdActualMonoBlSize(); - // update radio buttons - switch ( iCurPrefFrameSizeFactor ) - { - case FRAME_SIZE_FACTOR_PREFERRED: - rButBufferDelayPreferred->setChecked ( true ); - break; + // set radio buttons according to current value + rButBufferDelayPreferred->setChecked ( iCurActualBufSize == + SYSTEM_FRAME_SIZE_SAMPLES * FRAME_SIZE_FACTOR_PREFERRED ); - case FRAME_SIZE_FACTOR_DEFAULT: - rButBufferDelayDefault->setChecked ( true ); - break; + rButBufferDelayDefault->setChecked ( iCurActualBufSize == + SYSTEM_FRAME_SIZE_SAMPLES * FRAME_SIZE_FACTOR_DEFAULT ); - case FRAME_SIZE_FACTOR_SAFE: - rButBufferDelaySafe->setChecked ( true ); - break; - } + rButBufferDelaySafe->setChecked ( iCurActualBufSize == + SYSTEM_FRAME_SIZE_SAMPLES * FRAME_SIZE_FACTOR_SAFE ); - // preferred size - const int iPrefBufSize = - iCurPrefFrameSizeFactor * SYSTEM_FRAME_SIZE_SAMPLES; + // disable radio buttons which are not supported by audio interface + rButBufferDelayPreferred->setEnabled ( + pClient->GetFraSiFactPrefSupported() ); - // actual size (use yellow color if different from preferred size) - const QString strActSizeValues = - GenSndCrdBufferDelayString ( iCurActualBufSize ); + rButBufferDelayDefault->setEnabled ( + pClient->GetFraSiFactDefSupported() ); - if ( iPrefBufSize != iCurActualBufSize ) - { - // yellow color if actual buffer size is not the selected one - // but a valid one, red color if actual buffer size is not the - // selected one and is not a vaild one - if ( ( iCurActualBufSize != ( SYSTEM_FRAME_SIZE_SAMPLES * FRAME_SIZE_FACTOR_PREFERRED ) ) && - ( iCurActualBufSize != ( SYSTEM_FRAME_SIZE_SAMPLES * FRAME_SIZE_FACTOR_DEFAULT ) ) && - ( iCurActualBufSize != ( SYSTEM_FRAME_SIZE_SAMPLES * FRAME_SIZE_FACTOR_SAFE ) ) ) - { - TextLabelActualSndCrdBufDelay->setText ( "" + - strActSizeValues + "" ); - } - else - { - TextLabelActualSndCrdBufDelay->setText ( "" + - strActSizeValues + "" ); - } - } - else - { - TextLabelActualSndCrdBufDelay->setText ( strActSizeValues ); - } + rButBufferDelaySafe->setEnabled ( + pClient->GetFraSiFactSafeSupported() ); } void CClientSettingsDlg::showEvent ( QShowEvent* showEvent ) diff --git a/src/clientsettingsdlgbase.ui b/src/clientsettingsdlgbase.ui index b20d099b..05d0277c 100755 --- a/src/clientsettingsdlgbase.ui +++ b/src/clientsettingsdlgbase.ui @@ -245,36 +245,6 @@ - - - - - - Actual Value - - - - - - - - 110 - 20 - - - - QFrame::Panel - - - QFrame::Sunken - - - val - - - - -