Skip to content

Commit

Permalink
Merge pull request #4762: Fix echo cancellation setting not saved
Browse files Browse the repository at this point in the history
This fixes a few regressions introduced in #4694 affecting the echo cancellation settings.

Fixes #4761
  • Loading branch information
Krzmbrzl committed Feb 15, 2021
2 parents 973cee2 + d322311 commit f6fde4d
Showing 1 changed file with 47 additions and 8 deletions.
55 changes: 47 additions & 8 deletions src/mumble/Settings.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -170,7 +170,7 @@ OverlaySettings::OverlaySettings() {
fY = 0.0f;
fZoom = 0.875f;

#ifdef Q_OS_MAC
#ifdef Q_OS_MACOS
qsStyle = QLatin1String("Cleanlooks");
#endif

Expand Down Expand Up @@ -211,7 +211,7 @@ void OverlaySettings::setPreset(const OverlayPresets preset) {
fMutedDeafened = 0.5f;
fAvatar = 1.0f;

#if defined(Q_OS_WIN) || defined(Q_OS_MAC)
#if defined(Q_OS_WIN) || defined(Q_OS_MACOS)
qfUserName = QFont(QLatin1String("Verdana"), 20);
#else
qfUserName = QFont(QLatin1String("Arial"), 20);
Expand Down Expand Up @@ -251,7 +251,7 @@ void OverlaySettings::setPreset(const OverlayPresets preset) {
fMutedDeafened = (7.0f / 8.0f);
fAvatar = 1.0f;

#if defined(Q_OS_WIN) || defined(Q_OS_MAC)
#if defined(Q_OS_WIN) || defined(Q_OS_MACOS)
qfUserName = QFont(QLatin1String("Verdana"), 20);
#else
qfUserName = QFont(QLatin1String("Arial"), 20);
Expand Down Expand Up @@ -401,7 +401,16 @@ Settings::Settings() {
bJackStartServer = false;
bJackAutoConnect = true;

echoOption = EchoCancelOptionID::DISABLED;
#ifdef Q_OS_MACOS
// On macOS Speex can't be used, so we default to Apple's custom echo cancellation mode
// Note that this only seems to work with when using the built-in microphone and the built-in speakers. It
// doesn't make it worse for other combinations of input and output devices though. Thus it should be
// safe to enable this by default.
echoOption = EchoCancelOptionID::APPLE_AEC;
#else
// Everywhere else Speex works and thus we default to using that
echoOption = EchoCancelOptionID::SPEEX_MIXED;
#endif

bExclusiveInput = false;
bExclusiveOutput = false;
Expand Down Expand Up @@ -606,7 +615,7 @@ BOOST_TYPEOF_REGISTER_TEMPLATE(QList, 1)
// it. This causes such settings to fall back
// to their defaults, instead of being set to
// a zero value.
#ifdef Q_OS_MAC
#ifdef Q_OS_MACOS
# undef SAVELOAD
# define SAVELOAD(var, name) \
do { \
Expand Down Expand Up @@ -751,6 +760,8 @@ void Settings::load(QSettings *settings_ptr) {
SAVELOAD(fAudioMaxDistance, "audio/maxdistance");
SAVELOAD(fAudioMaxDistVolume, "audio/maxdistancevolume");
SAVELOAD(fAudioBloom, "audio/bloom");
DEPRECATED("audio/echo");
DEPRECATED("audio/echomulti");
SAVELOAD(bExclusiveInput, "audio/exclusiveinput");
SAVELOAD(bExclusiveOutput, "audio/exclusiveoutput");
SAVELOAD(bPositionalAudio, "audio/positional");
Expand All @@ -759,7 +770,33 @@ void Settings::load(QSettings *settings_ptr) {
SAVELOAD(qsAudioOutput, "audio/output");
SAVELOAD(bWhisperFriends, "audio/whisperfriends");
SAVELOAD(bTransmitPosition, "audio/postransmit");
LOADFLAG(echoOption, "audio/echooptionid");

if (settings_ptr->contains("audio/echooptionid")) {
// Load the new echo cancel option instead
LOADFLAG(echoOption, "audio/echooptionid");
} else {
#ifndef Q_OS_MACOS
// Compatibility layer for overtaking the old (now deprecated) settings
// This block should only be called once at the first start of the new Mumble version
// As echo cancellation was not available on macOS before, we don't have to run this compatibility
// code on macOS (instead simply use the new default as set in the constructor).
bool deprecatedEcho = false;
bool deprecatedEchoMulti = false;

SAVELOAD(deprecatedEcho, "audio/echo");
SAVELOAD(deprecatedEchoMulti, "audio/echomulti");

if (deprecatedEcho) {
if (deprecatedEchoMulti) {
echoOption = EchoCancelOptionID::SPEEX_MULTICHANNEL;
} else {
echoOption = EchoCancelOptionID::SPEEX_MIXED;
}
} else {
echoOption = EchoCancelOptionID::DISABLED;
}
#endif
}

SAVELOAD(iJitterBufferSize, "net/jitterbuffer");
SAVELOAD(iFramesPerPacket, "net/framesperpacket");
Expand Down Expand Up @@ -1002,7 +1039,7 @@ void OverlaySettings::save(QSettings *settings_ptr) {
settings_ptr->setValue(QLatin1String("version"), QLatin1String(MUMTEXT(MUMBLE_VERSION)));
settings_ptr->sync();

#if defined(Q_OS_WIN) || defined(Q_OS_MAC)
#if defined(Q_OS_WIN) || defined(Q_OS_MACOS)
if (settings_ptr->format() == QSettings::IniFormat)
#endif
{
Expand Down Expand Up @@ -1124,7 +1161,8 @@ void Settings::save() {
SAVELOAD(fAudioMaxDistance, "audio/maxdistance");
SAVELOAD(fAudioMaxDistVolume, "audio/maxdistancevolume");
SAVELOAD(fAudioBloom, "audio/bloom");
LOADFLAG(echoOption, "audio/echooptionid");
DEPRECATED("audio/echo");
DEPRECATED("audio/echomulti");
SAVELOAD(bExclusiveInput, "audio/exclusiveinput");
SAVELOAD(bExclusiveOutput, "audio/exclusiveoutput");
SAVELOAD(bPositionalAudio, "audio/positional");
Expand All @@ -1133,6 +1171,7 @@ void Settings::save() {
SAVELOAD(qsAudioOutput, "audio/output");
SAVELOAD(bWhisperFriends, "audio/whisperfriends");
SAVELOAD(bTransmitPosition, "audio/postransmit");
SAVEFLAG(echoOption, "audio/echooptionid");

SAVELOAD(iJitterBufferSize, "net/jitterbuffer");
SAVELOAD(iFramesPerPacket, "net/framesperpacket");
Expand Down

0 comments on commit f6fde4d

Please sign in to comment.