summaryrefslogtreecommitdiffstats
path: root/dom/media/MediaTrackGraph.cpp
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2024-06-12 05:35:37 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2024-06-12 05:35:37 +0000
commita90a5cba08fdf6c0ceb95101c275108a152a3aed (patch)
tree532507288f3defd7f4dcf1af49698bcb76034855 /dom/media/MediaTrackGraph.cpp
parentAdding debian version 126.0.1-1. (diff)
downloadfirefox-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/MediaTrackGraph.cpp')
-rw-r--r--dom/media/MediaTrackGraph.cpp63
1 files changed, 52 insertions, 11 deletions
diff --git a/dom/media/MediaTrackGraph.cpp b/dom/media/MediaTrackGraph.cpp
index a4f81d0071..e9356548b8 100644
--- a/dom/media/MediaTrackGraph.cpp
+++ b/dom/media/MediaTrackGraph.cpp
@@ -440,11 +440,10 @@ void MediaTrackGraphImpl::CheckDriver() {
NativeInputTrack* native =
mDeviceInputTrackManagerGraphThread.GetNativeInputTrack();
CubebUtils::AudioDeviceID inputDevice = native ? native->mDeviceId : nullptr;
- uint32_t inputChannelCount =
- native ? AudioInputChannelCount(native->mDeviceId) : 0;
- AudioInputType inputPreference =
- native ? AudioInputDevicePreference(native->mDeviceId)
- : AudioInputType::Unknown;
+ uint32_t inputChannelCount = AudioInputChannelCount(inputDevice);
+ AudioInputType inputPreference = AudioInputDevicePreference(inputDevice);
+ cubeb_input_processing_params inputProcessingParams =
+ RequestedAudioInputProcessingParams(inputDevice);
uint32_t primaryOutputChannelCount = PrimaryOutputChannelCount();
if (!audioCallbackDriver) {
@@ -452,7 +451,7 @@ void MediaTrackGraphImpl::CheckDriver() {
AudioCallbackDriver* driver = new AudioCallbackDriver(
this, CurrentDriver(), mSampleRate, primaryOutputChannelCount,
inputChannelCount, PrimaryOutputDeviceID(), inputDevice,
- inputPreference);
+ inputPreference, inputProcessingParams);
SwitchAtNextIteration(driver);
}
return;
@@ -468,9 +467,14 @@ void MediaTrackGraphImpl::CheckDriver() {
AudioCallbackDriver* driver = new AudioCallbackDriver(
this, CurrentDriver(), mSampleRate, primaryOutputChannelCount,
inputChannelCount, PrimaryOutputDeviceID(), inputDevice,
- inputPreference);
+ inputPreference, inputProcessingParams);
SwitchAtNextIteration(driver);
}
+
+ if (native) {
+ audioCallbackDriver->SetRequestedInputProcessingParams(
+ inputProcessingParams);
+ }
}
void MediaTrackGraphImpl::UpdateTrackOrder() {
@@ -770,7 +774,8 @@ void MediaTrackGraphImpl::OpenAudioInputImpl(DeviceInputTrack* aTrack) {
AudioCallbackDriver* driver = new AudioCallbackDriver(
this, CurrentDriver(), mSampleRate, PrimaryOutputChannelCount(),
AudioInputChannelCount(aTrack->mDeviceId), PrimaryOutputDeviceID(),
- aTrack->mDeviceId, AudioInputDevicePreference(aTrack->mDeviceId));
+ aTrack->mDeviceId, AudioInputDevicePreference(aTrack->mDeviceId),
+ aTrack->RequestedProcessingParams());
LOG(LogLevel::Debug,
("%p OpenAudioInputImpl: starting new AudioCallbackDriver(input) %p",
this, driver));
@@ -842,7 +847,8 @@ void MediaTrackGraphImpl::CloseAudioInputImpl(DeviceInputTrack* aTrack) {
driver = new AudioCallbackDriver(
this, CurrentDriver(), mSampleRate, PrimaryOutputChannelCount(),
AudioInputChannelCount(aTrack->mDeviceId), PrimaryOutputDeviceID(),
- nullptr, AudioInputDevicePreference(aTrack->mDeviceId));
+ nullptr, AudioInputDevicePreference(aTrack->mDeviceId),
+ aTrack->RequestedProcessingParams());
SwitchAtNextIteration(driver);
} else if (CurrentDriver()->AsAudioCallbackDriver()) {
LOG(LogLevel::Debug,
@@ -937,6 +943,32 @@ void MediaTrackGraphImpl::NotifyInputData(const AudioDataValue* aBuffer,
aAlreadyBuffered);
}
+void MediaTrackGraphImpl::NotifySetRequestedInputProcessingParamsResult(
+ AudioCallbackDriver* aDriver,
+ cubeb_input_processing_params aRequestedParams,
+ Result<cubeb_input_processing_params, int>&& aResult) {
+ MOZ_ASSERT(NS_IsMainThread());
+ NativeInputTrack* native =
+ mDeviceInputTrackManagerMainThread.GetNativeInputTrack();
+ if (!native) {
+ return;
+ }
+ QueueControlMessageWithNoShutdown([this, self = RefPtr(this),
+ driver = RefPtr(aDriver), aRequestedParams,
+ result = std::move(aResult)]() mutable {
+ NativeInputTrack* native =
+ mDeviceInputTrackManagerGraphThread.GetNativeInputTrack();
+ if (!native) {
+ return;
+ }
+ if (driver != mDriver) {
+ return;
+ }
+ native->NotifySetRequestedProcessingParamsResult(this, aRequestedParams,
+ result);
+ });
+}
+
void MediaTrackGraphImpl::DeviceChangedImpl() {
MOZ_ASSERT(OnGraphThread());
NativeInputTrack* native =
@@ -1115,7 +1147,7 @@ void MediaTrackGraphImpl::ReevaluateInputDevice(CubebUtils::AudioDeviceID aID) {
AudioCallbackDriver* newDriver = new AudioCallbackDriver(
this, CurrentDriver(), mSampleRate, PrimaryOutputChannelCount(),
AudioInputChannelCount(aID), PrimaryOutputDeviceID(), aID,
- AudioInputDevicePreference(aID));
+ AudioInputDevicePreference(aID), track->RequestedProcessingParams());
SwitchAtNextIteration(newDriver);
}
}
@@ -3459,7 +3491,7 @@ void MediaTrackGraphImpl::Init(GraphDriverType aDriverRequested,
// for the input channel.
mDriver = new AudioCallbackDriver(
this, nullptr, mSampleRate, aChannelCount, 0, PrimaryOutputDeviceID(),
- nullptr, AudioInputType::Unknown);
+ nullptr, AudioInputType::Unknown, CUBEB_INPUT_PROCESSING_PARAM_NONE);
} else {
mDriver = new SystemClockDriver(this, nullptr, mSampleRate);
}
@@ -4257,6 +4289,15 @@ AudioInputType MediaTrackGraphImpl::AudioInputDevicePreference(
: AudioInputType::Unknown;
}
+cubeb_input_processing_params
+MediaTrackGraphImpl::RequestedAudioInputProcessingParams(
+ CubebUtils::AudioDeviceID aID) {
+ MOZ_ASSERT(OnGraphThreadOrNotRunning());
+ DeviceInputTrack* t =
+ mDeviceInputTrackManagerGraphThread.GetDeviceInputTrack(aID);
+ return t ? t->RequestedProcessingParams() : CUBEB_INPUT_PROCESSING_PARAM_NONE;
+}
+
void MediaTrackGraphImpl::SetNewNativeInput() {
MOZ_ASSERT(NS_IsMainThread());
MOZ_ASSERT(!mDeviceInputTrackManagerMainThread.GetNativeInputTrack());