support Mute button for own audio #75
This commit is contained in:
parent
ce647535d8
commit
ad3e4e0587
5 changed files with 54 additions and 54 deletions
|
@ -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<int16_t> 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<int16_t>& 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<int16_t>& vecsStereoSndCrd )
|
||||
|
@ -1058,11 +1046,22 @@ void CClient::ProcessAudioDataIntern ( CVector<int16_t>& 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<int16_t>& 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 ) )
|
||||
{
|
||||
|
|
|
@ -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<unsigned char> vecCeltData;
|
||||
|
||||
CHighPrioSocket Socket;
|
||||
|
@ -354,6 +354,8 @@ protected:
|
|||
CBufferBase<int16_t> SndCrdConversionBufferIn;
|
||||
CBufferBase<int16_t> SndCrdConversionBufferOut;
|
||||
CVector<int16_t> vecDataConvBuf;
|
||||
CVector<int16_t> vecsStereoSndCrdTMP;
|
||||
CVector<int16_t> vecZeros;
|
||||
|
||||
bool bFraSiFactPrefSupported;
|
||||
bool bFraSiFactDefSupported;
|
||||
|
|
|
@ -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 )
|
||||
|
|
|
@ -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 );
|
||||
|
||||
|
|
|
@ -339,9 +339,9 @@
|
|||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QCheckBox" name="chbProfile">
|
||||
<widget class="QCheckBox" name="chbLocalMute">
|
||||
<property name="text">
|
||||
<string>My Profile</string>
|
||||
<string>Mute Stream</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
|
|
Loading…
Reference in a new issue