media icon indicating copy to clipboard operation
media copied to clipboard

AudioParam: Running only one event per tick leads to off-by-one event_start_time

Open collares opened this issue 6 years ago • 2 comments

Consider the following line, from WPT (the-audioparam-interface/audioparam-method-chaining.html):

envelope.gain
    .setValueAtTime(0.0, 0.0)
    .linearRampToValueAtTime(1.0, 1.0);

If I understand correctly, setValueAtTime runs at tick 0. We only process one event per tick, so linearRampToValueAtTime waits until tick 1 to run, at which point event_start_time gets set: https://github.com/servo/media/blob/eafa387be6424c99efc11231c9c5a03284116ddb/audio/param.rs#L150 The linearRamp line then starts at this point (value 0 at tick 1), when it should have started at tick 0.

collares avatar Aug 21 '19 23:08 collares

Oh, hmm. I fixed one off by one but I vaguely recall seeing similar stuff afterwards. Thanks for investigating!

Manishearth avatar Aug 22 '19 14:08 Manishearth

The two ifs here should probably have their own tryrecv loops

https://github.com/servo/media/blob/master/audio/render_thread.rs#L296

Manishearth avatar Aug 22 '19 14:08 Manishearth