Skip to content

Commit

Permalink
Fix intput/output devices show multiple times when changing Sound System
Browse files Browse the repository at this point in the history
  • Loading branch information
CoBC authored and bear101 committed Aug 14, 2024
1 parent 2fbba0f commit 737feeb
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 25 deletions.
46 changes: 22 additions & 24 deletions Client/qtTeamTalk/preferencesdlg.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -129,21 +129,10 @@ PreferencesDlg::PreferencesDlg(SoundDevice& devin, SoundDevice& devout, QWidget
this, &PreferencesDlg::slotDesktopAccess);

//sound tab
ui.sndSysBox->clear();
#if defined(Q_OS_WIN32)
ui.sndSysBox->addItem(tr("Windows Audio Session API (WASAPI)"), SOUNDSYSTEM_WASAPI);
ui.sndSysBox->addItem(tr("DirectSound"), SOUNDSYSTEM_DSOUND);
ui.sndSysBox->addItem(tr("Windows legacy audio system"), SOUNDSYSTEM_WINMM);
#elif defined(Q_OS_DARWIN)
ui.sndSysBox->addItem(tr("CoreAudio"), SOUNDSYSTEM_COREAUDIO);
ui.winfwChkBox->hide();
#else
ui.sndSysBox->addItem(tr("Advanced Linux Sound Architecture (ALSA)"), SOUNDSYSTEM_ALSA);
ui.sndSysBox->addItem(tr("PulseAudio"), SOUNDSYSTEM_PULSEAUDIO);
ui.winfwChkBox->hide();
#endif
connect(ui.sndSysBox, QOverload<int>::of(&QComboBox::currentIndexChanged),
this, &PreferencesDlg::slotSoundSystemChange);
connect(ui.sndSysBox, QOverload<int>::of(&QComboBox::currentIndexChanged), this, [&]()
{
showDevices(SoundSystem(ui.sndSysBox->currentData().toInt()));
});
connect(ui.inputdevBox, QOverload<int>::of(&QComboBox::currentIndexChanged),
this, &PreferencesDlg::slotSoundInputChange);
connect(ui.outputdevBox, QOverload<int>::of(&QComboBox::currentIndexChanged),
Expand Down Expand Up @@ -308,10 +297,6 @@ void PreferencesDlg::showDevices(SoundSystem snd)
ui.inputdevBox->clear();
ui.outputdevBox->clear();

int comboIndex = ui.sndSysBox->findData(snd);
if(comboIndex>=0)
ui.sndSysBox->setCurrentIndex(comboIndex);

SoundDevice dev;
int devid;
QString uid;
Expand Down Expand Up @@ -537,6 +522,8 @@ void PreferencesDlg::initConnectionTab()
QString appPath = QApplication::applicationFilePath();
appPath = QDir::toNativeSeparators(appPath);
ui.winfwChkBox->setChecked(TT_Firewall_AppExceptionExists(_W(appPath)));
#else
ui.winfwChkBox->hide();
#endif
ui.subusermsgChkBox->setChecked(ttSettings->value(SETTINGS_CONNECTION_SUBSCRIBE_USERMSG, SETTINGS_CONNECTION_SUBSCRIBE_USERMSG_DEFAULT).toBool());
ui.subchanmsgChkBox->setChecked(ttSettings->value(SETTINGS_CONNECTION_SUBSCRIBE_CHANNELMSG, SETTINGS_CONNECTION_SUBSCRIBE_CHANNELMSG_DEFAULT).toBool());
Expand All @@ -551,6 +538,22 @@ void PreferencesDlg::initConnectionTab()

void PreferencesDlg::initSoundSystemTab()
{
ui.sndSysBox->clear();
#if defined(Q_OS_WIN32)
ui.sndSysBox->addItem(tr("Windows Audio Session API (WASAPI)"), SOUNDSYSTEM_WASAPI);
ui.sndSysBox->addItem(tr("DirectSound"), SOUNDSYSTEM_DSOUND);
ui.sndSysBox->addItem(tr("Windows legacy audio system"), SOUNDSYSTEM_WINMM);
#elif defined(Q_OS_DARWIN)
ui.sndSysBox->addItem(tr("CoreAudio"), SOUNDSYSTEM_COREAUDIO);
ui.winfwChkBox->hide();
#else
ui.sndSysBox->addItem(tr("Advanced Linux Sound Architecture (ALSA)"), SOUNDSYSTEM_ALSA);
ui.sndSysBox->addItem(tr("PulseAudio"), SOUNDSYSTEM_PULSEAUDIO);
ui.winfwChkBox->hide();
#endif
int comboIndex = ui.sndSysBox->findData(SoundSystem(ttSettings->value(SETTINGS_SOUND_SOUNDSYSTEM, SOUNDSYSTEM_NONE).toInt()));
if(comboIndex>=0)
ui.sndSysBox->setCurrentIndex(comboIndex);
initDevices();
ui.mediavsvoiceSlider->setValue(ttSettings->value(SETTINGS_SOUND_MEDIASTREAM_VOLUME,
SETTINGS_SOUND_MEDIASTREAM_VOLUME_DEFAULT).toInt());
Expand Down Expand Up @@ -1134,11 +1137,6 @@ void PreferencesDlg::slotDesktopAccess()
dlg.exec();
}

void PreferencesDlg::slotSoundSystemChange()
{
showDevices(getSoundSystem());
}

void PreferencesDlg::slotSoundInputChange(int index)
{
int channels = 0;
Expand Down
1 change: 0 additions & 1 deletion Client/qtTeamTalk/preferencesdlg.h
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,6 @@ class PreferencesDlg : public QDialog
SoundSystem getSoundSystem();
void showDevices(SoundSystem snd);
QVector<SoundDevice> m_sounddevices;
void slotSoundSystemChange();
void slotSoundInputChange(int index);
void slotSoundOutputChange(int index);
void slotSoundRestart();
Expand Down

0 comments on commit 737feeb

Please sign in to comment.