Skip to content

Commit

Permalink
[giow] (1) Make seeking async since some implementations can't tell i…
Browse files Browse the repository at this point in the history
…f something is seekable synchronously. Also, make it not throw ever, and make it sanely re-entrant.

git-svn-id: http://svn.whatwg.org/webapps@4868 340c8d12-0b0e-0410-8428-c7bf67bfef74
  • Loading branch information
Hixie committed Mar 25, 2010
1 parent 630cc3d commit 5e4248e
Show file tree
Hide file tree
Showing 3 changed files with 187 additions and 114 deletions.
97 changes: 60 additions & 37 deletions complete.html
Original file line number Diff line number Diff line change
Expand Up @@ -24435,12 +24435,35 @@ <h5 id=seeking><span class=secno>4.8.9.9 </span>Seeking</h5>

<p>When the user agent is required to <dfn id=dom-media-seek title=dom-media-seek>seek</dfn> to a particular <var title="">new
playback position</var> in the <a href=#media-resource>media resource</a>, it means
that the user agent must run the following steps:</p>
that the user agent must run the following steps. This algorithm
interacts closely with the <a href=#event-loop>event loop</a> mechanism; in
particular, it has a <a href=#synchronous-section>synchronous
section</a> (which is triggered as part of the <a href=#event-loop>event
loop</a> algorithm). Steps in that section are marked with
&#8987;.</p>

<ol><li><p>If the <a href=#media-element>media element</a>'s <code title=dom-media-readyState><a href=#dom-media-readystate>readyState</a></code> is <code title=dom-media-HAVE_NOTHING><a href=#dom-media-have_nothing>HAVE_NOTHING</a></code>, then raise an
<code><a href=#invalid_state_err>INVALID_STATE_ERR</a></code> exception (if the seek was in
response to a DOM method call or setting of an IDL attribute), and
abort these steps.</li>

<li><p>If the element's <code title=dom-media-seeking><a href=#dom-media-seeking>seeking</a></code> IDL attribute is true,
then another instance of this algorithm is already running. Abort
that other instance of the algorithm without waiting for the step
that it is running to complete.</li>

<li><p>Set the <code title=dom-media-seeking><a href=#dom-media-seeking>seeking</a></code> IDL
attribute to true.</li>

<li id=seekUpdate><p><a href=#queue-a-task>Queue a task</a> to <a href=#fire-a-simple-event>fire a
simple event</a> named <code title=event-media-timeupdate><a href=#event-media-timeupdate>timeupdate</a></code> at the
element.</li>

<ol><li><p>If the <a href=#media-element>media element</a>'s <code title=dom-media-readyState><a href=#dom-media-readystate>readyState</a></code> is <code title=dom-media-HAVE_NOTHING><a href=#dom-media-have_nothing>HAVE_NOTHING</a></code>, then the user
agent must raise an <code><a href=#invalid_state_err>INVALID_STATE_ERR</a></code> exception (if
the seek was in response to a DOM method call or setting of an IDL
attribute), and abort these steps.</li>
<li><p>If the seek was in response to a DOM method call or setting
of an IDL attribute, then continue the script. The remainder of
these steps must be run asynchronously. With the exception of the
steps marked with &#8987;, they could be aborted at any time by
another instance of this algorithm being invoked.</li>

<li><p>If the <var title="">new playback position</var> is later
than the end of the <a href=#media-resource>media resource</a>, then let it be the
Expand All @@ -24451,49 +24474,49 @@ <h5 id=seeking><span class=secno>4.8.9.9 </span>Seeking</h5>
position instead.</li>

<li><p>If the (possibly now changed) <var title="">new playback
position</var> is not in one of the ranges given in the <code title=dom-media-seekable><a href=#dom-media-seekable>seekable</a></code> attribute, then the user
agent must raise an <code><a href=#index_size_err>INDEX_SIZE_ERR</a></code> exception (if the
seek was in response to a DOM method call or setting of an IDL
attribute), and abort these steps.</li>

<li><p>The <a href=#current-playback-position>current playback position</a> must be set to
the given <var title="">new playback position</var>.</li>

<li><p>The <code title=dom-media-seeking><a href=#dom-media-seeking>seeking</a></code> IDL
attribute must be set to true.</li>

<li id=seekUpdate><p>The user agent must <a href=#queue-a-task>queue a
task</a> to <a href=#fire-a-simple-event>fire a simple event</a> named <code title=event-media-timeupdate><a href=#event-media-timeupdate>timeupdate</a></code> at the element.</li>
position</var> is not in one of the ranges given in the <code title=dom-media-seekable><a href=#dom-media-seekable>seekable</a></code> attribute, then let it
be the position in one of the ranges given in the <code title=dom-media-seekable><a href=#dom-media-seekable>seekable</a></code> attribute that is the
nearest to the <var title="">new playback position</var>. If two
positions both satisfy that constraint (i.e. the <var title="">new
playback position</var> is exactly in the middle of a range in the
<code title=dom-media-seekable><a href=#dom-media-seekable>seekable</a></code> attribute) then
use the position that is closest to the <a href=#current-playback-position>current playback
position</a>. If there are no ranges given in the <code title=dom-media-seekable><a href=#dom-media-seekable>seekable</a></code> attribute then set the
<code title=dom-media-seeking><a href=#dom-media-seeking>seeking</a></code> IDL attribute to
false and abort these steps.</li>

<li><p>Set the <a href=#current-playback-position>current playback position</a> to the given
<var title="">new playback position</var>.</li>

<li><p>If the <a href=#media-element>media element</a> was <a href=#potentially-playing>potentially
playing</a> immediately before it started seeking, but seeking
caused its <code title=dom-media-readyState><a href=#dom-media-readystate>readyState</a></code>
attribute to change to a value lower than <code title=dom-media-HAVE_FUTURE_DATA><a href=#dom-media-have_future_data>HAVE_FUTURE_DATA</a></code>, the
user agent must <a href=#queue-a-task>queue a task</a> to <a href=#fire-a-simple-event>fire a simple
event</a> named <code title=event-media-waiting><a href=#event-media-waiting>waiting</a></code> at
the element.</li>
attribute to change to a value lower than <code title=dom-media-HAVE_FUTURE_DATA><a href=#dom-media-have_future_data>HAVE_FUTURE_DATA</a></code>, then
<a href=#queue-a-task>queue a task</a> to <a href=#fire-a-simple-event>fire a simple event</a> named
<code title=event-media-waiting><a href=#event-media-waiting>waiting</a></code> at the
element.</li>

<li><p>If, when it reaches this step, the user agent has still not
established whether or not the <a href=#media-data>media data</a> for the <var title="">new playback position</var> is available, and, if it is,
decoded enough data to play back that position, the user agent must
<a href=#queue-a-task>queue a task</a> to <a href=#fire-a-simple-event>fire a simple event</a>
named <code title=event-media-seeking><a href=#event-media-seeking>seeking</a></code> at the
element.</li>
decoded enough data to play back that position, then <a href=#queue-a-task>queue a
task</a> to <a href=#fire-a-simple-event>fire a simple event</a> named <code title=event-media-seeking><a href=#event-media-seeking>seeking</a></code> at the element.</li>

<li><p>If the seek was in response to a DOM method call or setting
of an IDL attribute, then continue the script. The remainder of
these steps must be run asynchronously.</li>
<li><p>Wait until it has established whether or not the <a href=#media-data>media
data</a> for the <var title="">new playback position</var> is
available, and, if it is, until it has decoded enough data to play
back that position.</li>

<li><p>The user agent must wait until it has established whether or
not the <a href=#media-data>media data</a> for the <var title="">new playback
position</var> is available, and, if it is, until it has decoded
enough data to play back that position.</li>
<li><p><a href=#await-a-stable-state>Await a stable state</a>. The <a href=#synchronous-section>synchronous
section</a> consists of all the remaining steps of this
algorithm. (Steps in the <a href=#synchronous-section>synchronous section</a> are
marked with &#8987;.)</li>

<li><p>The <code title=dom-media-seeking><a href=#dom-media-seeking>seeking</a></code> IDL
attribute must be set to false.</li>
<li><p>&#8987; Set the <code title=dom-media-seeking><a href=#dom-media-seeking>seeking</a></code> IDL attribute to
false.</li>

<li><p>The user agent must <a href=#queue-a-task>queue a task</a> to <a href=#fire-a-simple-event>fire
a simple event</a> named <code title=event-media-seeked><a href=#event-media-seeked>seeked</a></code> at the element.</li>
<li><p>&#8987; <a href=#queue-a-task>Queue a task</a> to <a href=#fire-a-simple-event>fire a simple
event</a> named <code title=event-media-seeked><a href=#event-media-seeked>seeked</a></code>
at the element.</li>

</ol><p>The <dfn id=dom-media-seekable title=dom-media-seekable><code>seekable</code></dfn>
attribute must return a new static <a href=#normalized-timeranges-object>normalized
Expand Down
99 changes: 61 additions & 38 deletions index
Original file line number Diff line number Diff line change
Expand Up @@ -173,7 +173,7 @@

<header class=head id=head><p><a class=logo href=http://www.whatwg.org/ rel=home><img alt=WHATWG src=/images/logo></a></p>
<hgroup><h1>HTML5 (including next generation additions still in development)</h1>
<h2 class="no-num no-toc">Draft Standard &mdash; 24 March 2010</h2>
<h2 class="no-num no-toc">Draft Standard &mdash; 25 March 2010</h2>
</hgroup><p>You can take part in this work. <a href=http://www.whatwg.org/mailing-list>Join the working group's discussion list.</a></p>
<p><strong>Web designers!</strong> We have a <a href=http://blog.whatwg.org/faq/>FAQ</a>, a <a href=http://forums.whatwg.org/>forum</a>, and a <a href=http://www.whatwg.org/mailing-list#help>help mailing list</a> for you!</p>
<!--<p class="impl"><strong>Implementors!</strong> We have a <a href="http://www.whatwg.org/mailing-list#implementors">mailing list</a> for you too!</p>-->
Expand Down Expand Up @@ -24336,12 +24336,35 @@ interface <dfn>CueRangeCallback</dfn> {

<p>When the user agent is required to <dfn id=dom-media-seek title=dom-media-seek>seek</dfn> to a particular <var title="">new
playback position</var> in the <a href=#media-resource>media resource</a>, it means
that the user agent must run the following steps:</p>
that the user agent must run the following steps. This algorithm
interacts closely with the <a href=#event-loop>event loop</a> mechanism; in
particular, it has a <a href=#synchronous-section>synchronous
section</a> (which is triggered as part of the <a href=#event-loop>event
loop</a> algorithm). Steps in that section are marked with
&#8987;.</p>

<ol><li><p>If the <a href=#media-element>media element</a>'s <code title=dom-media-readyState><a href=#dom-media-readystate>readyState</a></code> is <code title=dom-media-HAVE_NOTHING><a href=#dom-media-have_nothing>HAVE_NOTHING</a></code>, then raise an
<code><a href=#invalid_state_err>INVALID_STATE_ERR</a></code> exception (if the seek was in
response to a DOM method call or setting of an IDL attribute), and
abort these steps.</li>

<li><p>If the element's <code title=dom-media-seeking><a href=#dom-media-seeking>seeking</a></code> IDL attribute is true,
then another instance of this algorithm is already running. Abort
that other instance of the algorithm without waiting for the step
that it is running to complete.</li>

<li><p>Set the <code title=dom-media-seeking><a href=#dom-media-seeking>seeking</a></code> IDL
attribute to true.</li>

<li id=seekUpdate><p><a href=#queue-a-task>Queue a task</a> to <a href=#fire-a-simple-event>fire a
simple event</a> named <code title=event-media-timeupdate><a href=#event-media-timeupdate>timeupdate</a></code> at the
element.</li>

<ol><li><p>If the <a href=#media-element>media element</a>'s <code title=dom-media-readyState><a href=#dom-media-readystate>readyState</a></code> is <code title=dom-media-HAVE_NOTHING><a href=#dom-media-have_nothing>HAVE_NOTHING</a></code>, then the user
agent must raise an <code><a href=#invalid_state_err>INVALID_STATE_ERR</a></code> exception (if
the seek was in response to a DOM method call or setting of an IDL
attribute), and abort these steps.</li>
<li><p>If the seek was in response to a DOM method call or setting
of an IDL attribute, then continue the script. The remainder of
these steps must be run asynchronously. With the exception of the
steps marked with &#8987;, they could be aborted at any time by
another instance of this algorithm being invoked.</li>

<li><p>If the <var title="">new playback position</var> is later
than the end of the <a href=#media-resource>media resource</a>, then let it be the
Expand All @@ -24352,49 +24375,49 @@ interface <dfn>CueRangeCallback</dfn> {
position instead.</li>

<li><p>If the (possibly now changed) <var title="">new playback
position</var> is not in one of the ranges given in the <code title=dom-media-seekable><a href=#dom-media-seekable>seekable</a></code> attribute, then the user
agent must raise an <code><a href=#index_size_err>INDEX_SIZE_ERR</a></code> exception (if the
seek was in response to a DOM method call or setting of an IDL
attribute), and abort these steps.</li>

<li><p>The <a href=#current-playback-position>current playback position</a> must be set to
the given <var title="">new playback position</var>.</li>

<li><p>The <code title=dom-media-seeking><a href=#dom-media-seeking>seeking</a></code> IDL
attribute must be set to true.</li>

<li id=seekUpdate><p>The user agent must <a href=#queue-a-task>queue a
task</a> to <a href=#fire-a-simple-event>fire a simple event</a> named <code title=event-media-timeupdate><a href=#event-media-timeupdate>timeupdate</a></code> at the element.</li>
position</var> is not in one of the ranges given in the <code title=dom-media-seekable><a href=#dom-media-seekable>seekable</a></code> attribute, then let it
be the position in one of the ranges given in the <code title=dom-media-seekable><a href=#dom-media-seekable>seekable</a></code> attribute that is the
nearest to the <var title="">new playback position</var>. If two
positions both satisfy that constraint (i.e. the <var title="">new
playback position</var> is exactly in the middle of a range in the
<code title=dom-media-seekable><a href=#dom-media-seekable>seekable</a></code> attribute) then
use the position that is closest to the <a href=#current-playback-position>current playback
position</a>. If there are no ranges given in the <code title=dom-media-seekable><a href=#dom-media-seekable>seekable</a></code> attribute then set the
<code title=dom-media-seeking><a href=#dom-media-seeking>seeking</a></code> IDL attribute to
false and abort these steps.</li>

<li><p>Set the <a href=#current-playback-position>current playback position</a> to the given
<var title="">new playback position</var>.</li>

<li><p>If the <a href=#media-element>media element</a> was <a href=#potentially-playing>potentially
playing</a> immediately before it started seeking, but seeking
caused its <code title=dom-media-readyState><a href=#dom-media-readystate>readyState</a></code>
attribute to change to a value lower than <code title=dom-media-HAVE_FUTURE_DATA><a href=#dom-media-have_future_data>HAVE_FUTURE_DATA</a></code>, the
user agent must <a href=#queue-a-task>queue a task</a> to <a href=#fire-a-simple-event>fire a simple
event</a> named <code title=event-media-waiting><a href=#event-media-waiting>waiting</a></code> at
the element.</li>
attribute to change to a value lower than <code title=dom-media-HAVE_FUTURE_DATA><a href=#dom-media-have_future_data>HAVE_FUTURE_DATA</a></code>, then
<a href=#queue-a-task>queue a task</a> to <a href=#fire-a-simple-event>fire a simple event</a> named
<code title=event-media-waiting><a href=#event-media-waiting>waiting</a></code> at the
element.</li>

<li><p>If, when it reaches this step, the user agent has still not
established whether or not the <a href=#media-data>media data</a> for the <var title="">new playback position</var> is available, and, if it is,
decoded enough data to play back that position, the user agent must
<a href=#queue-a-task>queue a task</a> to <a href=#fire-a-simple-event>fire a simple event</a>
named <code title=event-media-seeking><a href=#event-media-seeking>seeking</a></code> at the
element.</li>
decoded enough data to play back that position, then <a href=#queue-a-task>queue a
task</a> to <a href=#fire-a-simple-event>fire a simple event</a> named <code title=event-media-seeking><a href=#event-media-seeking>seeking</a></code> at the element.</li>

<li><p>If the seek was in response to a DOM method call or setting
of an IDL attribute, then continue the script. The remainder of
these steps must be run asynchronously.</li>
<li><p>Wait until it has established whether or not the <a href=#media-data>media
data</a> for the <var title="">new playback position</var> is
available, and, if it is, until it has decoded enough data to play
back that position.</li>

<li><p>The user agent must wait until it has established whether or
not the <a href=#media-data>media data</a> for the <var title="">new playback
position</var> is available, and, if it is, until it has decoded
enough data to play back that position.</li>
<li><p><a href=#await-a-stable-state>Await a stable state</a>. The <a href=#synchronous-section>synchronous
section</a> consists of all the remaining steps of this
algorithm. (Steps in the <a href=#synchronous-section>synchronous section</a> are
marked with &#8987;.)</li>

<li><p>The <code title=dom-media-seeking><a href=#dom-media-seeking>seeking</a></code> IDL
attribute must be set to false.</li>
<li><p>&#8987; Set the <code title=dom-media-seeking><a href=#dom-media-seeking>seeking</a></code> IDL attribute to
false.</li>

<li><p>The user agent must <a href=#queue-a-task>queue a task</a> to <a href=#fire-a-simple-event>fire
a simple event</a> named <code title=event-media-seeked><a href=#event-media-seeked>seeked</a></code> at the element.</li>
<li><p>&#8987; <a href=#queue-a-task>Queue a task</a> to <a href=#fire-a-simple-event>fire a simple
event</a> named <code title=event-media-seeked><a href=#event-media-seeked>seeked</a></code>
at the element.</li>

</ol><p>The <dfn id=dom-media-seekable title=dom-media-seekable><code>seekable</code></dfn>
attribute must return a new static <a href=#normalized-timeranges-object>normalized
Expand Down
Loading

0 comments on commit 5e4248e

Please sign in to comment.