Re: Corner cases on start/stop exceptions

Raymond Toy writes:

> A few questions on corner cases when start or stop is called too many
> times. The spec currently says exceptions are thrown when start or stop is
> called more than once.  But what should happen to the audio in the
> following cases?
> Let c be the context and s be an oscillator
> s.start(10); s.start(0)
> The second start must throw an error, but does the oscillator start playing
> after 10 sec?
> s.start(); s.stop(c.currentTime + 10); s.stop(c.currentTime + 5)
> The second stop() must throw an error, but what happens to the audio? Does
> it stop at currentTime+10? Stop immediately? Something else?

It think it is best if methods that throw exceptions leave no side
effects, but, as pointed out in [1], the spec could clarify.

I would expect the audio to start at 10 sec and stop at currentTime + 10.

> Also, the current draft says this in section 4.10.2 for the stop method:
>     stop must only be called one time and only after a call to start or
> stop, or an INVALID_STATE_ERR  exception MUST be thrown
> The part that says "or stop" should probably be deleted, since you can only
> call stop once.

I admit there seems no reason for the "or stop" if start() "must
only be called one time".  [2] looks confused and I wonder what the
original intention was.

I see that after that commit there was a request [3] to allow
multiple stop calls.  That may be useful for stopping early, but I
wouldn't want to allow the stop time to be advanced because that
would introduce race conditions, and restarting the audio was
never intended.  duration and stop already exist to provide for
stopping early, if not looping.  I think it would be better to extend
duration to looping also, than to allow multiple stop calls just
for this use case.

Adding a |duration| parameter to start() on OscillatorNode would
also allow a precise duration if starting immediately.


Received on Wednesday, 30 October 2013 21:53:23 UTC