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 #include "chrome/browser/speech/tts_controller_impl.h" | 5 #include "chrome/browser/speech/tts_controller_impl.h" |
6 | 6 |
7 #include <string> | 7 #include <string> |
8 #include <vector> | 8 #include <vector> |
9 | 9 |
10 #include "base/float_util.h" | 10 #include "base/float_util.h" |
(...skipping 120 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
131 // Clear any queued utterances too. | 131 // Clear any queued utterances too. |
132 ClearUtteranceQueue(false); // Don't sent events. | 132 ClearUtteranceQueue(false); // Don't sent events. |
133 } | 133 } |
134 | 134 |
135 void TtsControllerImpl::SpeakOrEnqueue(Utterance* utterance) { | 135 void TtsControllerImpl::SpeakOrEnqueue(Utterance* utterance) { |
136 // If we're paused and we get an utterance that can't be queued, | 136 // If we're paused and we get an utterance that can't be queued, |
137 // flush the queue but stay in the paused state. | 137 // flush the queue but stay in the paused state. |
138 if (paused_ && !utterance->can_enqueue()) { | 138 if (paused_ && !utterance->can_enqueue()) { |
139 Stop(); | 139 Stop(); |
140 paused_ = true; | 140 paused_ = true; |
| 141 delete utterance; |
141 return; | 142 return; |
142 } | 143 } |
143 | 144 |
144 if (paused_ || (IsSpeaking() && utterance->can_enqueue())) { | 145 if (paused_ || (IsSpeaking() && utterance->can_enqueue())) { |
145 utterance_queue_.push(utterance); | 146 utterance_queue_.push(utterance); |
146 } else { | 147 } else { |
147 Stop(); | 148 Stop(); |
148 SpeakNow(utterance); | 149 SpeakNow(utterance); |
149 } | 150 } |
150 } | 151 } |
(...skipping 303 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
454 } | 455 } |
455 | 456 |
456 void TtsControllerImpl::SetTtsEngineDelegate( | 457 void TtsControllerImpl::SetTtsEngineDelegate( |
457 TtsEngineDelegate* delegate) { | 458 TtsEngineDelegate* delegate) { |
458 tts_engine_delegate_ = delegate; | 459 tts_engine_delegate_ = delegate; |
459 } | 460 } |
460 | 461 |
461 TtsEngineDelegate* TtsControllerImpl::GetTtsEngineDelegate() { | 462 TtsEngineDelegate* TtsControllerImpl::GetTtsEngineDelegate() { |
462 return tts_engine_delegate_; | 463 return tts_engine_delegate_; |
463 } | 464 } |
OLD | NEW |