| OLD | NEW |
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 cr.define('hotword', function() { | 5 cr.define('hotword', function() { |
| 6 'use strict'; | 6 'use strict'; |
| 7 | 7 |
| 8 /** | 8 /** |
| 9 * Class used to manage the state of the NaCl recognizer plugin. Handles all | 9 * Class used to manage the state of the NaCl recognizer plugin. Handles all |
| 10 * control of the NaCl plugin, including creation, start, stop, trigger, and | 10 * control of the NaCl plugin, including creation, start, stop, trigger, and |
| (...skipping 154 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 165 } else { | 165 } else { |
| 166 throw 'Attempting to start NaCl recogniser not in STOPPED or STOPPING ' + | 166 throw 'Attempting to start NaCl recogniser not in STOPPED or STOPPING ' + |
| 167 'state'; | 167 'state'; |
| 168 } | 168 } |
| 169 }; | 169 }; |
| 170 | 170 |
| 171 /** | 171 /** |
| 172 * Stops the hotword recognizer. | 172 * Stops the hotword recognizer. |
| 173 */ | 173 */ |
| 174 NaClManager.prototype.stopRecognizer = function() { | 174 NaClManager.prototype.stopRecognizer = function() { |
| 175 if (this.recognizerState_ == ManagerState_.STARTING) { |
| 176 // If the recognizer is stopped before it finishes starting, it causes an |
| 177 // assertion to be raised in waitForMessage_() since we're waiting for the |
| 178 // READY_FOR_AUDIO message. Clear the current timeout and expecting message |
| 179 // since we no longer expect it and may never receive it. |
| 180 this.clearTimeout_(); |
| 181 this.expectingMessage_ = null; |
| 182 } |
| 175 this.sendDataToPlugin_(hotword.constants.NaClPlugin.STOP); | 183 this.sendDataToPlugin_(hotword.constants.NaClPlugin.STOP); |
| 176 this.recognizerState_ = ManagerState_.STOPPING; | 184 this.recognizerState_ = ManagerState_.STOPPING; |
| 177 this.waitForMessage_(hotword.constants.TimeoutMs.NORMAL, | 185 this.waitForMessage_(hotword.constants.TimeoutMs.NORMAL, |
| 178 hotword.constants.NaClPlugin.STOPPED); | 186 hotword.constants.NaClPlugin.STOPPED); |
| 179 }; | 187 }; |
| 180 | 188 |
| 181 /** | 189 /** |
| 182 * Checks whether the file at the given path exists. | 190 * Checks whether the file at the given path exists. |
| 183 * @param {!string} path Path to a file. Can be any valid URL. | 191 * @param {!string} path Path to a file. Can be any valid URL. |
| 184 * @return {boolean} True if the patch exists. | 192 * @return {boolean} True if the patch exists. |
| (...skipping 318 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 503 break; | 511 break; |
| 504 } | 512 } |
| 505 } | 513 } |
| 506 }; | 514 }; |
| 507 | 515 |
| 508 return { | 516 return { |
| 509 NaClManager: NaClManager | 517 NaClManager: NaClManager |
| 510 }; | 518 }; |
| 511 | 519 |
| 512 }); | 520 }); |
| OLD | NEW |