summaryrefslogtreecommitdiffstats
path: root/dom/media/CubebUtils.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'dom/media/CubebUtils.cpp')
-rw-r--r--dom/media/CubebUtils.cpp45
1 files changed, 45 insertions, 0 deletions
diff --git a/dom/media/CubebUtils.cpp b/dom/media/CubebUtils.cpp
index dbdab3a56a..3c93e65095 100644
--- a/dom/media/CubebUtils.cpp
+++ b/dom/media/CubebUtils.cpp
@@ -14,6 +14,7 @@
#include "mozilla/Logging.h"
#include "mozilla/Preferences.h"
#include "mozilla/Components.h"
+#include "mozilla/SharedThreadPool.h"
#include "mozilla/Sprintf.h"
#include "mozilla/StaticMutex.h"
#include "mozilla/StaticPtr.h"
@@ -186,6 +187,43 @@ static const uint32_t CUBEB_NORMAL_LATENCY_MS = 100;
static const uint32_t CUBEB_NORMAL_LATENCY_FRAMES = 1024;
namespace CubebUtils {
+nsCString ProcessingParamsToString(cubeb_input_processing_params aParams) {
+ if (aParams == CUBEB_INPUT_PROCESSING_PARAM_NONE) {
+ return "NONE"_ns;
+ }
+ nsCString str;
+ for (auto p : {CUBEB_INPUT_PROCESSING_PARAM_ECHO_CANCELLATION,
+ CUBEB_INPUT_PROCESSING_PARAM_AUTOMATIC_GAIN_CONTROL,
+ CUBEB_INPUT_PROCESSING_PARAM_NOISE_SUPPRESSION,
+ CUBEB_INPUT_PROCESSING_PARAM_VOICE_ISOLATION}) {
+ if (!(aParams & p)) {
+ continue;
+ }
+ if (!str.IsEmpty()) {
+ str.Append(" | ");
+ }
+ str.Append([&p] {
+ switch (p) {
+ case CUBEB_INPUT_PROCESSING_PARAM_NONE:
+ // Handled above.
+ MOZ_CRASH(
+ "NONE is the absence of a param, thus not for logging here.");
+ case CUBEB_INPUT_PROCESSING_PARAM_ECHO_CANCELLATION:
+ return "AEC";
+ case CUBEB_INPUT_PROCESSING_PARAM_AUTOMATIC_GAIN_CONTROL:
+ return "AGC";
+ case CUBEB_INPUT_PROCESSING_PARAM_NOISE_SUPPRESSION:
+ return "NS";
+ case CUBEB_INPUT_PROCESSING_PARAM_VOICE_ISOLATION:
+ return "VOICE";
+ }
+ MOZ_ASSERT_UNREACHABLE("Unexpected input processing param");
+ return "<Unknown input processing param>";
+ }());
+ }
+ return str;
+}
+
RefPtr<CubebHandle> GetCubebUnlocked();
void GetPrefAndSetString(const char* aPref, StaticAutoPtr<char>& aStorage) {
@@ -765,6 +803,13 @@ bool SandboxEnabled() {
#endif
}
+already_AddRefed<SharedThreadPool> GetCubebOperationThread() {
+ RefPtr<SharedThreadPool> pool = SharedThreadPool::Get("CubebOperation"_ns, 1);
+ const uint32_t kIdleThreadTimeoutMs = 2000;
+ pool->SetIdleThreadTimeout(PR_MillisecondsToInterval(kIdleThreadTimeoutMs));
+ return pool.forget();
+}
+
uint32_t MaxNumberOfChannels() {
RefPtr<CubebHandle> handle = GetCubeb();
uint32_t maxNumberOfChannels;