OLD | NEW |
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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 <math.h> | 5 #include <math.h> |
6 #include <sapi.h> | 6 #include <sapi.h> |
7 | 7 |
8 #include "base/memory/singleton.h" | 8 #include "base/memory/singleton.h" |
9 #include "base/string_number_conversions.h" | 9 #include "base/string_number_conversions.h" |
10 #include "base/utf_string_conversions.h" | 10 #include "base/utf_string_conversions.h" |
(...skipping 169 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
180 char_position_ = static_cast<ULONG>(event.lParam) - prefix_len_; | 180 char_position_ = static_cast<ULONG>(event.lParam) - prefix_len_; |
181 controller->OnTtsEvent( | 181 controller->OnTtsEvent( |
182 utterance_id_, TTS_EVENT_SENTENCE, char_position_, | 182 utterance_id_, TTS_EVENT_SENTENCE, char_position_, |
183 std::string()); | 183 std::string()); |
184 break; | 184 break; |
185 } | 185 } |
186 } | 186 } |
187 } | 187 } |
188 | 188 |
189 ExtensionTtsPlatformImplWin::ExtensionTtsPlatformImplWin() | 189 ExtensionTtsPlatformImplWin::ExtensionTtsPlatformImplWin() |
190 : speech_synthesizer_(NULL) { | 190 : speech_synthesizer_(NULL), |
| 191 utterance_id_(0), |
| 192 prefix_len_(0), |
| 193 stream_number_(0), |
| 194 char_position_(0) { |
191 CoCreateInstance( | 195 CoCreateInstance( |
192 CLSID_SpVoice, | 196 CLSID_SpVoice, |
193 NULL, | 197 NULL, |
194 CLSCTX_SERVER, | 198 CLSCTX_SERVER, |
195 IID_ISpVoice, | 199 IID_ISpVoice, |
196 reinterpret_cast<void**>(&speech_synthesizer_)); | 200 reinterpret_cast<void**>(&speech_synthesizer_)); |
197 if (speech_synthesizer_) { | 201 if (speech_synthesizer_) { |
198 ULONGLONG event_mask = | 202 ULONGLONG event_mask = |
199 SPFEI(SPEI_START_INPUT_STREAM) | | 203 SPFEI(SPEI_START_INPUT_STREAM) | |
200 SPFEI(SPEI_TTS_BOOKMARK) | | 204 SPFEI(SPEI_TTS_BOOKMARK) | |
201 SPFEI(SPEI_WORD_BOUNDARY) | | 205 SPFEI(SPEI_WORD_BOUNDARY) | |
202 SPFEI(SPEI_SENTENCE_BOUNDARY) | | 206 SPFEI(SPEI_SENTENCE_BOUNDARY) | |
203 SPFEI(SPEI_END_INPUT_STREAM); | 207 SPFEI(SPEI_END_INPUT_STREAM); |
204 speech_synthesizer_->SetInterest(event_mask, event_mask); | 208 speech_synthesizer_->SetInterest(event_mask, event_mask); |
205 speech_synthesizer_->SetNotifyCallbackFunction( | 209 speech_synthesizer_->SetNotifyCallbackFunction( |
206 ExtensionTtsPlatformImplWin::SpeechEventCallback, 0, 0); | 210 ExtensionTtsPlatformImplWin::SpeechEventCallback, 0, 0); |
207 } | 211 } |
208 } | 212 } |
209 | 213 |
210 // static | 214 // static |
211 ExtensionTtsPlatformImplWin* ExtensionTtsPlatformImplWin::GetInstance() { | 215 ExtensionTtsPlatformImplWin* ExtensionTtsPlatformImplWin::GetInstance() { |
212 return Singleton<ExtensionTtsPlatformImplWin>::get(); | 216 return Singleton<ExtensionTtsPlatformImplWin>::get(); |
213 } | 217 } |
214 | 218 |
215 // static | 219 // static |
216 void ExtensionTtsPlatformImplWin::SpeechEventCallback( | 220 void ExtensionTtsPlatformImplWin::SpeechEventCallback( |
217 WPARAM w_param, LPARAM l_param) { | 221 WPARAM w_param, LPARAM l_param) { |
218 GetInstance()->OnSpeechEvent(); | 222 GetInstance()->OnSpeechEvent(); |
219 } | 223 } |
OLD | NEW |