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
This commit is contained in:
Paul Adenot
2024-11-20 14:53:12 +00:00
parent 284f991de0
commit 79f1bb0efd
8 changed files with 71 additions and 39 deletions

View File

@@ -482,7 +482,6 @@ void AudioEventTimeline::GetValuesAtTimeHelperInternal(
case AudioTimelineEvent::SetTarget: case AudioTimelineEvent::SetTarget:
case AudioTimelineEvent::SetValueCurve: case AudioTimelineEvent::SetValueCurve:
break; break;
case AudioTimelineEvent::SetValue:
case AudioTimelineEvent::Cancel: case AudioTimelineEvent::Cancel:
case AudioTimelineEvent::Track: case AudioTimelineEvent::Track:
MOZ_ASSERT(false, "Should have been handled earlier."); MOZ_ASSERT(false, "Should have been handled earlier.");
@@ -500,7 +499,6 @@ void AudioEventTimeline::GetValuesAtTimeHelperInternal(
break; break;
case AudioTimelineEvent::SetTarget: case AudioTimelineEvent::SetTarget:
MOZ_FALLTHROUGH_ASSERT("AudioTimelineEvent::SetTarget"); MOZ_FALLTHROUGH_ASSERT("AudioTimelineEvent::SetTarget");
case AudioTimelineEvent::SetValue:
case AudioTimelineEvent::Cancel: case AudioTimelineEvent::Cancel:
case AudioTimelineEvent::Track: case AudioTimelineEvent::Track:
MOZ_ASSERT(false, "Should have been handled earlier."); MOZ_ASSERT(false, "Should have been handled earlier.");

View File

@@ -31,8 +31,8 @@ namespace dom {
struct AudioTimelineEvent { struct AudioTimelineEvent {
MOZ_DEFINE_ENUM_WITH_BASE_AND_TOSTRING_AT_CLASS_SCOPE( MOZ_DEFINE_ENUM_WITH_BASE_AND_TOSTRING_AT_CLASS_SCOPE(
Type, uint32_t, Type, uint32_t,
(SetValue, SetValueAtTime, LinearRamp, ExponentialRamp, SetTarget, (SetValueAtTime, LinearRamp, ExponentialRamp, SetTarget, SetValueCurve,
SetValueCurve, Track, Cancel)); Track, Cancel));
class TimeUnion { class TimeUnion {
public: public:
@@ -313,17 +313,6 @@ class AudioEventTimeline {
return mSimpleValue.value(); 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 <typename TimeType> template <typename TimeType>
void CancelScheduledValues(TimeType aStartTime) { void CancelScheduledValues(TimeType aStartTime) {
for (unsigned i = 0; i < mEvents.Length(); ++i) { for (unsigned i = 0; i < mEvents.Length(); ++i) {

View File

@@ -8,6 +8,7 @@
#define AudioParam_h_ #define AudioParam_h_
#include "AudioParamTimeline.h" #include "AudioParamTimeline.h"
#include "mozilla/ErrorResult.h"
#include "nsWrapperCache.h" #include "nsWrapperCache.h"
#include "nsCycleCollectionParticipant.h" #include "nsCycleCollectionParticipant.h"
#include "AudioNode.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. // Intended for use in AudioNode creation, when the setter should not throw.
void SetInitialValue(float aValue) { void SetInitialValue(float aValue) {
MOZ_ASSERT(HasSimpleValue(), "Existing events unexpected"); IgnoredErrorResult rv;
AudioParamEvent event(AudioTimelineEvent::SetValue, 0.0f, aValue); SetValue(aValue, rv);
DebugOnly<ErrorResult> rv;
MOZ_ASSERT(ValidateEvent(event, rv), "This event should be valid");
AudioParamTimeline::SetValue(aValue);
SendEventToEngine(event);
} }
void SetValue(float aValue, ErrorResult& aRv) { void SetValue(float aValue, ErrorResult& aRv) {
AudioParamEvent event(AudioTimelineEvent::SetValue, 0.0f, aValue); SetValueAtTime(aValue, GetParentObject()->CurrentTime(), aRv);
if (!ValidateEvent(event, aRv)) {
return;
}
AudioParamTimeline::SetValue(aValue);
SendEventToEngine(event);
} }
AudioParam* SetValueAtTime(float aValue, double aStartTime, AudioParam* SetValueAtTime(float aValue, double aStartTime,

View File

@@ -64,10 +64,6 @@ class AudioParamTimeline : public AudioEventTimeline {
mTrack = aEvent.mTrack; mTrack = aEvent.mTrack;
return; return;
} }
if (aEvent.mType == AudioTimelineEvent::SetValue) {
AudioEventTimeline::SetValue(aEvent.NominalValue());
return;
}
AudioEventTimeline::InsertEvent<TimeType>(aEvent); AudioEventTimeline::InsertEvent<TimeType>(aEvent);
} }

View File

@@ -1,8 +1,8 @@
[test-analyser-resume-after-suspended.html] [test-analyser-resume-after-suspended.html]
expected: expected:
if (os == "mac") and debug: [OK, TIMEOUT] if (os == "mac") and debug: [OK, TIMEOUT]
if os == "linux": ERROR if os == "linux": [ERROR, TIMEOUT]
[AnalyserNode resume after suspended] [AnalyserNode resume after suspended]
expected: expected:
if (os == "mac") and debug: [PASS, TIMEOUT] if (os == "mac") and debug: [PASS, TIMEOUT]
if os == "linux": TIMEOUT if os == "linux": [PASS, TIMEOUT]

View File

@@ -30,3 +30,33 @@
[< [StereoPanner\] 8 out of 8 assertions were failed.] [< [StereoPanner\] 8 out of 8 assertions were failed.]
expected: FAIL 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

View File

@@ -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.] [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 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

View File

@@ -13,3 +13,6 @@
[< [detune limits\] 1 out of 4 assertions were failed.] [< [detune limits\] 1 out of 4 assertions were failed.]
expected: FAIL 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