Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/mumble-voip/mumble.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRobert Adam <dev@robert-adam.de>2021-05-16 10:32:41 +0300
committerGitHub <noreply@github.com>2021-05-16 10:32:41 +0300
commit1e388ac85f7f624ecdb54259a8ea9149581cf4bc (patch)
treebbb239a774b2803c9e29e4d825815d8e30c7106d
parent029fdc4c7f05fa2fce71faf768cc34e596697e48 (diff)
parent7fb4708c03a204cec977624828bc4b69356301a9 (diff)
Merge PR #4994: FIX(client): Echo cancellation options not translated
These Strings were not translated because as global static variables they were created before the necessary translators are installed. This commit fixes this by making sure the containing EchoCancelOption objects are created lazily (at the time they are needed for the first time), thus causing a delaying instantiation. Fixes #4993
-rw-r--r--cmake/os.cmake2
-rw-r--r--src/mumble/AudioConfigDialog.cpp2
-rw-r--r--src/mumble/CMakeLists.txt1
-rw-r--r--src/mumble/EchoCancelOption.cpp34
-rw-r--r--src/mumble/EchoCancelOption.h20
5 files changed, 42 insertions, 17 deletions
diff --git a/cmake/os.cmake b/cmake/os.cmake
index 46b46abe0..78ccfb8bf 100644
--- a/cmake/os.cmake
+++ b/cmake/os.cmake
@@ -32,6 +32,8 @@ if(WIN32)
add_definitions(
"-DUNICODE"
"-DWIN32_LEAN_AND_MEAN"
+ # Prevent Windows headers from defining the macros "min" and "max" that mess up e.g. std::min usage
+ "-DNOMINMAX"
)
else()
if(${CMAKE_SYSTEM_NAME} STREQUAL "FreeBSD")
diff --git a/src/mumble/AudioConfigDialog.cpp b/src/mumble/AudioConfigDialog.cpp
index 91cf47f5e..65af66496 100644
--- a/src/mumble/AudioConfigDialog.cpp
+++ b/src/mumble/AudioConfigDialog.cpp
@@ -521,7 +521,7 @@ void AudioInputDialog::updateEchoEnableState() {
if (air->canEcho(ecoid, outputInterface)) {
++i;
hasUsableEchoOption = true;
- const EchoCancelOption &echoOption = echoCancelOptions[static_cast< int >(ecoid)];
+ const EchoCancelOption &echoOption = EchoCancelOption::getOptions()[static_cast< int >(ecoid)];
qcbEcho->insertItem(i, echoOption.description, static_cast< int >(ecoid));
qcbEcho->setItemData(i, echoOption.explanation, Qt::ToolTipRole);
if (s.echoOption == ecoid) {
diff --git a/src/mumble/CMakeLists.txt b/src/mumble/CMakeLists.txt
index 08b50b288..0d781c7d9 100644
--- a/src/mumble/CMakeLists.txt
+++ b/src/mumble/CMakeLists.txt
@@ -134,6 +134,7 @@ set(MUMBLE_SOURCES
"Database.h"
"DeveloperConsole.cpp"
"DeveloperConsole.h"
+ "EchoCancelOption.cpp"
"EchoCancelOption.h"
"Global.cpp"
"Global.h"
diff --git a/src/mumble/EchoCancelOption.cpp b/src/mumble/EchoCancelOption.cpp
new file mode 100644
index 000000000..185f5086c
--- /dev/null
+++ b/src/mumble/EchoCancelOption.cpp
@@ -0,0 +1,34 @@
+// Copyright 2021 The Mumble Developers. All rights reserved.
+// Use of this source code is governed by a BSD-style license
+// that can be found in the LICENSE file at the root of the
+// Mumble source tree or at <https://www.mumble.info/LICENSE>.
+
+#include "EchoCancelOption.h"
+
+#include <QObject>
+
+const std::vector< EchoCancelOption > &EchoCancelOption::getOptions() {
+ // Note that we have to create this list lazily (at the time it is needed for the first time) in order
+ // to make sure that there actually is a translator installed that can translate these Strings. If we
+ // create these objects too early (e.g. by making them a static variable in global namespace), the Strings
+ // will not get translated.
+
+ // The item order MUST follow the order in the EchoCancelOptionID enum
+ static const std::vector< EchoCancelOption > echoCancelOptions = {
+ { EchoCancelOptionID::DISABLED, QObject::tr("Disabled"), QObject::tr("Echo cancellation is disabled.") },
+ { EchoCancelOptionID::SPEEX_MIXED, QObject::tr("Mixed echo cancellation (speex)"),
+ QObject::tr("Mixed has low CPU impact, but only works well if your "
+ "speakers are equally loud and equidistant from the microphone.") },
+ { EchoCancelOptionID::SPEEX_MULTICHANNEL, QObject::tr("Multichannel echo cancellation (speex)"),
+ QObject::tr("Multichannel echo cancellation provides much better echo "
+ "cancellation, but at a higher CPU cost. "
+ "Multichannel echo cancellation requires more CPU, so "
+ "you should try mixed first.") },
+ // Available only on Apple devices
+ { EchoCancelOptionID::APPLE_AEC, QObject::tr("EXPERIMENTAL: Acoustic echo cancellation (Apple)."),
+ QObject::tr("The support for this option is experimental only! This option works best when using built-in "
+ "microphone and speaker.") }
+ };
+
+ return echoCancelOptions;
+}
diff --git a/src/mumble/EchoCancelOption.h b/src/mumble/EchoCancelOption.h
index f556b0e70..b41388efd 100644
--- a/src/mumble/EchoCancelOption.h
+++ b/src/mumble/EchoCancelOption.h
@@ -7,6 +7,7 @@
#define MUMBLE_MUMBLE_ECHOCANCELLATIONOPTION_H
#include <QtCore/QObject>
+#include <vector>
/// This enum lists a series of echo cancellation options
@@ -23,23 +24,10 @@ struct EchoCancelOption {
EchoCancelOptionID id;
QString description;
QString explanation;
-};
-// Please strictly follow the order of the EchoCancelOptionID when adding items to this array.
-static const EchoCancelOption echoCancelOptions[] = {
- { EchoCancelOptionID::DISABLED, QObject::tr("Disabled"), QObject::tr("Echo cancellation is disabled.") },
- { EchoCancelOptionID::SPEEX_MIXED, QObject::tr("Mixed echo cancellation (speex)"),
- QObject::tr("Mixed has low CPU impact, but only works well if your "
- "speakers are equally loud and equidistant from the microphone.") },
- { EchoCancelOptionID::SPEEX_MULTICHANNEL, QObject::tr("Multichannel echo cancellation (speex)"),
- QObject::tr("Multichannel echo cancellation provides much better echo "
- "cancellation, but at a higher CPU cost. "
- "Multichannel echo cancellation requires more CPU, so "
- "you should try mixed first.") },
- // Available only on Apple devices
- { EchoCancelOptionID::APPLE_AEC, QObject::tr("EXPERIMENTAL: Acoustic echo cancellation (Apple)."),
- QObject::tr("The support for this option is experimental only! This option works best when using built-in "
- "microphone and speaker.") }
+ /// @returns A vector of EchoCancelOption objects in the same order as specified in the
+ /// EchoCancelOptionID enum. Thus the enums can be used as an index for the returned vector.
+ static const std::vector< EchoCancelOption > &getOptions();
};
#endif // MUMBLE_ECHOCANCELLATIONOPTION_H