Skip to content

Commit

Permalink
bug fix: do not reset sound card channel selection on a device proper…
Browse files Browse the repository at this point in the history
…ty change
  • Loading branch information
corrados committed Nov 22, 2020
1 parent e0c0b05 commit d8a5c6f
Show file tree
Hide file tree
Showing 8 changed files with 49 additions and 32 deletions.
2 changes: 2 additions & 0 deletions ChangeLog
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@

- added possibility to set MIDI offset for fader control to --ctrlmidich (#95)

- bug fix: do not reset sound card channel selection on a device property change

- bug fix: compiling Jamulus 3.6.1 is failing on Debian 9 Linode (#736)

- bug fix: on MacOS Jamulus does not always select the previous sound card (#680)
Expand Down
20 changes: 13 additions & 7 deletions mac/sound.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -331,16 +331,22 @@ QString CSound::LoadAndInitializeDriver ( QString strDriverName, bool )
{
// store ID of selected driver if initialization was successful
lCurDev = iDriverIdx;
strCurDevName = strDriverNames[iDriverIdx];
CurrentAudioInputDeviceID = audioInputDevice[iDriverIdx];
CurrentAudioOutputDeviceID = audioOutputDevice[iDriverIdx];

// the device has changed, per definition we reset the channel
// mapping to the defaults (first two available channels)
SetLeftInputChannel ( 0 );
SetRightInputChannel ( 1 );
SetLeftOutputChannel ( 0 );
SetRightOutputChannel ( 1 );
// only reset the channel mapping if a new device was selected
if ( strCurDevName.compare ( strDriverNames[iDriverIdx] ) != 0 )
{
// the device has changed, per definition we reset the channel
// mapping to the defaults (first two available channels)
SetLeftInputChannel ( 0 );
SetRightInputChannel ( 1 );
SetLeftOutputChannel ( 0 );
SetRightOutputChannel ( 1 );

// store the current name of the driver
strCurDevName = strDriverNames[iDriverIdx];
}
}

return strStat;
Expand Down
3 changes: 3 additions & 0 deletions src/client.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -639,6 +639,9 @@ void CClient::OnSndCrdReinitRequest ( int iSndCrdResetType )
// restart client
Sound.Start();
}

// inform GUI about the sound card device change
emit SoundDeviceChanged();
}

void CClient::OnHandledSignal ( int sigNum )
Expand Down
1 change: 1 addition & 0 deletions src/client.h
Original file line number Diff line number Diff line change
Expand Up @@ -420,5 +420,6 @@ protected slots:
CVector<uint16_t> vecLevelList );

void Disconnected();
void SoundDeviceChanged();
void ControllerInFaderLevel ( int iChannelIdx, int iValue );
};
3 changes: 3 additions & 0 deletions src/clientdlg.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -488,6 +488,9 @@ CClientDlg::CClientDlg ( CClient* pNCliP,
QObject::connect ( pClient, &CClient::CLVersionAndOSReceived,
this, &CClientDlg::OnCLVersionAndOSReceived );

QObject::connect ( pClient, &CClient::SoundDeviceChanged,
&ClientSettingsDlg, &CClientSettingsDlg::OnUpdateSoundDeviceChannelSelectionFrame );

QObject::connect ( &ClientSettingsDlg, &CClientSettingsDlg::GUIDesignChanged,
this, &CClientDlg::OnGUIDesignChanged );

Expand Down
34 changes: 16 additions & 18 deletions src/clientsettingsdlg.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -301,16 +301,8 @@ CClientSettingsDlg::CClientSettingsDlg ( CClient* pNCliP,
sldNetBufServer->setRange ( MIN_NET_BUF_SIZE_NUM_BL, MAX_NET_BUF_SIZE_NUM_BL );
UpdateJitterBufferFrame();

// init combo box containing all available sound cards in the system
cbxSoundcard->clear();
for ( int iSndDevIdx = 0; iSndDevIdx < pClient->GetSndCrdNumDev(); iSndDevIdx++ )
{
cbxSoundcard->addItem ( pClient->GetSndCrdDeviceName ( iSndDevIdx ) );
}
cbxSoundcard->setCurrentText ( pClient->GetSndCrdDev() );

// init sound card channel selection frame
UpdateSoundChannelSelectionFrame();
OnUpdateSoundDeviceChannelSelectionFrame();

// Audio Channels combo box
cbxAudioChannels->clear();
Expand Down Expand Up @@ -519,8 +511,17 @@ void CClientSettingsDlg::UpdateSoundCardFrame()
}
}

void CClientSettingsDlg::UpdateSoundChannelSelectionFrame()
void CClientSettingsDlg::OnUpdateSoundDeviceChannelSelectionFrame()
{
// update combo box containing all available sound cards in the system
cbxSoundcard->clear();
for ( int iSndDevIdx = 0; iSndDevIdx < pClient->GetSndCrdNumDev(); iSndDevIdx++ )
{
cbxSoundcard->addItem ( pClient->GetSndCrdDeviceName ( iSndDevIdx ) );
}
cbxSoundcard->setCurrentText ( pClient->GetSndCrdDev() );

// update input/output channel selection
#if defined ( _WIN32 ) || defined ( __APPLE__ ) || defined ( __MACOSX )
int iSndChanIdx;

Expand Down Expand Up @@ -601,36 +602,33 @@ void CClientSettingsDlg::OnSoundcardActivated ( int iSndDevIdx )
"because of the following error: " ) ) + strError +
QString ( tr ( " The previous driver will be selected." ) ),
tr ( "Ok" ), nullptr );

// recover old selection
cbxSoundcard->setCurrentText ( pClient->GetSndCrdDev() );
}
UpdateSoundChannelSelectionFrame();
OnUpdateSoundDeviceChannelSelectionFrame();
UpdateDisplay();
}

void CClientSettingsDlg::OnLInChanActivated ( int iChanIdx )
{
pClient->SetSndCrdLeftInputChannel ( iChanIdx );
UpdateSoundChannelSelectionFrame();
OnUpdateSoundDeviceChannelSelectionFrame();
}

void CClientSettingsDlg::OnRInChanActivated ( int iChanIdx )
{
pClient->SetSndCrdRightInputChannel ( iChanIdx );
UpdateSoundChannelSelectionFrame();
OnUpdateSoundDeviceChannelSelectionFrame();
}

void CClientSettingsDlg::OnLOutChanActivated ( int iChanIdx )
{
pClient->SetSndCrdLeftOutputChannel ( iChanIdx );
UpdateSoundChannelSelectionFrame();
OnUpdateSoundDeviceChannelSelectionFrame();
}

void CClientSettingsDlg::OnROutChanActivated ( int iChanIdx )
{
pClient->SetSndCrdRightOutputChannel ( iChanIdx );
UpdateSoundChannelSelectionFrame();
OnUpdateSoundDeviceChannelSelectionFrame();
}

void CClientSettingsDlg::OnAudioChannelsActivated ( int iChanIdx )
Expand Down
4 changes: 2 additions & 2 deletions src/clientsettingsdlg.h
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,6 @@ class CClientSettingsDlg : public QDialog, private Ui_CClientSettingsDlgBase
protected:
void UpdateJitterBufferFrame();
void UpdateSoundCardFrame();
void UpdateSoundChannelSelectionFrame();
void UpdateCustomCentralServerComboBox();
QString GenSndCrdBufferDelayString ( const int iFrameSize,
const QString strAddText = "" );
Expand All @@ -88,7 +87,7 @@ class CClientSettingsDlg : public QDialog, private Ui_CClientSettingsDlgBase
QTimer TimerStatus;
QButtonGroup SndCrdBufferDelayButtonGroup;

public slots:
public slots:
void OnTimerStatus() { UpdateDisplay(); }
void OnNetBufValueChanged ( int value );
void OnNetBufServerValueChanged ( int value );
Expand All @@ -107,6 +106,7 @@ class CClientSettingsDlg : public QDialog, private Ui_CClientSettingsDlgBase
void OnGUIDesignActivated ( int iDesignIdx );
void OnDriverSetupClicked();
void OnLanguageChanged ( QString strLanguage ) { pSettings->strLanguage = strLanguage; }
void OnUpdateSoundDeviceChannelSelectionFrame();

signals:
void GUIDesignChanged();
Expand Down
14 changes: 9 additions & 5 deletions windows/sound.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -69,12 +69,16 @@ QString CSound::LoadAndInitializeDriver ( QString strDriverName,
// check if device is capable
if ( strStat.isEmpty() )
{
// the device has changed, per definition we reset the channel
// mapping to the defaults (first two available channels)
ResetChannelMapping();
// only reset the channel mapping if a new device was selected
if ( strCurDevName.compare ( strDriverNames[iDriverIdx] ) != 0 )
{
// the device has changed, per definition we reset the channel
// mapping to the defaults (first two available channels)
ResetChannelMapping();

// store ID of selected driver if initialization was successful
strCurDevName = cDriverNames[iDriverIdx];
// store ID of selected driver if initialization was successful
strCurDevName = cDriverNames[iDriverIdx];
}
}
else
{
Expand Down

1 comment on commit d8a5c6f

@ann0see
Copy link
Member

@ann0see ann0see commented on d8a5c6f Feb 12, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Note to self: #796 Check if this code is related. I'm quite sure though.

Please sign in to comment.