| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 <objbase.h> |
| 6 #include <sapi.h> | 7 #include <sapi.h> |
| 7 #include <sphelper.h> | 8 #include <sphelper.h> |
| 8 #include <stdint.h> | 9 #include <stdint.h> |
| 9 | 10 |
| 10 #include "base/macros.h" | 11 #include "base/macros.h" |
| 11 #include "base/memory/singleton.h" | 12 #include "base/memory/singleton.h" |
| 12 #include "base/strings/string_number_conversions.h" | 13 #include "base/strings/string_number_conversions.h" |
| 13 #include "base/strings/string_piece.h" | 14 #include "base/strings/string_piece.h" |
| 14 #include "base/strings/utf_string_conversions.h" | 15 #include "base/strings/utf_string_conversions.h" |
| 15 #include "base/values.h" | 16 #include "base/values.h" |
| (...skipping 294 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 310 } | 311 } |
| 311 } | 312 } |
| 312 } | 313 } |
| 313 | 314 |
| 314 TtsPlatformImplWin::TtsPlatformImplWin() | 315 TtsPlatformImplWin::TtsPlatformImplWin() |
| 315 : utterance_id_(0), | 316 : utterance_id_(0), |
| 316 prefix_len_(0), | 317 prefix_len_(0), |
| 317 stream_number_(0), | 318 stream_number_(0), |
| 318 char_position_(0), | 319 char_position_(0), |
| 319 paused_(false) { | 320 paused_(false) { |
| 320 speech_synthesizer_.CreateInstance(CLSID_SpVoice); | 321 ::CoCreateInstance(CLSID_SpVoice, nullptr, CLSCTX_ALL, |
| 322 IID_PPV_ARGS(&speech_synthesizer_)); |
| 321 if (speech_synthesizer_.Get()) { | 323 if (speech_synthesizer_.Get()) { |
| 322 ULONGLONG event_mask = | 324 ULONGLONG event_mask = |
| 323 SPFEI(SPEI_START_INPUT_STREAM) | | 325 SPFEI(SPEI_START_INPUT_STREAM) | |
| 324 SPFEI(SPEI_TTS_BOOKMARK) | | 326 SPFEI(SPEI_TTS_BOOKMARK) | |
| 325 SPFEI(SPEI_WORD_BOUNDARY) | | 327 SPFEI(SPEI_WORD_BOUNDARY) | |
| 326 SPFEI(SPEI_SENTENCE_BOUNDARY) | | 328 SPFEI(SPEI_SENTENCE_BOUNDARY) | |
| 327 SPFEI(SPEI_END_INPUT_STREAM); | 329 SPFEI(SPEI_END_INPUT_STREAM); |
| 328 speech_synthesizer_->SetInterest(event_mask, event_mask); | 330 speech_synthesizer_->SetInterest(event_mask, event_mask); |
| 329 speech_synthesizer_->SetNotifyCallbackFunction( | 331 speech_synthesizer_->SetNotifyCallbackFunction( |
| 330 TtsPlatformImplWin::SpeechEventCallback, 0, 0); | 332 TtsPlatformImplWin::SpeechEventCallback, 0, 0); |
| 331 } | 333 } |
| 332 } | 334 } |
| 333 | 335 |
| 334 // static | 336 // static |
| 335 TtsPlatformImplWin* TtsPlatformImplWin::GetInstance() { | 337 TtsPlatformImplWin* TtsPlatformImplWin::GetInstance() { |
| 336 return base::Singleton<TtsPlatformImplWin, | 338 return base::Singleton<TtsPlatformImplWin, |
| 337 base::LeakySingletonTraits<TtsPlatformImplWin>>::get(); | 339 base::LeakySingletonTraits<TtsPlatformImplWin>>::get(); |
| 338 } | 340 } |
| 339 | 341 |
| 340 // static | 342 // static |
| 341 void TtsPlatformImplWin::SpeechEventCallback( | 343 void TtsPlatformImplWin::SpeechEventCallback( |
| 342 WPARAM w_param, LPARAM l_param) { | 344 WPARAM w_param, LPARAM l_param) { |
| 343 GetInstance()->OnSpeechEvent(); | 345 GetInstance()->OnSpeechEvent(); |
| 344 } | 346 } |
| OLD | NEW |