commit 79210b6b6b8c893ff44ef46d18a81fd8a99b2be5
parent e906d7a880c61e48b77e031b74c7d111f20ff511
Author: Karl Tomlinson <karlt+@karlt.net>
Date: Tue, 16 Dec 2025 08:41:29 +0000
Bug 2005984 Use a graph-unique generation for each AudioInputProcessingParamsRequest r=pehrsons
Previously the generation was DeviceInputTrack-unique.
In bug 2005992, GraphDriver changes for native audio input device changes
will happen in CheckDriver(), which will allow the same AudioCallbackDriver to
be used if a NativeInputTrack is removed and another immediated added for the
same device.
Differential Revision: https://phabricator.services.mozilla.com/D276410
Diffstat:
3 files changed, 16 insertions(+), 7 deletions(-)
diff --git a/dom/media/DeviceInputTrack.cpp b/dom/media/DeviceInputTrack.cpp
@@ -331,7 +331,8 @@ DeviceInputTrack::UpdateRequestedProcessingParams() {
if (auto p = params.valueOr(CUBEB_INPUT_PROCESSING_PARAM_NONE);
p != mProcessingParamsRequest.mParams) {
mProcessingParamsRequest.mParams = p;
- mProcessingParamsRequest.mGeneration += 1;
+ mProcessingParamsRequest.mGeneration =
+ Graph()->ProcessingParamsGeneration();
TRACK_GRAPH_LOG(
"%sNativeInputTrack notifying of setting requested processing params "
diff --git a/dom/media/MediaTrackGraph.h b/dom/media/MediaTrackGraph.h
@@ -1278,6 +1278,10 @@ class MediaTrackGraph {
* get the existing NativeInputTrackMain thread only.*/
NativeInputTrack* GetNativeInputTrackMainThread();
+ /* Return a positive monotonically increasing graph-unique generation id for
+ * AudioInputProcessingParamsRequest::mGeneration. */
+ int ProcessingParamsGeneration() { return ++mProcessingParamsGeneration; }
+
protected:
explicit MediaTrackGraph(TrackRate aSampleRate,
CubebUtils::AudioDeviceID aPrimaryOutputDeviceID)
@@ -1306,6 +1310,10 @@ class MediaTrackGraph {
* This is the device specified when creating the graph.
*/
const CubebUtils::AudioDeviceID mPrimaryOutputDeviceID;
+
+ /* A monotonically increasing graph-unique generation for
+ * AudioInputProcessingParamsRequest::mGeneration. */
+ int mProcessingParamsGeneration = 0;
};
inline void MediaTrack::AssertOnGraphThread() const {
diff --git a/dom/media/gtest/TestAudioTrackGraph.cpp b/dom/media/gtest/TestAudioTrackGraph.cpp
@@ -3093,25 +3093,25 @@ TEST(TestAudioTrackGraph, PlatformProcessingNonNativeToNativeSwitch)
// On non-native device's start.
EXPECT_CALL(*secondListener,
NotifySetRequestedInputProcessingParams(
- graph, 1, CUBEB_INPUT_PROCESSING_PARAM_ECHO_CANCELLATION));
+ graph, 3, CUBEB_INPUT_PROCESSING_PARAM_ECHO_CANCELLATION));
EXPECT_CALL(*secondListener, NotifySetRequestedInputProcessingParamsResult(
- graph, 1, Eq(std::ref(echoResult))))
+ graph, 3, Eq(std::ref(echoResult))))
.WillOnce([&] { ++numProcessingParamsResults; });
// After switch to native device for second device.
EXPECT_CALL(*firstListener, Disconnect);
EXPECT_CALL(*secondListener, Disconnect);
EXPECT_CALL(*secondListener,
NotifySetRequestedInputProcessingParams(
- graph, 1, CUBEB_INPUT_PROCESSING_PARAM_ECHO_CANCELLATION));
+ graph, 4, CUBEB_INPUT_PROCESSING_PARAM_ECHO_CANCELLATION));
EXPECT_CALL(*secondListener, NotifySetRequestedInputProcessingParamsResult(
- graph, 1, Eq(std::ref(echoResult))))
+ graph, 4, Eq(std::ref(echoResult))))
.WillOnce([&] { ++numProcessingParamsResults; });
// After param update.
EXPECT_CALL(*secondListener,
NotifySetRequestedInputProcessingParams(
- graph, 2, CUBEB_INPUT_PROCESSING_PARAM_NOISE_SUPPRESSION));
+ graph, 5, CUBEB_INPUT_PROCESSING_PARAM_NOISE_SUPPRESSION));
EXPECT_CALL(*secondListener, NotifySetRequestedInputProcessingParamsResult(
- graph, 2, Eq(std::ref(noiseResult))))
+ graph, 5, Eq(std::ref(noiseResult))))
.WillOnce([&] { ++numProcessingParamsResults; });
EXPECT_CALL(*secondListener, Disconnect);
}