diff --git a/src/client.cpp b/src/client.cpp index ef68a111..b1ceeedf 100755 --- a/src/client.cpp +++ b/src/client.cpp @@ -56,7 +56,7 @@ CClient::CClient ( const quint16 iPortNumber, eAudioChannelConf ( CC_MONO ), iNumAudioChannels ( 1 ), bIsInitializationPhase ( true ), - bMuteInputAndOutput ( false ), + bMuteOutStream ( false ), Socket ( &Channel, iPortNumber ), Sound ( AudioCallback, this, iCtrlMIDIChannel, bNoAutoJackConnect ), iAudioInFader ( AUD_FADER_IN_MIDDLE ), @@ -807,6 +807,8 @@ void CClient::Init() iStereoBlockSizeSam = 2 * iMonoBlockSizeSam; vecCeltData.Init ( iCeltNumCodedBytes ); + vecZeros.Init ( iStereoBlockSizeSam, 0 ); + vecsStereoSndCrdTMP.Init ( iStereoBlockSizeSam ); opus_custom_encoder_ctl ( CurOpusEncoder, OPUS_SET_BITRATE ( @@ -841,13 +843,11 @@ void CClient::Init() // the output conversion buffer must be filled with the inner // block size for initialization (this is the latency which is // introduced by the conversion buffer) to avoid buffer underruns - const CVector vZeros ( iStereoBlockSizeSam, 0 ); - SndCrdConversionBufferOut.Put ( vZeros, vZeros.Size() ); + SndCrdConversionBufferOut.Put ( vecZeros, iStereoBlockSizeSam ); } // reset initialization phase flag and mute flag bIsInitializationPhase = true; - bMuteInputAndOutput = false; } void CClient::AudioCallback ( CVector& psData, void* arg ) @@ -868,12 +868,6 @@ static CTimingMeas JitterMeas ( 1000, "test2.dat" ); JitterMeas.Measure(); */ - // mute input if requested - if ( bMuteInputAndOutput ) - { - vecsStereoSndCrd.Reset ( 0 ); - } - // check if a conversion buffer is required or not if ( bSndCrdConversionBufferRequired ) { @@ -901,12 +895,6 @@ JitterMeas.Measure(); // process audio data ProcessAudioDataIntern ( vecsStereoSndCrd ); } - - // mute output if requested - if ( bMuteInputAndOutput ) - { - vecsStereoSndCrd.Reset ( 0 ); - } } void CClient::ProcessAudioDataIntern ( CVector& vecsStereoSndCrd ) @@ -1058,11 +1046,22 @@ void CClient::ProcessAudioDataIntern ( CVector& vecsStereoSndCrd ) // OPUS encoding if ( CurOpusEncoder != nullptr ) { - opus_custom_encode ( CurOpusEncoder, - &vecsStereoSndCrd[i * iNumAudioChannels * iOPUSFrameSizeSamples], - iOPUSFrameSizeSamples, - &vecCeltData[0], - iCeltNumCodedBytes ); + if ( bMuteOutStream ) + { + opus_custom_encode ( CurOpusEncoder, + &vecZeros[i * iNumAudioChannels * iOPUSFrameSizeSamples], + iOPUSFrameSizeSamples, + &vecCeltData[0], + iCeltNumCodedBytes ); + } + else + { + opus_custom_encode ( CurOpusEncoder, + &vecsStereoSndCrd[i * iNumAudioChannels * iOPUSFrameSizeSamples], + iOPUSFrameSizeSamples, + &vecCeltData[0], + iCeltNumCodedBytes ); + } } // send coded audio through the network @@ -1073,6 +1072,12 @@ void CClient::ProcessAudioDataIntern ( CVector& vecsStereoSndCrd ) // Receive signal ---------------------------------------------------------- + // in case of mute stream, store local data + if ( bMuteOutStream ) + { + vecsStereoSndCrdTMP = vecsStereoSndCrd; + } + for ( i = 0; i < iSndCrdFrameSizeFactor; i++ ) { // receive a new block @@ -1120,6 +1125,16 @@ for (i = 0; i < iMonoBlockSizeSam; i++) fflush(pFileDelay); */ + + // for muted stream we have to add our local data here + if ( bMuteOutStream ) + { + for ( i = 0; i < iStereoBlockSizeSam; i++ ) + { + vecsStereoSndCrd[i] += vecsStereoSndCrdTMP[i]; + } + } + // check if channel is connected and if we do not have the initialization phase if ( Channel.IsConnected() && ( !bIsInitializationPhase ) ) { diff --git a/src/client.h b/src/client.h index 0c98934d..99e731d2 100755 --- a/src/client.h +++ b/src/client.h @@ -236,7 +236,7 @@ public: bool GetFraSiFactDefSupported() { return bFraSiFactDefSupported; } bool GetFraSiFactSafeSupported() { return bFraSiFactSafeSupported; } - void SetMuteInputAndOutputState ( const bool bDoMute ) { bMuteInputAndOutput = bDoMute; } + void SetMuteOutStream ( const bool bDoMute ) { bMuteOutStream = bDoMute; } void SetRemoteChanGain ( const int iId, const double dGain ) { Channel.SetRemoteChanGain ( iId, dGain ); } @@ -331,7 +331,7 @@ protected: EAudChanConf eAudioChannelConf; int iNumAudioChannels; bool bIsInitializationPhase; - bool bMuteInputAndOutput; + bool bMuteOutStream; CVector vecCeltData; CHighPrioSocket Socket; @@ -354,6 +354,8 @@ protected: CBufferBase SndCrdConversionBufferIn; CBufferBase SndCrdConversionBufferOut; CVector vecDataConvBuf; + CVector vecsStereoSndCrdTMP; + CVector vecZeros; bool bFraSiFactPrefSupported; bool bFraSiFactDefSupported; diff --git a/src/clientdlg.cpp b/src/clientdlg.cpp index 94b6d191..2fe2a3bf 100755 --- a/src/clientdlg.cpp +++ b/src/clientdlg.cpp @@ -416,8 +416,8 @@ CClientDlg::CClientDlg ( CClient* pNCliP, QObject::connect ( chbChat, SIGNAL ( stateChanged ( int ) ), this, SLOT ( OnChatStateChanged ( int ) ) ); - QObject::connect ( chbProfile, SIGNAL ( stateChanged ( int ) ), - this, SLOT ( OnProfileStateChanged ( int ) ) ); + QObject::connect ( chbLocalMute, SIGNAL ( stateChanged ( int ) ), + this, SLOT ( OnLocalMuteStateChanged ( int ) ) ); // timers QObject::connect ( &TimerSigMet, SIGNAL ( timeout() ), @@ -769,8 +769,8 @@ void CClientDlg::OnLicenceRequired ( ELicenceType eLicenceType ) { CLicenceDlg LicenceDlg; - // mute the client - pClient->SetMuteInputAndOutputState ( true ); + // mute the client output stream + pClient->SetMuteOutStream ( true ); // Open the licence dialog and check if the licence was accepted. In // case the dialog is just closed or the decline button was pressed, @@ -780,8 +780,11 @@ void CClientDlg::OnLicenceRequired ( ELicenceType eLicenceType ) Disconnect(); } - // unmute the client - pClient->SetMuteInputAndOutputState ( false ); + // unmute the client output stream if local mute button is not pressed + if ( chbLocalMute->checkState() == Qt::Unchecked ) + { + pClient->SetMuteOutStream ( false ); + } } } @@ -923,16 +926,9 @@ void CClientDlg::OnChatStateChanged ( int value ) } } -void CClientDlg::OnProfileStateChanged ( int value ) +void CClientDlg::OnLocalMuteStateChanged ( int value ) { - if ( value == Qt::Checked ) - { - ShowMusicianProfileDialog(); - } - else - { - MusicianProfileDlg.hide(); - } + pClient->SetMuteOutStream ( value == Qt::Checked ); } void CClientDlg::OnTimerSigMet() @@ -1166,19 +1162,6 @@ void CClientDlg::UpdateDisplay() chbChat->setChecked ( true ); chbChat->blockSignals ( false ); } - - if ( chbProfile->isChecked() && !MusicianProfileDlg.isVisible() ) - { - chbProfile->blockSignals ( true ); - chbProfile->setChecked ( false ); - chbProfile->blockSignals ( false ); - } - if ( !chbProfile->isChecked() && MusicianProfileDlg.isVisible() ) - { - chbProfile->blockSignals ( true ); - chbProfile->setChecked ( true ); - chbProfile->blockSignals ( false ); - } } void CClientDlg::SetGUIDesign ( const EGUIDesign eNewDesign ) diff --git a/src/clientdlg.h b/src/clientdlg.h index bdfb4adb..5d265574 100755 --- a/src/clientdlg.h +++ b/src/clientdlg.h @@ -150,7 +150,7 @@ public slots: void OnSettingsStateChanged ( int value ); void OnChatStateChanged ( int value ); - void OnProfileStateChanged ( int value ); + void OnLocalMuteStateChanged ( int value ); void OnAudioPanValueChanged ( int value ); diff --git a/src/clientdlgbase.ui b/src/clientdlgbase.ui index daf8a40d..b819ee5f 100755 --- a/src/clientdlgbase.ui +++ b/src/clientdlgbase.ui @@ -339,9 +339,9 @@ - + - My Profile + Mute Stream