From 79c0047bb314c0cb2c0931b5c4f3ecabe2a35547 Mon Sep 17 00:00:00 2001 From: Volker Fischer Date: Fri, 17 Apr 2020 21:21:37 +0200 Subject: [PATCH] added Enable Small Network Buffers switch --- ChangeLog | 12 +++++++++++- src/client.cpp | 25 +++++++++++++++++++++++-- src/client.h | 4 ++++ src/clientsettingsdlg.cpp | 30 +++++++++++++++++++++++------- src/clientsettingsdlg.h | 2 +- src/clientsettingsdlgbase.ui | 12 ++++++++++-- src/settings.cpp | 10 ++++++++++ 7 files changed, 82 insertions(+), 13 deletions(-) diff --git a/ChangeLog b/ChangeLog index 2a7dc090..bbcf48c4 100644 --- a/ChangeLog +++ b/ChangeLog @@ -6,6 +6,10 @@ * added a Mute Stream button to hear your signal and the signal of the other clients but do not transmit your signal to the server so that the other clients cannot hear you + * added Enable Small Network Buffers switch to enable small sound card buffers in + combination with legacy OPUS packets since OPUS packets with 64 samples enable low + latency but can increase audio drop outs + * upgrade OPUS codec library to v1.3.1 by doloopuntil * improved auto jitter buffer for 64 samples frame size @@ -13,10 +17,16 @@ * the ping times in the server list are now more stable -TODO we need a switch to enable OPUS64 packets (otherwise it is not possible to use very small sound card buffers with the normal OPUS 128 samples frame size) +TODO store Show All Musicians setting in the ini-file + +TODO bug fix: "Start up the new version with the Connection Setup showing. "Show all musicians" is on (as I say). Switch it off before the list is displayed. The + checkbox is off - but the list displays all musicians! You need to turn it on and off again to get it to do its thing. (If you wait a little, it's fine - + i.e. before it's populated the musicians but after it's displayed the list, turn it off.)", see https://github.com/corrados/jamulus/issues/78 TODO offer the Jamulus ASIO settingspanel in case of an ASIO ERROR to fix, e.g., incorrect sample rate (https://sourceforge.net/p/llcon/discussion/533517/thread/777663cf94/#035f) +TODO the server list filter seems not to work if --showallservers is used + TODO store Central Server jamulus.server start scripts on the Repo (one for Central Server, one for Central Server North America) diff --git a/src/client.cpp b/src/client.cpp index 86637a3a..526f7de8 100755 --- a/src/client.cpp +++ b/src/client.cpp @@ -71,6 +71,7 @@ CClient::CClient ( const quint16 iPortNumber, bFraSiFactSafeSupported ( false ), eGUIDesign ( GD_ORIGINAL ), bDisplayChannelLevels ( true ), + bEnableOPUS64 ( false ), bJitterBufferOK ( true ), strCentralServerAddress ( "" ), eCentralServerAddressType ( AT_DEFAULT ), @@ -431,6 +432,26 @@ void CClient::SetSndCrdPrefFrameSizeFactor ( const int iNewFactor ) } } +void CClient::SetEnableOPUS64 ( const bool eNEnableOPUS64 ) +{ + // init with new parameter, if client was running then first + // stop it and restart again after new initialization + const bool bWasRunning = Sound.IsRunning(); + if ( bWasRunning ) + { + Sound.Stop(); + } + + // set new parameter + bEnableOPUS64 = eNEnableOPUS64; + Init(); + + if ( bWasRunning ) + { + Sound.Start(); + } +} + void CClient::SetAudioQuality ( const EAudioQuality eNAudioQuality ) { // init with new parameter, if client was running then first @@ -686,7 +707,7 @@ void CClient::Init() // Calculate the current sound card frame size factor. In case // the current mono block size is not a multiple of the system // frame size, we have to use a sound card conversion buffer. - if ( ( iMonoBlockSizeSam == ( SYSTEM_FRAME_SIZE_SAMPLES * FRAME_SIZE_FACTOR_PREFERRED ) ) || + if ( ( ( iMonoBlockSizeSam == ( SYSTEM_FRAME_SIZE_SAMPLES * FRAME_SIZE_FACTOR_PREFERRED ) ) && bEnableOPUS64 ) || ( iMonoBlockSizeSam == ( SYSTEM_FRAME_SIZE_SAMPLES * FRAME_SIZE_FACTOR_DEFAULT ) ) || ( iMonoBlockSizeSam == ( SYSTEM_FRAME_SIZE_SAMPLES * FRAME_SIZE_FACTOR_SAFE ) ) ) { @@ -713,7 +734,7 @@ void CClient::Init() // select the OPUS frame size mode depending on current mono block size samples if ( bSndCrdConversionBufferRequired ) { - if ( iSndCardMonoBlockSizeSamConvBuff < DOUBLE_SYSTEM_FRAME_SIZE_SAMPLES ) + if ( ( iSndCardMonoBlockSizeSamConvBuff < DOUBLE_SYSTEM_FRAME_SIZE_SAMPLES ) && bEnableOPUS64 ) { iMonoBlockSizeSam = SYSTEM_FRAME_SIZE_SAMPLES; eAudioCompressionType = CT_OPUS64; diff --git a/src/client.h b/src/client.h index 99e731d2..1e890cd7 100755 --- a/src/client.h +++ b/src/client.h @@ -204,6 +204,9 @@ public: void SetSndCrdPrefFrameSizeFactor ( const int iNewFactor ); int GetSndCrdPrefFrameSizeFactor() { return iSndCrdPrefFrameSizeFactor; } + void SetEnableOPUS64 ( const bool eNEnableOPUS64 ); + bool GetEnableOPUS64() { return bEnableOPUS64; } + int GetSndCrdActualMonoBlSize() { // the actual sound card mono block size depends on whether a @@ -366,6 +369,7 @@ protected: EGUIDesign eGUIDesign; bool bDisplayChannelLevels; + bool bEnableOPUS64; bool bJitterBufferOK; diff --git a/src/clientsettingsdlg.cpp b/src/clientsettingsdlg.cpp index 1a291aac..7723173a 100755 --- a/src/clientsettingsdlg.cpp +++ b/src/clientsettingsdlg.cpp @@ -121,6 +121,16 @@ CClientSettingsDlg::CClientSettingsDlg ( CClient* pNCliP, QWidget* parent, cbxROutChan->setWhatsThis ( strSndCrdChanMapp ); cbxROutChan->setAccessibleName ( tr ( "Right output channel selection combo box" ) ); + // enable OPUS64 + chbEnableOPUS64->setWhatsThis ( tr ( "Enable Small Network Buffers: If enabled, " + "the support for very small network audio packets is activated. Very small " + "network packets are only actually used if the sound card buffer delay is smaller than " ) + + QString().setNum ( DOUBLE_SYSTEM_FRAME_SIZE_SAMPLES ) + tr ( " samples. The " + "smaller the network buffers, the smaller the audio latency. But at the same time " + "the network load increases and the probability of audio dropouts also increases." ) ); + + chbEnableOPUS64->setAccessibleName ( tr ( "Enable small network buffers check box" ) ); + // sound card buffer delay QString strSndCrdBufDelay = tr ( "Sound Card Buffer Delay: The " "buffer delay setting is a fundamental setting of the " ) + @@ -317,7 +327,7 @@ CClientSettingsDlg::CClientSettingsDlg ( CClient* pNCliP, QWidget* parent, chbGUIDesignFancy->setCheckState ( Qt::Checked ); } - // Display Channel Levels check box + // Display Channel Levels check box chbDisplayChannelLevels->setCheckState ( pClient->GetDisplayChannelLevels() ? Qt::Checked : Qt::Unchecked ); // "Audio Channels" combo box @@ -345,6 +355,9 @@ CClientSettingsDlg::CClientSettingsDlg ( CClient* pNCliP, QWidget* parent, // update new client fader level edit box edtNewClientLevel->setText ( QString::number ( pClient->iNewClientFaderLevel ) ); + // update enable small network buffers check box + chbEnableOPUS64->setCheckState ( pClient->GetEnableOPUS64() ? Qt::Checked : Qt::Unchecked ); + // set text for sound card buffer delay radio buttons rbtBufferDelayPreferred->setText ( GenSndCrdBufferDelayString ( FRAME_SIZE_FACTOR_PREFERRED * SYSTEM_FRAME_SIZE_SAMPLES ) ); @@ -386,6 +399,9 @@ CClientSettingsDlg::CClientSettingsDlg ( CClient* pNCliP, QWidget* parent, QObject::connect ( chbAutoJitBuf, SIGNAL ( stateChanged ( int ) ), this, SLOT ( OnAutoJitBufStateChanged ( int ) ) ); + QObject::connect ( chbEnableOPUS64, SIGNAL ( stateChanged ( int ) ), + this, SLOT ( OnEnableOPUS64StateChanged ( int ) ) ); + // line edits QObject::connect ( edtCentralServerAddress, SIGNAL ( editingFinished() ), this, SLOT ( OnCentralServerAddressEditingFinished() ) ); @@ -607,12 +623,6 @@ void CClientSettingsDlg::OnNetBufServerValueChanged ( int value ) UpdateJitterBufferFrame(); } -void CClientSettingsDlg::OnSliderSndCrdBufferDelay ( int value ) -{ - pClient->SetSndCrdPrefFrameSizeFactor ( value ); - UpdateDisplay(); -} - void CClientSettingsDlg::OnSoundcardActivated ( int iSndDevIdx ) { const QString strError = pClient->SetSndCrdDev ( iSndDevIdx ); @@ -684,6 +694,12 @@ void CClientSettingsDlg::OnAutoJitBufStateChanged ( int value ) UpdateJitterBufferFrame(); } +void CClientSettingsDlg::OnEnableOPUS64StateChanged ( int value ) +{ + pClient->SetEnableOPUS64 ( value == Qt::Checked ); + UpdateDisplay(); +} + void CClientSettingsDlg::OnGUIDesignFancyStateChanged ( int value ) { if ( value == Qt::Unchecked ) diff --git a/src/clientsettingsdlg.h b/src/clientsettingsdlg.h index 23b2aad7..330c44b3 100755 --- a/src/clientsettingsdlg.h +++ b/src/clientsettingsdlg.h @@ -87,10 +87,10 @@ protected: void OnTimerStatus() { UpdateDisplay(); } void OnNetBufValueChanged ( int value ); void OnNetBufServerValueChanged ( int value ); - void OnSliderSndCrdBufferDelay ( int value ); void OnAutoJitBufStateChanged ( int value ); void OnGUIDesignFancyStateChanged ( int value ); void OnDisplayChannelLevelsStateChanged ( int value ); + void OnEnableOPUS64StateChanged ( int value ); void OnCentralServerAddressEditingFinished(); void OnNewClientLevelEditingFinished(); void OnSndCrdBufferDelayButtonGroupClicked ( QAbstractButton* button ); diff --git a/src/clientsettingsdlgbase.ui b/src/clientsettingsdlgbase.ui index 5028d30f..170ed677 100755 --- a/src/clientsettingsdlgbase.ui +++ b/src/clientsettingsdlgbase.ui @@ -6,8 +6,8 @@ 0 0 - 567 - 371 + 575 + 394 @@ -207,6 +207,13 @@ + + + + Enable Small Network Buffers + + + @@ -715,6 +722,7 @@ cbxRInChan cbxLOutChan cbxROutChan + chbEnableOPUS64 rbtBufferDelayPreferred rbtBufferDelayDefault rbtBufferDelaySafe diff --git a/src/settings.cpp b/src/settings.cpp index 69953a72..fc7cc7bc 100755 --- a/src/settings.cpp +++ b/src/settings.cpp @@ -243,6 +243,12 @@ void CSettings::Load() pClient->SetServerSockBufNumFrames ( iValue ); } + // enable OPUS64 setting + if ( GetFlagIniSet ( IniXMLDocument, "client", "enableopussmall", bValue ) ) + { + pClient->SetEnableOPUS64 ( bValue ); + } + // GUI design if ( GetNumericIniSet ( IniXMLDocument, "client", "guidesign", 0, 1 /* GD_ORIGINAL */, iValue ) ) @@ -531,6 +537,10 @@ void CSettings::Save() SetNumericIniSet ( IniXMLDocument, "client", "jitbufserver", pClient->GetServerSockBufNumFrames() ); + // enable OPUS64 setting + SetFlagIniSet ( IniXMLDocument, "client", "enableopussmall", + pClient->GetEnableOPUS64() ); + // GUI design SetNumericIniSet ( IniXMLDocument, "client", "guidesign", static_cast ( pClient->GetGUIDesign() ) );