| 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 <sapi.h> | 6 #include <sapi.h> |
| 7 #include <sphelper.h> | 7 #include <sphelper.h> |
| 8 #include <stdint.h> | 8 #include <stdint.h> |
| 9 | 9 |
| 10 #include "base/macros.h" | 10 #include "base/macros.h" |
| (...skipping 173 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 184 } | 184 } |
| 185 } | 185 } |
| 186 } | 186 } |
| 187 return false; | 187 return false; |
| 188 } | 188 } |
| 189 | 189 |
| 190 void TtsPlatformImplWin::GetVoices( | 190 void TtsPlatformImplWin::GetVoices( |
| 191 std::vector<VoiceData>* out_voices) { | 191 std::vector<VoiceData>* out_voices) { |
| 192 base::win::ScopedComPtr<IEnumSpObjectTokens> voice_tokens; | 192 base::win::ScopedComPtr<IEnumSpObjectTokens> voice_tokens; |
| 193 unsigned long voice_count; | 193 unsigned long voice_count; |
| 194 if (S_OK != SpEnumTokens(SPCAT_VOICES, NULL, NULL, voice_tokens.Receive())) | 194 if (S_OK != |
| 195 SpEnumTokens(SPCAT_VOICES, NULL, NULL, voice_tokens.GetAddressOf())) |
| 195 return; | 196 return; |
| 196 if (S_OK != voice_tokens->GetCount(&voice_count)) | 197 if (S_OK != voice_tokens->GetCount(&voice_count)) |
| 197 return; | 198 return; |
| 198 | 199 |
| 199 for (unsigned i = 0; i < voice_count; i++) { | 200 for (unsigned i = 0; i < voice_count; i++) { |
| 200 VoiceData voice; | 201 VoiceData voice; |
| 201 | 202 |
| 202 base::win::ScopedComPtr<ISpObjectToken> voice_token; | 203 base::win::ScopedComPtr<ISpObjectToken> voice_token; |
| 203 if (S_OK != voice_tokens->Next(1, voice_token.Receive(), NULL)) | 204 if (S_OK != voice_tokens->Next(1, voice_token.GetAddressOf(), NULL)) |
| 204 return; | 205 return; |
| 205 | 206 |
| 206 base::win::ScopedCoMem<WCHAR> description; | 207 base::win::ScopedCoMem<WCHAR> description; |
| 207 if (S_OK != SpGetDescription(voice_token.Get(), &description)) | 208 if (S_OK != SpGetDescription(voice_token.Get(), &description)) |
| 208 continue; | 209 continue; |
| 209 voice.name = base::WideToUTF8(description.get()); | 210 voice.name = base::WideToUTF8(description.get()); |
| 210 | 211 |
| 211 base::win::ScopedComPtr<ISpDataKey> attributes; | 212 base::win::ScopedComPtr<ISpDataKey> attributes; |
| 212 if (S_OK != voice_token->OpenKey(kAttributesKey, attributes.Receive())) | 213 if (S_OK != voice_token->OpenKey(kAttributesKey, attributes.GetAddressOf())) |
| 213 continue; | 214 continue; |
| 214 | 215 |
| 215 base::win::ScopedCoMem<WCHAR> gender; | 216 base::win::ScopedCoMem<WCHAR> gender; |
| 216 if (S_OK == attributes->GetStringValue(kGenderValue, &gender)) { | 217 if (S_OK == attributes->GetStringValue(kGenderValue, &gender)) { |
| 217 if (0 == _wcsicmp(gender.get(), L"male")) | 218 if (0 == _wcsicmp(gender.get(), L"male")) |
| 218 voice.gender = TTS_GENDER_MALE; | 219 voice.gender = TTS_GENDER_MALE; |
| 219 else if (0 == _wcsicmp(gender.get(), L"female")) | 220 else if (0 == _wcsicmp(gender.get(), L"female")) |
| 220 voice.gender = TTS_GENDER_FEMALE; | 221 voice.gender = TTS_GENDER_FEMALE; |
| 221 } | 222 } |
| 222 | 223 |
| (...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 282 } | 283 } |
| 283 | 284 |
| 284 void TtsPlatformImplWin::SetVoiceFromName(const std::string& name) { | 285 void TtsPlatformImplWin::SetVoiceFromName(const std::string& name) { |
| 285 if (name.empty() || name == last_voice_name_) | 286 if (name.empty() || name == last_voice_name_) |
| 286 return; | 287 return; |
| 287 | 288 |
| 288 last_voice_name_ = name; | 289 last_voice_name_ = name; |
| 289 | 290 |
| 290 base::win::ScopedComPtr<IEnumSpObjectTokens> voice_tokens; | 291 base::win::ScopedComPtr<IEnumSpObjectTokens> voice_tokens; |
| 291 unsigned long voice_count; | 292 unsigned long voice_count; |
| 292 if (S_OK != SpEnumTokens(SPCAT_VOICES, NULL, NULL, voice_tokens.Receive())) | 293 if (S_OK != |
| 294 SpEnumTokens(SPCAT_VOICES, NULL, NULL, voice_tokens.GetAddressOf())) |
| 293 return; | 295 return; |
| 294 if (S_OK != voice_tokens->GetCount(&voice_count)) | 296 if (S_OK != voice_tokens->GetCount(&voice_count)) |
| 295 return; | 297 return; |
| 296 | 298 |
| 297 for (unsigned i = 0; i < voice_count; i++) { | 299 for (unsigned i = 0; i < voice_count; i++) { |
| 298 base::win::ScopedComPtr<ISpObjectToken> voice_token; | 300 base::win::ScopedComPtr<ISpObjectToken> voice_token; |
| 299 if (S_OK != voice_tokens->Next(1, voice_token.Receive(), NULL)) | 301 if (S_OK != voice_tokens->Next(1, voice_token.GetAddressOf(), NULL)) |
| 300 return; | 302 return; |
| 301 | 303 |
| 302 base::win::ScopedCoMem<WCHAR> description; | 304 base::win::ScopedCoMem<WCHAR> description; |
| 303 if (S_OK != SpGetDescription(voice_token.Get(), &description)) | 305 if (S_OK != SpGetDescription(voice_token.Get(), &description)) |
| 304 continue; | 306 continue; |
| 305 if (name == base::WideToUTF8(description.get())) { | 307 if (name == base::WideToUTF8(description.get())) { |
| 306 speech_synthesizer_->SetVoice(voice_token.Get()); | 308 speech_synthesizer_->SetVoice(voice_token.Get()); |
| 307 break; | 309 break; |
| 308 } | 310 } |
| 309 } | 311 } |
| (...skipping 23 matching lines...) Expand all Loading... |
| 333 TtsPlatformImplWin* TtsPlatformImplWin::GetInstance() { | 335 TtsPlatformImplWin* TtsPlatformImplWin::GetInstance() { |
| 334 return base::Singleton<TtsPlatformImplWin, | 336 return base::Singleton<TtsPlatformImplWin, |
| 335 base::LeakySingletonTraits<TtsPlatformImplWin>>::get(); | 337 base::LeakySingletonTraits<TtsPlatformImplWin>>::get(); |
| 336 } | 338 } |
| 337 | 339 |
| 338 // static | 340 // static |
| 339 void TtsPlatformImplWin::SpeechEventCallback( | 341 void TtsPlatformImplWin::SpeechEventCallback( |
| 340 WPARAM w_param, LPARAM l_param) { | 342 WPARAM w_param, LPARAM l_param) { |
| 341 GetInstance()->OnSpeechEvent(); | 343 GetInstance()->OnSpeechEvent(); |
| 342 } | 344 } |
| OLD | NEW |