diff options
author | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-06-12 05:35:37 +0000 |
---|---|---|
committer | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-06-12 05:35:37 +0000 |
commit | a90a5cba08fdf6c0ceb95101c275108a152a3aed (patch) | |
tree | 532507288f3defd7f4dcf1af49698bcb76034855 /dom/media/DeviceInputTrack.cpp | |
parent | Adding debian version 126.0.1-1. (diff) | |
download | firefox-a90a5cba08fdf6c0ceb95101c275108a152a3aed.tar.xz firefox-a90a5cba08fdf6c0ceb95101c275108a152a3aed.zip |
Merging upstream version 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.cpp | 57 |
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(); |