Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(12)

Side by Side Diff: chrome/browser/resources/hotword/state_manager.js

Issue 940833002: With always-on enabled, always shut down the hotword detector after a trigger. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 * Trivial container class for session information. 9 * Trivial container class for session information.
10 * @param {!hotword.constants.SessionSource} source Source of the hotword 10 * @param {!hotword.constants.SessionSource} source Source of the hotword
(...skipping 198 matching lines...) Expand 10 before | Expand all | Expand 10 after
209 // possible for both to be set. In that case, always-on takes precedence. 209 // possible for both to be set. In that case, always-on takes precedence.
210 return this.hotwordStatus_.enabled && 210 return this.hotwordStatus_.enabled &&
211 !this.hotwordStatus_.alwaysOnEnabled; 211 !this.hotwordStatus_.alwaysOnEnabled;
212 }, 212 },
213 213
214 /** 214 /**
215 * @return {boolean} True if always-on hotwording is enabled. 215 * @return {boolean} True if always-on hotwording is enabled.
216 */ 216 */
217 isAlwaysOnEnabled: function() { 217 isAlwaysOnEnabled: function() {
218 assert(this.hotwordStatus_, 'No hotword status (isAlwaysOnEnabled)'); 218 assert(this.hotwordStatus_, 'No hotword status (isAlwaysOnEnabled)');
219 return this.hotwordStatus_.alwaysOnEnabled; 219 return this.hotwordStatus_.alwaysOnEnabled &&
220 !this.hotwordStatus_.trainingEnabled;
220 }, 221 },
221 222
222 /** 223 /**
223 * @return {boolean} True if training is enabled. 224 * @return {boolean} True if training is enabled.
224 */ 225 */
225 isTrainingEnabled: function() { 226 isTrainingEnabled: function() {
226 assert(this.hotwordStatus_, 'No hotword status (isTrainingEnabled)'); 227 assert(this.hotwordStatus_, 'No hotword status (isTrainingEnabled)');
227 return this.hotwordStatus_.trainingEnabled; 228 return this.hotwordStatus_.trainingEnabled;
228 }, 229 },
229 230
(...skipping 248 matching lines...) Expand 10 before | Expand all | Expand 10 after
478 // order to restart the detector. 479 // order to restart the detector.
479 if (this.sessions_.length) { 480 if (this.sessions_.length) {
480 var session = this.sessions_.pop(); 481 var session = this.sessions_.pop();
481 session.triggerCb_(event.log); 482 session.triggerCb_(event.log);
482 483
483 hotword.metrics.recordEnum( 484 hotword.metrics.recordEnum(
484 hotword.constants.UmaMetrics.TRIGGER_SOURCE, 485 hotword.constants.UmaMetrics.TRIGGER_SOURCE,
485 UmaTriggerSources_[session.source_], 486 UmaTriggerSources_[session.source_],
486 hotword.constants.UmaTriggerSource.MAX); 487 hotword.constants.UmaTriggerSource.MAX);
487 } 488 }
489
490 // If we're in always-on mode, shut down the hotword detector. The hotword
491 // stream requires that we close and re-open it after a trigger, and the
492 // only way to accomplish this is to shut everything down.
493 if (this.isAlwaysOnEnabled())
494 this.shutdownDetector_();
488 }, 495 },
489 496
490 /** 497 /**
491 * Handle speaker model saved. 498 * Handle speaker model saved.
492 * @private 499 * @private
493 */ 500 */
494 onSpeakerModelSaved_: function() { 501 onSpeakerModelSaved_: function() {
495 hotword.debug('Speaker model saved!'); 502 hotword.debug('Speaker model saved!');
496 503
497 if (this.sessions_.length) { 504 if (this.sessions_.length) {
(...skipping 75 matching lines...) Expand 10 before | Expand all | Expand 10 after
573 580
574 if (oldLocked != this.isLocked_) 581 if (oldLocked != this.isLocked_)
575 this.updateStateFromStatus_(); 582 this.updateStateFromStatus_();
576 } 583 }
577 }; 584 };
578 585
579 return { 586 return {
580 StateManager: StateManager 587 StateManager: StateManager
581 }; 588 };
582 }); 589 });
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698