Skip to content

Commit

Permalink
Sound options: force an autodetect if the current sound system is not…
Browse files Browse the repository at this point in the history
… valid
  • Loading branch information
ctrlaltca committed Aug 2, 2024
1 parent 5908b59 commit 1b045ba
Showing 1 changed file with 18 additions and 20 deletions.
38 changes: 18 additions & 20 deletions src/modules/options/OptionsWidget_sound.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -229,30 +229,28 @@ void OptionsWidget_soundGeneral::soundFillBox()
KviModule * m = g_pModuleManager->getModule("snd");

if(!m || !m->ctrl("getAvailableSoundSystems", &l))
goto disable;

m_pSoundSystemBox->clear();

for(const auto& it : l)
m_pSoundSystemBox->addItem(it);

cnt = m_pSoundSystemBox->count();
for(i = 0; i < cnt; i++)
{
QString t = m_pSoundSystemBox->itemText(i);
if(KviQString::equalCI(t, KVI_OPTION_STRING(KviOption_stringSoundSystem)))
{
m_pSoundSystemBox->setCurrentIndex(i);
break;
}
m_pSoundSystemBox->clear();
m_pSoundSystemBox->setEnabled(false);
m_pSoundTestButton->setEnabled(false);
m_pSoundAutoDetectButton->setEnabled(false);
return;
}

return;
disable:
m_pSoundSystemBox->clear();
m_pSoundSystemBox->setEnabled(false);
m_pSoundTestButton->setEnabled(false);
m_pSoundAutoDetectButton->setEnabled(false);
m_pSoundSystemBox->addItems(l);

int idx = m_pSoundSystemBox->findText(KVI_OPTION_STRING(KviOption_stringSoundSystem));
if(idx == -1) {
// the previously used sound system doesn't exist anymore, force an autodetect
g_pApp->setOverrideCursor(Qt::WaitCursor);
QString szSoundSystem;
m->ctrl("detectSoundSystem", &szSoundSystem);
g_pApp->restoreOverrideCursor();
idx = m_pSoundSystemBox->findText(szSoundSystem);
}

m_pSoundSystemBox->setCurrentIndex(idx);
}

void OptionsWidget_soundGeneral::mediaFillBox()
Expand Down

0 comments on commit 1b045ba

Please sign in to comment.