From 79f1bb0efdec43279abb4f727d0e9f9eee49de2e Mon Sep 17 00:00:00 2001 From: Paul Adenot Date: Wed, 20 Nov 2024 14:53:12 +0000 Subject: [PATCH] Bug 1308435 - Make setting the value attribute of an AudioParam strictly equivalent of calling setValueAtTime with AudioContext.currentTime. r=karlt Differential Revision: https://phabricator.services.mozilla.com/D225219 --- dom/media/webaudio/AudioEventTimeline.cpp | 2 -- dom/media/webaudio/AudioEventTimeline.h | 15 ++-------- dom/media/webaudio/AudioParam.h | 22 +++----------- dom/media/webaudio/AudioParamTimeline.h | 4 --- ...t-analyser-resume-after-suspended.html.ini | 4 +-- .../k-rate-connections.html.ini | 30 +++++++++++++++++++ .../k-rate-constant-source.html.ini | 30 +++++++++++++++++++ .../detune-limiting.html.ini | 3 ++ 8 files changed, 71 insertions(+), 39 deletions(-) diff --git a/dom/media/webaudio/AudioEventTimeline.cpp b/dom/media/webaudio/AudioEventTimeline.cpp index f960cadd6256..24ce2f6d2c1d 100644 --- a/dom/media/webaudio/AudioEventTimeline.cpp +++ b/dom/media/webaudio/AudioEventTimeline.cpp @@ -482,7 +482,6 @@ void AudioEventTimeline::GetValuesAtTimeHelperInternal( case AudioTimelineEvent::SetTarget: case AudioTimelineEvent::SetValueCurve: break; - case AudioTimelineEvent::SetValue: case AudioTimelineEvent::Cancel: case AudioTimelineEvent::Track: MOZ_ASSERT(false, "Should have been handled earlier."); @@ -500,7 +499,6 @@ void AudioEventTimeline::GetValuesAtTimeHelperInternal( break; case AudioTimelineEvent::SetTarget: MOZ_FALLTHROUGH_ASSERT("AudioTimelineEvent::SetTarget"); - case AudioTimelineEvent::SetValue: case AudioTimelineEvent::Cancel: case AudioTimelineEvent::Track: MOZ_ASSERT(false, "Should have been handled earlier."); diff --git a/dom/media/webaudio/AudioEventTimeline.h b/dom/media/webaudio/AudioEventTimeline.h index 497f9c083664..612898378416 100644 --- a/dom/media/webaudio/AudioEventTimeline.h +++ b/dom/media/webaudio/AudioEventTimeline.h @@ -31,8 +31,8 @@ namespace dom { struct AudioTimelineEvent { MOZ_DEFINE_ENUM_WITH_BASE_AND_TOSTRING_AT_CLASS_SCOPE( Type, uint32_t, - (SetValue, SetValueAtTime, LinearRamp, ExponentialRamp, SetTarget, - SetValueCurve, Track, Cancel)); + (SetValueAtTime, LinearRamp, ExponentialRamp, SetTarget, SetValueCurve, + Track, Cancel)); class TimeUnion { public: @@ -313,17 +313,6 @@ class AudioEventTimeline { return mSimpleValue.value(); } - void SetValue(float aValue) { - // FIXME: bug 1308435 - // A spec change means this should instead behave like setValueAtTime(). - - // Silently don't change anything if there are any events - if (mEvents.IsEmpty()) { - mSetTargetStartValue = mDefaultValue = aValue; - mSimpleValue = Some(aValue); - } - } - template void CancelScheduledValues(TimeType aStartTime) { for (unsigned i = 0; i < mEvents.Length(); ++i) { diff --git a/dom/media/webaudio/AudioParam.h b/dom/media/webaudio/AudioParam.h index 2365857a5bf5..e9bb581580f2 100644 --- a/dom/media/webaudio/AudioParam.h +++ b/dom/media/webaudio/AudioParam.h @@ -8,6 +8,7 @@ #define AudioParam_h_ #include "AudioParamTimeline.h" +#include "mozilla/ErrorResult.h" #include "nsWrapperCache.h" #include "nsCycleCollectionParticipant.h" #include "AudioNode.h" @@ -58,27 +59,12 @@ class AudioParam final : public nsWrapperCache, public AudioParamTimeline { // Intended for use in AudioNode creation, when the setter should not throw. void SetInitialValue(float aValue) { - MOZ_ASSERT(HasSimpleValue(), "Existing events unexpected"); - AudioParamEvent event(AudioTimelineEvent::SetValue, 0.0f, aValue); - - DebugOnly rv; - MOZ_ASSERT(ValidateEvent(event, rv), "This event should be valid"); - - AudioParamTimeline::SetValue(aValue); - - SendEventToEngine(event); + IgnoredErrorResult rv; + SetValue(aValue, rv); } void SetValue(float aValue, ErrorResult& aRv) { - AudioParamEvent event(AudioTimelineEvent::SetValue, 0.0f, aValue); - - if (!ValidateEvent(event, aRv)) { - return; - } - - AudioParamTimeline::SetValue(aValue); - - SendEventToEngine(event); + SetValueAtTime(aValue, GetParentObject()->CurrentTime(), aRv); } AudioParam* SetValueAtTime(float aValue, double aStartTime, diff --git a/dom/media/webaudio/AudioParamTimeline.h b/dom/media/webaudio/AudioParamTimeline.h index bd0ba99ffe58..8d745e103764 100644 --- a/dom/media/webaudio/AudioParamTimeline.h +++ b/dom/media/webaudio/AudioParamTimeline.h @@ -64,10 +64,6 @@ class AudioParamTimeline : public AudioEventTimeline { mTrack = aEvent.mTrack; return; } - if (aEvent.mType == AudioTimelineEvent::SetValue) { - AudioEventTimeline::SetValue(aEvent.NominalValue()); - return; - } AudioEventTimeline::InsertEvent(aEvent); } diff --git a/testing/web-platform/meta/webaudio/the-audio-api/the-analysernode-interface/test-analyser-resume-after-suspended.html.ini b/testing/web-platform/meta/webaudio/the-audio-api/the-analysernode-interface/test-analyser-resume-after-suspended.html.ini index 3a121f4c3639..5b08919a7d5b 100644 --- a/testing/web-platform/meta/webaudio/the-audio-api/the-analysernode-interface/test-analyser-resume-after-suspended.html.ini +++ b/testing/web-platform/meta/webaudio/the-audio-api/the-analysernode-interface/test-analyser-resume-after-suspended.html.ini @@ -1,8 +1,8 @@ [test-analyser-resume-after-suspended.html] expected: if (os == "mac") and debug: [OK, TIMEOUT] - if os == "linux": ERROR + if os == "linux": [ERROR, TIMEOUT] [AnalyserNode resume after suspended] expected: if (os == "mac") and debug: [PASS, TIMEOUT] - if os == "linux": TIMEOUT + if os == "linux": [PASS, TIMEOUT] diff --git a/testing/web-platform/meta/webaudio/the-audio-api/the-audioparam-interface/k-rate-connections.html.ini b/testing/web-platform/meta/webaudio/the-audio-api/the-audioparam-interface/k-rate-connections.html.ini index c8b7b251e3de..d43f6b6da914 100644 --- a/testing/web-platform/meta/webaudio/the-audio-api/the-audioparam-interface/k-rate-connections.html.ini +++ b/testing/web-platform/meta/webaudio/the-audio-api/the-audioparam-interface/k-rate-connections.html.ini @@ -30,3 +30,33 @@ [< [StereoPanner\] 8 out of 8 assertions were failed.] expected: FAIL + + [X gain[0:128\]: Expected 2 for all values but found 127 unexpected values: \n\tIndex\tActual\n\t[1\]\t2.9990234375\n\t[2\]\t3.998046875\n\t[3\]\t4.9970703125\n\t[4\]\t5.99609375\n\t...and 123 more errors.] + expected: FAIL + + [X gain[128:256\]: Expected 129.875 for all values but found 127 unexpected values: \n\tIndex\tActual\n\t[1\]\t130.8740234375\n\t[2\]\t131.873046875\n\t[3\]\t132.8720703125\n\t[4\]\t133.87109375\n\t...and 123 more errors.] + expected: FAIL + + [X gain[256:384\]: Expected 257.75 for all values but found 127 unexpected values: \n\tIndex\tActual\n\t[1\]\t258.7490234375\n\t[2\]\t259.748046875\n\t[3\]\t260.7470703125\n\t[4\]\t261.74609375\n\t...and 123 more errors.] + expected: FAIL + + [X gain[384:512\]: Expected 385.625 for all values but found 127 unexpected values: \n\tIndex\tActual\n\t[1\]\t386.6240234375\n\t[2\]\t387.623046875\n\t[3\]\t388.6220703125\n\t[4\]\t389.62109375\n\t...and 123 more errors.] + expected: FAIL + + [X gain[512:640\]: Expected 513.5 for all values but found 127 unexpected values: \n\tIndex\tActual\n\t[1\]\t514.4990234375\n\t[2\]\t515.498046875\n\t[3\]\t516.4970703125\n\t[4\]\t517.49609375\n\t...and 123 more errors.] + expected: FAIL + + [X gain[640:768\]: Expected 641.375 for all values but found 127 unexpected values: \n\tIndex\tActual\n\t[1\]\t642.3740234375\n\t[2\]\t643.373046875\n\t[3\]\t644.3720703125\n\t[4\]\t645.37109375\n\t...and 123 more errors.] + expected: FAIL + + [X gain[768:896\]: Expected 769.25 for all values but found 127 unexpected values: \n\tIndex\tActual\n\t[1\]\t770.2490234375\n\t[2\]\t771.248046875\n\t[3\]\t772.2470703125\n\t[4\]\t773.24609375\n\t...and 123 more errors.] + expected: FAIL + + [X gain[896:1024\]: Expected 897.125 for all values but found 127 unexpected values: \n\tIndex\tActual\n\t[1\]\t898.1240234375\n\t[2\]\t899.123046875\n\t[3\]\t900.1220703125\n\t[4\]\t901.12109375\n\t...and 123 more errors.] + expected: FAIL + + [< [Gain\] 8 out of 8 assertions were failed.] + expected: FAIL + + [# AUDIT TASK RUNNER FINISHED: 2 out of 2 tasks were failed.] + expected: FAIL diff --git a/testing/web-platform/meta/webaudio/the-audio-api/the-audioparam-interface/k-rate-constant-source.html.ini b/testing/web-platform/meta/webaudio/the-audio-api/the-audioparam-interface/k-rate-constant-source.html.ini index 82d486ea1cf2..8df24de21ce7 100644 --- a/testing/web-platform/meta/webaudio/the-audio-api/the-audioparam-interface/k-rate-constant-source.html.ini +++ b/testing/web-platform/meta/webaudio/the-audio-api/the-audioparam-interface/k-rate-constant-source.html.ini @@ -48,3 +48,33 @@ [X k-rate ConstantSource.offset: output[384:512\]: Expected 384 for all values but found 127 unexpected values: \n\tIndex\tActual\n\t[1\]\t385\n\t[2\]\t386\n\t[3\]\t387\n\t[4\]\t388\n\t...and 123 more errors.] expected: FAIL + + [X ConstantSource.offset k-rate input: output[0:128\]: Expected 2 for all values but found 127 unexpected values: \n\tIndex\tActual\n\t[1\]\t2.9990234375\n\t[2\]\t3.998046875\n\t[3\]\t4.9970703125\n\t[4\]\t5.99609375\n\t...and 123 more errors.] + expected: FAIL + + [X ConstantSource.offset k-rate input: output[128:256\]: Expected 129.875 for all values but found 127 unexpected values: \n\tIndex\tActual\n\t[1\]\t130.8740234375\n\t[2\]\t131.873046875\n\t[3\]\t132.8720703125\n\t[4\]\t133.87109375\n\t...and 123 more errors.] + expected: FAIL + + [X ConstantSource.offset k-rate input: output[256:384\]: Expected 257.75 for all values but found 127 unexpected values: \n\tIndex\tActual\n\t[1\]\t258.7490234375\n\t[2\]\t259.748046875\n\t[3\]\t260.7470703125\n\t[4\]\t261.74609375\n\t...and 123 more errors.] + expected: FAIL + + [X ConstantSource.offset k-rate input: output[384:512\]: Expected 385.625 for all values but found 127 unexpected values: \n\tIndex\tActual\n\t[1\]\t386.6240234375\n\t[2\]\t387.623046875\n\t[3\]\t388.6220703125\n\t[4\]\t389.62109375\n\t...and 123 more errors.] + expected: FAIL + + [X ConstantSource.offset k-rate input: output[512:640\]: Expected 513.5 for all values but found 127 unexpected values: \n\tIndex\tActual\n\t[1\]\t514.4990234375\n\t[2\]\t515.498046875\n\t[3\]\t516.4970703125\n\t[4\]\t517.49609375\n\t...and 123 more errors.] + expected: FAIL + + [X ConstantSource.offset k-rate input: output[640:768\]: Expected 641.375 for all values but found 127 unexpected values: \n\tIndex\tActual\n\t[1\]\t642.3740234375\n\t[2\]\t643.373046875\n\t[3\]\t644.3720703125\n\t[4\]\t645.37109375\n\t...and 123 more errors.] + expected: FAIL + + [X ConstantSource.offset k-rate input: output[768:896\]: Expected 769.25 for all values but found 127 unexpected values: \n\tIndex\tActual\n\t[1\]\t770.2490234375\n\t[2\]\t771.248046875\n\t[3\]\t772.2470703125\n\t[4\]\t773.24609375\n\t...and 123 more errors.] + expected: FAIL + + [X ConstantSource.offset k-rate input: output[896:1024\]: Expected 897.125 for all values but found 127 unexpected values: \n\tIndex\tActual\n\t[1\]\t898.1240234375\n\t[2\]\t899.123046875\n\t[3\]\t900.1220703125\n\t[4\]\t901.12109375\n\t...and 123 more errors.] + expected: FAIL + + [< [ConstantSource.offset\] 8 out of 8 assertions were failed.] + expected: FAIL + + [# AUDIT TASK RUNNER FINISHED: 3 out of 3 tasks were failed.] + expected: FAIL diff --git a/testing/web-platform/meta/webaudio/the-audio-api/the-oscillatornode-interface/detune-limiting.html.ini b/testing/web-platform/meta/webaudio/the-audio-api/the-oscillatornode-interface/detune-limiting.html.ini index 0127b99218e8..f0fd69aa4854 100644 --- a/testing/web-platform/meta/webaudio/the-audio-api/the-oscillatornode-interface/detune-limiting.html.ini +++ b/testing/web-platform/meta/webaudio/the-audio-api/the-oscillatornode-interface/detune-limiting.html.ini @@ -13,3 +13,6 @@ [< [detune limits\] 1 out of 4 assertions were failed.] expected: FAIL + + [X osc[5:\]: Expected 0 for all values but found 5507 unexpected values: \n\tIndex\tActual\n\t[0\]\t0.652276873588562\n\t[1\]\t-0.4830973744392395\n\t[2\]\t0.1254984438419342\n\t[3\]\t-0.8726160526275635\n\t...and 5503 more errors.] + expected: FAIL