[EME] Fixed CDM async loading based on Bug 20991 comment 7
authorAdrian Bateman <adrianba@microsoft.com>
Thu, 14 Nov 2013 16:57:40 +0800
changeset 207 2719b617426e
parent 206 cda7de85614f
child 208 66c95f7f7436
[EME] Fixed CDM async loading based on Bug 20991 comment 7
encrypted-media/encrypted-media.html
encrypted-media/encrypted-media.xml
--- a/encrypted-media/encrypted-media.html	Thu Nov 14 15:48:48 2013 +0800
+++ b/encrypted-media/encrypted-media.html	Thu Nov 14 16:57:40 2013 +0800
@@ -310,10 +310,10 @@
       </li>
 
       <li>
-        <p>The user agent will asynchronously execute the following steps:</p>
+        <p>Schedule a task to execute the following steps:</p>
         <ol>
           <li><p>Let <var title="true">cdm</var> be the <a href="#cdm">content decryption module</a> corresponding to <var title="true">keySystem</var>.</p></li>
-          <li><p>Load <var title="true">cdm</var> if necessary.</p></li>
+          <li><p>Load and initialize the <var title="true">cdm</var> if necessary.</p></li>
           <li>
             <dl class="switch">
               <dt>If <var title="true">cdm</var> fails to load or initialize</dt>
@@ -349,8 +349,6 @@
     <ol>
       <li><p>If <var title="true">type</var> contains a MIME type that is not supported or is not supported by the <code><a href="#dom-keysystem">keySystem</a></code>, throw a <code><a href="https://dvcs.w3.org/hg/domcore/raw-file/tip/Overview.html#dom-domexception-not_supported_err">NOT_SUPPORTED_ERR</a></code> exception and abort these steps.</p></li>
 
-      <li><p>Let <var title="true">cdm</var> be the <var title="true">cdm</var> loaded in the <a href="#dom-media-keys-constructor"><code>MediaKeys</code> constructor</a>.</p></li>
-
       <li>Create a new <code><a href="#dom-mediakeysession">MediaKeySession</a></code> object.
         <ol>
           <li><p>Let the <code><a href="#dom-keysystem">keySystem</a></code> attribute be <var title="true">keySystem</var>.</p></li>
@@ -360,17 +358,18 @@
       
       <li><p>Add the new object to an internal list of session objects.</p></li>
 
-      <li><p>
-        If there is a <code><a href="#dom-mediakeyerror">MediaKeyError</a></code> stored with the <code><a href="#dom-mediakeys">MediaKeys</a></code> object that occurred because of an error loading the <var title="true">cdm</var>
-        then <a href="http://www.w3.org/TR/html5/webappapis.html#queue-a-task">queue a task</a> to <a href="http://www.w3.org/TR/html5/webappapis.html#fire-a-simple-event">fire a simple event</a> named <code><a href="#dom-eventerror">error</a></code> at the <code><a href="#dom-mediakeysession">MediaKeySession</a></code> object and abort these steps.
-      </p></li>
-
       <li>
 <p>Schedule a task to initialize the session, providing <var title="true">type</var>, <var title="true">initData</var>, and the new object.</p>
         <p>The user agent will asynchronously execute the following steps in the task:</p>
         <ol>
           <li><p>Let <var title="true">request</var> be null.</p></li>
           <li><p>Let <var title="true">defaultURL</var> be null.</p></li>
+          <li><p>Wait for the <a href="#dom-media-keys-constructor"><code>MediaKeys</code> constructor</a> task to complete.</p></li>
+          <li><p>
+            If there is a <code><a href="#dom-mediakeyerror">MediaKeyError</a></code> stored with the <code><a href="#dom-mediakeys">MediaKeys</a></code> object that occurred because of an error during the  loading the <a href="#dom-media-keys-constructor"><code>MediaKeys</code> constructor</a> task
+            then <a href="http://www.w3.org/TR/html5/webappapis.html#queue-a-task">queue a task</a> to <a href="http://www.w3.org/TR/html5/webappapis.html#fire-a-simple-event">fire a simple event</a> named <code><a href="#dom-eventerror">error</a></code> at the <code><a href="#dom-mediakeysession">MediaKeySession</a></code> object and abort these steps.
+          </p></li>
+          <li><p>Let <var title="true">cdm</var> be the <var title="true">cdm</var> loaded in the <a href="#dom-media-keys-constructor"><code>MediaKeys</code> constructor</a>.</p></li>
           <li>
 <p>Use <var title="true">cdm</var> to execute the following steps:</p>
             <ol>
--- a/encrypted-media/encrypted-media.xml	Thu Nov 14 15:48:48 2013 +0800
+++ b/encrypted-media/encrypted-media.xml	Thu Nov 14 16:57:40 2013 +0800
@@ -307,10 +307,10 @@
       </li>
 
       <li>
-        <p>The user agent will asynchronously execute the following steps:</p>
+        <p>Schedule a task to execute the following steps:</p>
         <ol>
           <li><p>Let <var title="true">cdm</var> be the <a href="#cdm">content decryption module</a> corresponding to <var title="true">keySystem</var>.</p></li>
-          <li><p>Load <var title="true">cdm</var> if necessary.</p></li>
+          <li><p>Load and initialize the <var title="true">cdm</var> if necessary.</p></li>
           <li>
             <dl class="switch">
               <dt>If <var title="true">cdm</var> fails to load or initialize</dt>
@@ -345,8 +345,6 @@
     <ol>
       <li><p>If <var title="true">type</var> contains a MIME type that is not supported or is not supported by the <coderef>keySystem</coderef>, throw a <not-supported-err/> exception and abort these steps.</p></li>
 
-      <li><p>Let <var title="true">cdm</var> be the <var title="true">cdm</var> loaded in the <a href="#dom-media-keys-constructor"><code>MediaKeys</code> constructor</a>.</p></li>
-
       <li>Create a new <coderef>MediaKeySession</coderef> object.
         <ol>
           <li><p>Let the <coderef>keySystem</coderef> attribute be <var title="true">keySystem</var>.</p></li>
@@ -356,16 +354,17 @@
       
       <li><p>Add the new object to an internal list of session objects.</p></li>
 
-      <li><p>
-        If there is a <coderef>MediaKeyError</coderef> stored with the <coderef>MediaKeys</coderef> object that occurred because of an error loading the <var title="true">cdm</var>
-        then <queue-a-task/> to <fire-a-simple-event/> named <coderef prefix="event">error</coderef> at the <coderef>MediaKeySession</coderef> object and abort these steps.
-      </p></li>
-
       <li><p>Schedule a task to initialize the session, providing <var title="true">type</var>, <var title="true">initData</var>, and the new object.</p>
         <p>The user agent will asynchronously execute the following steps in the task:</p>
         <ol>
           <li><p>Let <var title="true">request</var> be null.</p></li>
           <li><p>Let <var title="true">defaultURL</var> be null.</p></li>
+          <li><p>Wait for the <a href="#dom-media-keys-constructor"><code>MediaKeys</code> constructor</a> task to complete.</p></li>
+          <li><p>
+            If there is a <coderef>MediaKeyError</coderef> stored with the <coderef>MediaKeys</coderef> object that occurred because of an error during the  loading the <a href="#dom-media-keys-constructor"><code>MediaKeys</code> constructor</a> task
+            then <queue-a-task/> to <fire-a-simple-event/> named <coderef prefix="event">error</coderef> at the <coderef>MediaKeySession</coderef> object and abort these steps.
+          </p></li>
+          <li><p>Let <var title="true">cdm</var> be the <var title="true">cdm</var> loaded in the <a href="#dom-media-keys-constructor"><code>MediaKeys</code> constructor</a>.</p></li>
           <li><p>Use <var title="true">cdm</var> to execute the following steps:</p>
             <ol>
               <li><p>Process <var title="true">type</var> and <var title="true">initData</var>.</p>