Merge pull request #1 from corrados/master

update
This commit is contained in:
ignotus 2020-06-07 15:58:02 +02:00 committed by GitHub
commit 88064b5d20
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
8 changed files with 135 additions and 128 deletions

View file

@ -71,8 +71,8 @@ CAnalyzerConsole::CAnalyzerConsole ( CClient* pNCliP,
// Connections ------------------------------------------------------------- // Connections -------------------------------------------------------------
// timers // timers
QObject::connect ( &TimerErrRateUpdate, SIGNAL ( timeout() ), QObject::connect ( &TimerErrRateUpdate, &QTimer::timeout,
this, SLOT ( OnTimerErrRateUpdate() ) ); this, &CAnalyzerConsole::OnTimerErrRateUpdate );
} }
void CAnalyzerConsole::showEvent ( QShowEvent* ) void CAnalyzerConsole::showEvent ( QShowEvent* )

View file

@ -400,26 +400,26 @@ CClientSettingsDlg::CClientSettingsDlg ( CClient* pNCliP, QWidget* parent,
this, &CClientSettingsDlg::OnNewClientLevelEditingFinished ); this, &CClientSettingsDlg::OnNewClientLevelEditingFinished );
// combo boxes // combo boxes
QObject::connect ( cbxSoundcard, SIGNAL ( activated ( int ) ), QObject::connect ( cbxSoundcard, static_cast<void (QComboBox::*) ( int )> ( &QComboBox::activated ),
this, SLOT ( OnSoundcardActivated ( int ) ) ); this, &CClientSettingsDlg::OnSoundcardActivated );
QObject::connect ( cbxLInChan, SIGNAL ( activated ( int ) ), QObject::connect ( cbxLInChan, static_cast<void (QComboBox::*) ( int )> ( &QComboBox::activated ),
this, SLOT ( OnLInChanActivated ( int ) ) ); this, &CClientSettingsDlg::OnLInChanActivated );
QObject::connect ( cbxRInChan, SIGNAL ( activated ( int ) ), QObject::connect ( cbxRInChan, static_cast<void (QComboBox::*) ( int )> ( &QComboBox::activated ),
this, SLOT ( OnRInChanActivated ( int ) ) ); this, &CClientSettingsDlg::OnRInChanActivated );
QObject::connect ( cbxLOutChan, SIGNAL ( activated ( int ) ), QObject::connect ( cbxLOutChan, static_cast<void (QComboBox::*) ( int )> ( &QComboBox::activated ),
this, SLOT ( OnLOutChanActivated ( int ) ) ); this, &CClientSettingsDlg::OnLOutChanActivated );
QObject::connect ( cbxROutChan, SIGNAL ( activated ( int ) ), QObject::connect ( cbxROutChan, static_cast<void (QComboBox::*) ( int )> ( &QComboBox::activated ),
this, SLOT ( OnROutChanActivated ( int ) ) ); this, &CClientSettingsDlg::OnROutChanActivated );
QObject::connect ( cbxAudioChannels, SIGNAL ( activated ( int ) ), QObject::connect ( cbxAudioChannels, static_cast<void (QComboBox::*) ( int )> ( &QComboBox::activated ),
this, SLOT ( OnAudioChannelsActivated ( int ) ) ); this, &CClientSettingsDlg::OnAudioChannelsActivated );
QObject::connect ( cbxAudioQuality, SIGNAL ( activated ( int ) ), QObject::connect ( cbxAudioQuality, static_cast<void (QComboBox::*) ( int )> ( &QComboBox::activated ),
this, SLOT ( OnAudioQualityActivated ( int ) ) ); this, &CClientSettingsDlg::OnAudioQualityActivated );
// buttons // buttons
QObject::connect ( butDriverSetup, &QPushButton::clicked, QObject::connect ( butDriverSetup, &QPushButton::clicked,
@ -427,8 +427,8 @@ CClientSettingsDlg::CClientSettingsDlg ( CClient* pNCliP, QWidget* parent,
// misc // misc
QObject::connect ( &SndCrdBufferDelayButtonGroup, QObject::connect ( &SndCrdBufferDelayButtonGroup,
SIGNAL ( buttonClicked ( QAbstractButton* ) ), this, static_cast<void (QButtonGroup::*) ( QAbstractButton* )> ( &QButtonGroup::buttonClicked ),
SLOT ( OnSndCrdBufferDelayButtonGroupClicked ( QAbstractButton* ) ) ); this, &CClientSettingsDlg::OnSndCrdBufferDelayButtonGroupClicked );
// Timers ------------------------------------------------------------------ // Timers ------------------------------------------------------------------

View file

@ -169,8 +169,8 @@ CConnectDlg::CConnectDlg ( CClient* pNCliP,
QObject::connect ( cbxServerAddr, &QComboBox::editTextChanged, QObject::connect ( cbxServerAddr, &QComboBox::editTextChanged,
this, &CConnectDlg::OnServerAddrEditTextChanged ); this, &CConnectDlg::OnServerAddrEditTextChanged );
QObject::connect ( cbxCentServAddrType, SIGNAL ( activated ( int ) ), QObject::connect ( cbxCentServAddrType, static_cast<void (QComboBox::*) ( int )> ( &QComboBox::activated ),
this, SLOT ( OnCentServAddrTypeChanged ( int ) ) ); this, &CConnectDlg::OnCentServAddrTypeChanged );
// check boxes // check boxes
QObject::connect ( chbExpandAll, &QCheckBox::stateChanged, QObject::connect ( chbExpandAll, &QCheckBox::stateChanged,

View file

@ -59,8 +59,8 @@ CHighPrecisionTimer::CHighPrecisionTimer ( const bool bNewUseDoubleSystemFrameSi
veciTimeOutIntervals[2] = 0; veciTimeOutIntervals[2] = 0;
// connect timer timeout signal // connect timer timeout signal
QObject::connect ( &Timer, SIGNAL ( timeout() ), QObject::connect ( &Timer, &QTimer::timeout,
this, SLOT ( OnTimer() ) ); this, &CHighPrecisionTimer::OnTimer );
} }
void CHighPrecisionTimer::Start() void CHighPrecisionTimer::Start()
@ -238,6 +238,7 @@ CServer::CServer ( const int iNewMaxNumChan,
iMaxNumChannels ( iNewMaxNumChan ), iMaxNumChannels ( iNewMaxNumChan ),
Socket ( this, iPortNumber ), Socket ( this, iPortNumber ),
Logging ( iMaxDaysHistory ), Logging ( iMaxDaysHistory ),
iFrameCount ( 0 ),
JamRecorder ( strRecordingDirName ), JamRecorder ( strRecordingDirName ),
bWriteStatusHTMLFile ( false ), bWriteStatusHTMLFile ( false ),
HighPrecisionTimer ( bNUseDoubleSystemFrameSize ), HighPrecisionTimer ( bNUseDoubleSystemFrameSize ),
@ -752,22 +753,14 @@ void CServer::Stop()
void CServer::OnTimer() void CServer::OnTimer()
{ {
int i, j, iUnused;
int iClientFrameSizeSamples = 0; // initialize to avoid a compiler warning
OpusCustomDecoder* CurOpusDecoder;
OpusCustomEncoder* CurOpusEncoder;
unsigned char* pCurCodedData;
/* /*
// TEST do a timer jitter measurement static CTimingMeas JitterMeas ( 1000, "test2.dat" ); JitterMeas.Measure(); // TEST do a timer jitter measurement
static CTimingMeas JitterMeas ( 1000, "test2.dat" );
JitterMeas.Measure();
*/ */
// Get data from all connected clients ------------------------------------- // Get data from all connected clients -------------------------------------
// some inits // some inits
int iNumClients = 0; // init connected client counter int iNumClients = 0; // init connected client counter
bool bChannelIsNowDisconnected = false; bool bChannelIsNowDisconnected = false;
bool bUpdateChannelLevels = false;
bool bSendChannelLevels = false; bool bSendChannelLevels = false;
// Make put and get calls thread safe. Do not forget to unlock mutex // Make put and get calls thread safe. Do not forget to unlock mutex
@ -775,7 +768,7 @@ JitterMeas.Measure();
Mutex.lock(); Mutex.lock();
{ {
// first, get number and IDs of connected channels // first, get number and IDs of connected channels
for ( i = 0; i < iMaxNumChannels; i++ ) for ( int i = 0; i < iMaxNumChannels; i++ )
{ {
if ( vecChannels[i].IsConnected() ) if ( vecChannels[i].IsConnected() )
{ {
@ -789,8 +782,12 @@ JitterMeas.Measure();
} }
// process connected channels // process connected channels
for ( i = 0; i < iNumClients; i++ ) for ( int i = 0; i < iNumClients; i++ )
{ {
int iClientFrameSizeSamples = 0; // initialize to avoid a compiler warning
OpusCustomDecoder* CurOpusDecoder;
unsigned char* pCurCodedData;
// get actual ID of current channel // get actual ID of current channel
const int iCurChanID = vecChanIDsCurConChan[i]; const int iCurChanID = vecChanIDsCurConChan[i];
@ -850,7 +847,7 @@ JitterMeas.Measure();
} }
// get gains of all connected channels // get gains of all connected channels
for ( j = 0; j < iNumClients; j++ ) for ( int j = 0; j < iNumClients; j++ )
{ {
// The second index of "vecvecdGains" does not represent // The second index of "vecvecdGains" does not represent
// the channel ID! Therefore we have to use // the channel ID! Therefore we have to use
@ -865,6 +862,12 @@ JitterMeas.Measure();
vecvecdPannings[i][j] = vecChannels[iCurChanID].GetPan ( vecChanIDsCurConChan[j] ); vecvecdPannings[i][j] = vecChannels[iCurChanID].GetPan ( vecChanIDsCurConChan[j] );
} }
// flag for updating channel levels (if at least one clients wants it)
if ( vecChannels[iCurChanID].ChannelLevelsRequired() )
{
bUpdateChannelLevels = true;
}
// If the server frame size is smaller than the received OPUS frame size, we need a conversion // If the server frame size is smaller than the received OPUS frame size, we need a conversion
// buffer which stores the large buffer. // buffer which stores the large buffer.
// Note that we have a shortcut here. If the conversion buffer is not needed, the boolean flag // Note that we have a shortcut here. If the conversion buffer is not needed, the boolean flag
@ -908,11 +911,11 @@ JitterMeas.Measure();
// OPUS decode received data stream // OPUS decode received data stream
if ( CurOpusDecoder != nullptr ) if ( CurOpusDecoder != nullptr )
{ {
iUnused = opus_custom_decode ( CurOpusDecoder, Q_UNUSED ( opus_custom_decode ( CurOpusDecoder,
pCurCodedData, pCurCodedData,
iCeltNumCodedBytes, iCeltNumCodedBytes,
&vecvecsData[i][iB * SYSTEM_FRAME_SIZE_SAMPLES * vecNumAudioChannels[i]], &vecvecsData[i][iB * SYSTEM_FRAME_SIZE_SAMPLES * vecNumAudioChannels[i]],
iClientFrameSizeSamples ); iClientFrameSizeSamples ) );
} }
} }
@ -941,35 +944,20 @@ JitterMeas.Measure();
// one client is connected. // one client is connected.
if ( iNumClients > 0 ) if ( iNumClients > 0 )
{ {
// low frequency updates // calculate levels for all connected clients
if ( iFrameCount > CHANNEL_LEVEL_UPDATE_INTERVAL ) if ( bUpdateChannelLevels )
{ {
iFrameCount = 0; bSendChannelLevels = CreateLevelsForAllConChannels ( iNumClients,
// Calculate channel levels if any client has requested them
for ( int i = 0; i < iNumClients; i++ )
{
if ( vecChannels[vecChanIDsCurConChan[i]].ChannelLevelsRequired() )
{
bSendChannelLevels = true;
CreateLevelsForAllConChannels ( iNumClients,
vecNumAudioChannels, vecNumAudioChannels,
vecvecsData, vecvecsData,
vecChannelLevels ); vecChannelLevels );
break;
}
}
}
iFrameCount++;
if ( bUseDoubleSystemFrameSize )
{
// additional increment needed for double frame size to get to the same time interval
iFrameCount++;
} }
for ( int i = 0; i < iNumClients; i++ ) for ( int i = 0; i < iNumClients; i++ )
{ {
int iClientFrameSizeSamples = 0; // initialize to avoid a compiler warning
OpusCustomEncoder* CurOpusEncoder;
// get actual ID of current channel // get actual ID of current channel
const int iCurChanID = vecChanIDsCurConChan[i]; const int iCurChanID = vecChanIDsCurConChan[i];
@ -1056,11 +1044,11 @@ JitterMeas.Measure();
opus_custom_encoder_ctl ( CurOpusEncoder, opus_custom_encoder_ctl ( CurOpusEncoder,
OPUS_SET_BITRATE ( CalcBitRateBitsPerSecFromCodedBytes ( iCeltNumCodedBytes, iClientFrameSizeSamples ) ) ); OPUS_SET_BITRATE ( CalcBitRateBitsPerSecFromCodedBytes ( iCeltNumCodedBytes, iClientFrameSizeSamples ) ) );
iUnused = opus_custom_encode ( CurOpusEncoder, Q_UNUSED ( opus_custom_encode ( CurOpusEncoder,
&vecsSendData[iB * SYSTEM_FRAME_SIZE_SAMPLES * vecNumAudioChannels[i]], &vecsSendData[iB * SYSTEM_FRAME_SIZE_SAMPLES * vecNumAudioChannels[i]],
iClientFrameSizeSamples, iClientFrameSizeSamples,
&vecbyCodedData[0], &vecbyCodedData[0],
iCeltNumCodedBytes ); iCeltNumCodedBytes ) );
} }
// send separate mix to current clients // send separate mix to current clients
@ -1075,7 +1063,9 @@ opus_custom_encoder_ctl ( CurOpusEncoder,
// send channel levels // send channel levels
if ( bSendChannelLevels && vecChannels[iCurChanID].ChannelLevelsRequired() ) if ( bSendChannelLevels && vecChannels[iCurChanID].ChannelLevelsRequired() )
{ {
ConnLessProtocol.CreateCLChannelLevelListMes ( vecChannels[iCurChanID].GetAddress(), vecChannelLevels, iNumClients ); ConnLessProtocol.CreateCLChannelLevelListMes ( vecChannels[iCurChanID].GetAddress(),
vecChannelLevels,
iNumClients );
} }
} }
} }
@ -1086,8 +1076,6 @@ opus_custom_encoder_ctl ( CurOpusEncoder,
// does not consume any significant CPU when no client is connected. // does not consume any significant CPU when no client is connected.
Stop(); Stop();
} }
Q_UNUSED ( iUnused )
} }
/// @brief Mix all audio data from all clients together. /// @brief Mix all audio data from all clients together.
@ -1558,12 +1546,19 @@ void CServer::customEvent ( QEvent* pEvent )
} }
/// @brief Compute frame peak level for each client /// @brief Compute frame peak level for each client
void CServer::CreateLevelsForAllConChannels ( const int iNumClients, bool CServer::CreateLevelsForAllConChannels ( const int iNumClients,
const CVector<int>& vecNumAudioChannels, const CVector<int>& vecNumAudioChannels,
const CVector<CVector<int16_t> > vecvecsData, const CVector<CVector<int16_t> > vecvecsData,
CVector<uint16_t>& vecLevelsOut ) CVector<uint16_t>& vecLevelsOut )
{ {
int i, j, k; int i, j, k;
bool bLevelsWereUpdated = false;
// low frequency updates
if ( iFrameCount > CHANNEL_LEVEL_UPDATE_INTERVAL )
{
iFrameCount = 0;
bLevelsWereUpdated = true;
// init return vector with zeros since we mix all channels on that vector // init return vector with zeros since we mix all channels on that vector
vecLevelsOut.Reset ( 0 ); vecLevelsOut.Reset ( 0 );
@ -1612,4 +1607,16 @@ void CServer::CreateLevelsForAllConChannels ( const int i
vecLevelsOut[j] = static_cast<uint16_t> ( ceil ( dCurSigLevel ) ); vecLevelsOut[j] = static_cast<uint16_t> ( ceil ( dCurSigLevel ) );
} }
}
// increment the frame counter needed for low frequency update trigger
iFrameCount++;
if ( bUseDoubleSystemFrameSize )
{
// additional increment needed for double frame size to get to the same time interval
iFrameCount++;
}
return bLevelsWereUpdated;
} }

View file

@ -298,7 +298,7 @@ protected:
bool bUseDoubleSystemFrameSize; bool bUseDoubleSystemFrameSize;
int iServerFrameSizeSamples; int iServerFrameSizeSamples;
void CreateLevelsForAllConChannels ( const int iNumClients, bool CreateLevelsForAllConChannels ( const int iNumClients,
const CVector<int>& vecNumAudioChannels, const CVector<int>& vecNumAudioChannels,
const CVector<CVector<int16_t> > vecvecsData, const CVector<CVector<int16_t> > vecvecsData,
CVector<uint16_t>& vecLevelsOut ); CVector<uint16_t>& vecLevelsOut );
@ -347,7 +347,7 @@ protected:
CServerLogging Logging; CServerLogging Logging;
// channel level update frame interval counter // channel level update frame interval counter
uint16_t iFrameCount; int iFrameCount;
// recording thread // recording thread
recorder::CJamRecorder JamRecorder; recorder::CJamRecorder JamRecorder;

View file

@ -357,11 +357,11 @@ lvwClients->setMinimumHeight ( 140 );
this, &CServerDlg::OnLocationCityTextChanged ); this, &CServerDlg::OnLocationCityTextChanged );
// combo boxes // combo boxes
QObject::connect ( cbxLocationCountry, SIGNAL ( activated ( int ) ), QObject::connect ( cbxLocationCountry, static_cast<void (QComboBox::*) ( int )> ( &QComboBox::activated ),
this, SLOT ( OnLocationCountryActivated ( int ) ) ); this, &CServerDlg::OnLocationCountryActivated );
QObject::connect ( cbxCentServAddrType, SIGNAL ( activated ( int ) ), QObject::connect ( cbxCentServAddrType, static_cast<void (QComboBox::*) ( int )> ( &QComboBox::activated ),
this, SLOT ( OnCentServAddrTypeActivated ( int ) ) ); this, &CServerDlg::OnCentServAddrTypeActivated );
// push buttons // push buttons
QObject::connect ( pbtNewRecording, &QPushButton::released, QObject::connect ( pbtNewRecording, &QPushButton::released,

View file

@ -117,8 +117,8 @@ void CSocket::Init ( const quint16 iPortNumber )
QObject::connect ( this, &CSocket::ProtcolCLMessageReceived, QObject::connect ( this, &CSocket::ProtcolCLMessageReceived,
pChannel, &CChannel::OnProtcolCLMessageReceived ); pChannel, &CChannel::OnProtcolCLMessageReceived );
QObject::connect ( this, SIGNAL ( NewConnection() ), QObject::connect ( this, static_cast<void (CSocket::*)()> ( &CSocket::NewConnection ),
pChannel, SLOT ( OnNewConnection() ) ); pChannel, &CChannel::OnNewConnection );
} }
else else
{ {
@ -130,8 +130,8 @@ void CSocket::Init ( const quint16 iPortNumber )
QObject::connect ( this, &CSocket::ProtcolCLMessageReceived, QObject::connect ( this, &CSocket::ProtcolCLMessageReceived,
pServer, &CServer::OnProtcolCLMessageReceived ); pServer, &CServer::OnProtcolCLMessageReceived );
QObject::connect ( this, SIGNAL ( NewConnection ( int, CHostAddress ) ), QObject::connect ( this, static_cast<void (CSocket::*) ( int, CHostAddress )> ( &CSocket::NewConnection ),
pServer, SLOT ( OnNewConnection ( int, CHostAddress ) ) ); pServer, &CServer::OnNewConnection );
QObject::connect ( this, &CSocket::ServerFull, QObject::connect ( this, &CSocket::ServerFull,
pServer, &CServer::OnServerFull ); pServer, &CServer::OnServerFull );

View file

@ -731,17 +731,17 @@ CMusProfDlg::CMusProfDlg ( CClient* pNCliP,
QObject::connect ( pedtAlias, &QLineEdit::textChanged, QObject::connect ( pedtAlias, &QLineEdit::textChanged,
this, &CMusProfDlg::OnAliasTextChanged ); this, &CMusProfDlg::OnAliasTextChanged );
QObject::connect ( pcbxInstrument, SIGNAL ( activated ( int ) ), QObject::connect ( pcbxInstrument, static_cast<void (QComboBox::*) ( int )> ( &QComboBox::activated ),
this, SLOT ( OnInstrumentActivated ( int ) ) ); this, &CMusProfDlg::OnInstrumentActivated );
QObject::connect ( pcbxCountry, SIGNAL ( activated ( int ) ), QObject::connect ( pcbxCountry, static_cast<void (QComboBox::*) ( int )> ( &QComboBox::activated ),
this, SLOT ( OnCountryActivated ( int ) ) ); this, &CMusProfDlg::OnCountryActivated );
QObject::connect ( pedtCity, &QLineEdit::textChanged, QObject::connect ( pedtCity, &QLineEdit::textChanged,
this, &CMusProfDlg::OnCityTextChanged ); this, &CMusProfDlg::OnCityTextChanged );
QObject::connect ( pcbxSkill, SIGNAL ( activated ( int ) ), QObject::connect ( pcbxSkill, static_cast<void (QComboBox::*) ( int )> ( &QComboBox::activated ),
this, SLOT ( OnSkillActivated ( int ) ) ); this, &CMusProfDlg::OnSkillActivated );
QObject::connect ( butClose, &QPushButton::clicked, QObject::connect ( butClose, &QPushButton::clicked,
this, &CMusProfDlg::accept ); this, &CMusProfDlg::accept );