summaryrefslogtreecommitdiffstats
path: root/dom/media/DeviceInputTrack.cpp
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2024-06-12 05:35:29 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2024-06-12 05:35:29 +0000
commit59203c63bb777a3bacec32fb8830fba33540e809 (patch)
tree58298e711c0ff0575818c30485b44a2f21bf28a0 /dom/media/DeviceInputTrack.cpp
parentAdding upstream version 126.0.1. (diff)
downloadfirefox-59203c63bb777a3bacec32fb8830fba33540e809.tar.xz
firefox-59203c63bb777a3bacec32fb8830fba33540e809.zip
Adding upstream version 127.0.upstream/127.0
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'dom/media/DeviceInputTrack.cpp')
-rw-r--r--dom/media/DeviceInputTrack.cpp57
1 files changed, 57 insertions, 0 deletions
diff --git a/dom/media/DeviceInputTrack.cpp b/dom/media/DeviceInputTrack.cpp
index 5d69f7107a..3bf2e87558 100644
--- a/dom/media/DeviceInputTrack.cpp
+++ b/dom/media/DeviceInputTrack.cpp
@@ -316,6 +316,20 @@ bool DeviceInputTrack::HasVoiceInput() const {
return false;
}
+cubeb_input_processing_params DeviceInputTrack::RequestedProcessingParams()
+ const {
+ AssertOnGraphThreadOrNotRunning();
+ Maybe<cubeb_input_processing_params> params;
+ for (const auto& listener : mListeners) {
+ if (params) {
+ *params &= listener->RequestedInputProcessingParams(mGraph);
+ } else {
+ params = Some(listener->RequestedInputProcessingParams(mGraph));
+ }
+ }
+ return params.valueOr(CUBEB_INPUT_PROCESSING_PARAM_NONE);
+}
+
void DeviceInputTrack::DeviceChanged(MediaTrackGraph* aGraph) const {
AssertOnGraphThreadOrNotRunning();
MOZ_ASSERT(aGraph == mGraph,
@@ -326,6 +340,16 @@ void DeviceInputTrack::DeviceChanged(MediaTrackGraph* aGraph) const {
}
}
+void DeviceInputTrack::NotifySetRequestedProcessingParamsResult(
+ MediaTrackGraph* aGraph, cubeb_input_processing_params aRequestedParams,
+ const Result<cubeb_input_processing_params, int>& aResult) {
+ AssertOnGraphThread();
+ for (const auto& listener : mListeners) {
+ listener->NotifySetRequestedInputProcessingParamsResult(
+ mGraph, aRequestedParams, aResult);
+ }
+}
+
void DeviceInputTrack::ReevaluateInputDevice() {
MOZ_ASSERT(NS_IsMainThread());
QueueControlMessageWithNoShutdown([self = RefPtr{this}, this] {
@@ -491,6 +515,8 @@ void NonNativeInputTrack::ProcessInput(GraphTime aFrom, GraphTime aTo,
// GraphRunner keeps the same thread.
MOZ_ASSERT(!HasGraphThreadChanged());
+ ReevaluateProcessingParams();
+
AudioSegment data = mAudioSource->GetAudioSegment(delta, consumer);
MOZ_ASSERT(data.GetDuration() == delta);
GetData<AudioSegment>()->AppendFrom(&data);
@@ -512,6 +538,8 @@ void NonNativeInputTrack::StartAudio(
mGraphThreadId = std::this_thread::get_id();
#endif
mAudioSource = std::move(aAudioInputSource);
+ mAudioSource->Init();
+ ReevaluateProcessingParams();
mAudioSource->Start();
}
@@ -571,6 +599,35 @@ AudioInputSource::Id NonNativeInputTrack::GenerateSourceId() {
return mSourceIdNumber++;
}
+void NonNativeInputTrack::ReevaluateProcessingParams() {
+ AssertOnGraphThread();
+ MOZ_ASSERT(mAudioSource);
+ auto params = RequestedProcessingParams();
+ if (mRequestedProcessingParams == params) {
+ return;
+ }
+ mRequestedProcessingParams = params;
+ using Promise = AudioInputSource::SetRequestedProcessingParamsPromise;
+ mAudioSource->SetRequestedProcessingParams(params)->Then(
+ GetMainThreadSerialEventTarget(), __func__,
+ [this, self = RefPtr(this),
+ params](Promise::ResolveOrRejectValue&& aValue) {
+ if (IsDestroyed()) {
+ return;
+ }
+ auto result = ([&]() -> Result<cubeb_input_processing_params, int> {
+ if (aValue.IsResolve()) {
+ return aValue.ResolveValue();
+ }
+ return Err(aValue.RejectValue());
+ })();
+ QueueControlMessageWithNoShutdown(
+ [this, self = RefPtr(this), params, result = std::move(result)] {
+ NotifySetRequestedProcessingParamsResult(Graph(), params, result);
+ });
+ });
+}
+
#ifdef DEBUG
bool NonNativeInputTrack::HasGraphThreadChanged() {
AssertOnGraphThread();