mirror of
https://github.com/mumble-voip/mumble.git
synced 2025-10-26 11:19:16 +00:00
FIX(client): Fix AudioWizard echo cancellation checkbox
The echo cancellation checkbox had two separate, but similar problems: 1) It would never load in a checked state when you open up the AudioWizard 2) It would also never load the correct checked state representing the user settings when switching AudioInput or AudioOutput systems. The first problem can be traced back to commit010437556dwhere the state of qcbEcho depends on the selected element of the AudioOutput dropdown menu, before it has been filled. The second problem probably goes back to2991d2093awhere the enabled state of the qcbEcho checkbox was changed on changing audio systems, but the checked state was not reloaded. This commit refactors the code (swaps initializing input and output) and adds a shared method to update the qcbEcho checkbox appropriately. Fixes #6544
This commit is contained in:
parent
cb01bfa520
commit
2e676713af
@ -44,26 +44,8 @@ AudioWizard::AudioWizard(QWidget *p) : QWizard(p) {
|
||||
qcbUsage->setChecked(Global::get().s.bUsage);
|
||||
|
||||
// Device
|
||||
if (AudioInputRegistrar::qmNew) {
|
||||
foreach (AudioInputRegistrar *air, *AudioInputRegistrar::qmNew) {
|
||||
qcbInput->addItem(air->name);
|
||||
if (air->name == AudioInputRegistrar::current) {
|
||||
qcbInput->setCurrentIndex(qcbInput->count() - 1);
|
||||
EchoCancelOptionID echoCancelOptionId = firstUsableEchoCancellation(air, qcbOutput->currentText());
|
||||
if (echoCancelOptionId != EchoCancelOptionID::DISABLED) {
|
||||
qcbEcho->setEnabled(true);
|
||||
qcbEcho->setChecked(Global::get().s.echoOption != EchoCancelOptionID::DISABLED);
|
||||
}
|
||||
}
|
||||
QList< audioDevice > ql = air->getDeviceChoices();
|
||||
}
|
||||
}
|
||||
if (qcbInput->count() < 2) {
|
||||
qcbInput->setEnabled(false);
|
||||
}
|
||||
|
||||
if (AudioOutputRegistrar::qmNew) {
|
||||
foreach (AudioOutputRegistrar *aor, *AudioOutputRegistrar::qmNew) {
|
||||
for (AudioOutputRegistrar *aor : *AudioOutputRegistrar::qmNew) {
|
||||
qcbOutput->addItem(aor->name);
|
||||
if (aor->name == AudioOutputRegistrar::current) {
|
||||
qcbOutput->setCurrentIndex(qcbOutput->count() - 1);
|
||||
@ -73,11 +55,24 @@ AudioWizard::AudioWizard(QWidget *p) : QWizard(p) {
|
||||
QList< audioDevice > ql = aor->getDeviceChoices();
|
||||
}
|
||||
}
|
||||
|
||||
if (qcbOutput->count() < 2) {
|
||||
qcbOutput->setEnabled(false);
|
||||
}
|
||||
|
||||
if (AudioInputRegistrar::qmNew) {
|
||||
for (AudioInputRegistrar *air : *AudioInputRegistrar::qmNew) {
|
||||
qcbInput->addItem(air->name);
|
||||
if (air->name == AudioInputRegistrar::current) {
|
||||
qcbInput->setCurrentIndex(qcbInput->count() - 1);
|
||||
updateEchoCheckbox(air);
|
||||
}
|
||||
QList< audioDevice > ql = air->getDeviceChoices();
|
||||
}
|
||||
}
|
||||
if (qcbInput->count() < 2) {
|
||||
qcbInput->setEnabled(false);
|
||||
}
|
||||
|
||||
qcbHighContrast->setChecked(Global::get().s.bHighContrast);
|
||||
on_qcbHighContrast_clicked(Global::get().s.bHighContrast);
|
||||
#ifdef Q_OS_WIN
|
||||
@ -243,8 +238,7 @@ void AudioWizard::on_qcbInputDevice_activated(int) {
|
||||
air->setDeviceChoice(qcbInputDevice->itemData(idx), Global::get().s);
|
||||
}
|
||||
|
||||
EchoCancelOptionID echoCancelOptionId = firstUsableEchoCancellation(air, qcbOutput->currentText());
|
||||
qcbEcho->setEnabled(echoCancelOptionId != EchoCancelOptionID::DISABLED);
|
||||
updateEchoCheckbox(air);
|
||||
|
||||
Global::get().ai = AudioInputPtr(air->create());
|
||||
Global::get().ai->start(QThread::HighestPriority);
|
||||
@ -284,9 +278,7 @@ void AudioWizard::on_qcbOutputDevice_activated(int) {
|
||||
bDelay = aor->usesOutputDelay();
|
||||
}
|
||||
|
||||
AudioInputRegistrar *air = AudioInputRegistrar::qmNew->value(qcbInput->currentText());
|
||||
EchoCancelOptionID echoCancelOptionId = firstUsableEchoCancellation(air, qcbOutput->currentText());
|
||||
qcbEcho->setEnabled(echoCancelOptionId != EchoCancelOptionID::DISABLED);
|
||||
updateEchoCheckbox(AudioInputRegistrar::qmNew->value(qcbInput->currentText()));
|
||||
|
||||
Global::get().ao = AudioOutputPtr(aor->create());
|
||||
Global::get().ao->start(QThread::HighPriority);
|
||||
@ -767,6 +759,18 @@ void AudioWizard::on_qrbQualityCustom_clicked() {
|
||||
restartAudio(true);
|
||||
}
|
||||
|
||||
void AudioWizard::updateEchoCheckbox(AudioInputRegistrar *air) {
|
||||
bool echoCancelPossible =
|
||||
firstUsableEchoCancellation(air, qcbOutput->currentText()) != EchoCancelOptionID::DISABLED;
|
||||
|
||||
qcbEcho->setEnabled(echoCancelPossible);
|
||||
if (echoCancelPossible) {
|
||||
qcbEcho->setChecked(Global::get().s.echoOption != EchoCancelOptionID::DISABLED);
|
||||
} else {
|
||||
qcbEcho->setChecked(false);
|
||||
}
|
||||
}
|
||||
|
||||
EchoCancelOptionID AudioWizard::firstUsableEchoCancellation(AudioInputRegistrar *air, const QString outputSys) {
|
||||
for (EchoCancelOptionID ecoid : air->echoOptions) {
|
||||
if (air->canEcho(ecoid, outputSys)) {
|
||||
|
||||
@ -20,6 +20,8 @@ private:
|
||||
Q_OBJECT
|
||||
Q_DISABLE_COPY(AudioWizard)
|
||||
|
||||
void updateEchoCheckbox(AudioInputRegistrar *air);
|
||||
|
||||
/// Which echo cancellation is usable depends on the audio backend and the device combination.
|
||||
/// This function will iterate through the list of available echo cancellation in the audio backend and check with
|
||||
/// the backend whether this echo cancellation option works for current device combination.
|
||||
|
||||
Loading…
Reference in New Issue
Block a user