| author | Ehsan Akhgari <ehsan@mozilla.com> |
| Tue, 30 Oct 2012 20:12:19 -0400 | |
| changeset 112045 | 5fc85295afde2d41eec6d4ae04421ad8192ca5ed |
| parent 112044 | 4d8717e04a99c2d003164517e2c00c235dffe8a9 |
| child 112046 | ef4e2c69f73e6c31ef451a5ced3375620c86941d |
| push id | 23790 |
| push user | ryanvm@gmail.com |
| push date | Fri, 02 Nov 2012 01:26:40 +0000 |
| treeherder | mozilla-central@556b9cfb269f [default view] [failures only] |
| perfherder | [talos] [build metrics] [platform microbench] (compared to previous push) |
| reviewers | bzbarsky |
| bugs | 807171 |
| milestone | 19.0a1 |
| first release with | nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
|
| last release without | nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
|
--- a/content/media/webaudio/AudioEventTimeline.h +++ b/content/media/webaudio/AudioEventTimeline.h @@ -148,17 +148,29 @@ public: void SetValueCurveAtTime(const FloatArrayWrapper& aValues, float aStartTime, float aDuration, ErrorResult& aRv) { // TODO: implement // InsertEvent(Event(Event::SetValueCurve, aStartTime, 0.0f, 0.0f, aDuration, aValues), aRv); } void CancelScheduledValues(float aStartTime) { - // TODO: implement + for (unsigned i = 0; i < mEvents.Length(); ++i) { + if (mEvents[i].mTime >= aStartTime) { +#ifdef DEBUG + // Sanity check: the array should be sorted, so all of the following + // events should have a time greater than aStartTime too. + for (unsigned j = i + 1; j < mEvents.Length(); ++j) { + MOZ_ASSERT(mEvents[j].mTime >= aStartTime); + } +#endif + mEvents.TruncateLength(i); + break; + } + } } // This method computes the AudioParam value at a given time based on the event timeline float GetValueAtTime(float aTime) const { const Event* previous = nullptr; const Event* next = nullptr;
--- a/content/media/webaudio/compiledtest/TestAudioEventTimeline.cpp +++ b/content/media/webaudio/compiledtest/TestAudioEventTimeline.cpp @@ -203,16 +203,35 @@ void TestEventReplacement() is(timeline.GetEventCount(), 1, "Event should be replaced"); is(timeline.GetValueAtTime(0.1f), 20.0f, "The first event should be overwritten"); timeline.LinearRampToValueAtTime(30.0f, 0.1f, rv); is(rv, NS_OK, "Event scheduling should be successful"); is(timeline.GetEventCount(), 2, "Different event type should be appended"); is(timeline.GetValueAtTime(0.1f), 30.0f, "The first event should be overwritten"); } +void TestEventRemoval() +{ + Timeline timeline(10.0f, .1f, 20.0f); + + ErrorResultMock rv; + + timeline.SetValueAtTime(10.0f, 0.1f, rv); + timeline.SetValueAtTime(15.0f, 0.15f, rv); + timeline.SetValueAtTime(20.0f, 0.2f, rv); + timeline.LinearRampToValueAtTime(30.0f, 0.3f, rv); + is(timeline.GetEventCount(), 4, "Should have three events initially"); + timeline.CancelScheduledValues(0.4f); + is(timeline.GetEventCount(), 4, "Trying to delete past the end of the array should have no effect"); + timeline.CancelScheduledValues(0.3f); + is(timeline.GetEventCount(), 3, "Should successfully delete one event"); + timeline.CancelScheduledValues(0.12f); + is(timeline.GetEventCount(), 1, "Should successfully delete two events"); +} + void TestBeforeFirstEvent() { Timeline timeline(10.0f, .1f, 20.0f); ErrorResultMock rv; timeline.SetValueAtTime(20.0f, 1.0f, rv); is(timeline.GetValueAtTime(0.5f), 10.0f, "Retrun the default value before the first event"); @@ -322,16 +341,17 @@ int main() ScopedXPCOM xpcom("TestAudioEventTimeline"); if (xpcom.failed()) { return 1; } TestSpecExample(); TestInvalidEvents(); TestEventReplacement(); + TestEventRemoval(); TestBeforeFirstEvent(); TestAfterLastValueEvent(); TestAfterLastTargetValueEvent(); TestAfterLastTargetValueEventWithValueSet(); TestValue(); TestLinearRampAtZero(); TestExponentialRampAtZero(); TestLinearRampAtSameTime();
--- a/dom/webidl/AudioParam.webidl +++ b/dom/webidl/AudioParam.webidl @@ -32,12 +32,12 @@ interface AudioParam { void setTargetAtTime(float target, float startTime, float timeConstant); // Sets an array of arbitrary parameter values starting at time for the given duration. // The number of values will be scaled to fit into the desired duration. // [Throws] // void setValueCurveAtTime(Float32Array values, float startTime, float duration); // Cancels all scheduled parameter changes with times greater than or equal to startTime. - // void cancelScheduledValues(float startTime); + void cancelScheduledValues(float startTime); };