OLD | NEW |
1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2010 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/extensions/extension_tts_api.h" | 5 #include "chrome/browser/extensions/extension_tts_api.h" |
6 | 6 |
7 #include <atlbase.h> | 7 #include <atlbase.h> |
8 #include <atlcom.h> | 8 #include <atlcom.h> |
9 #include <sapi.h> | 9 #include <sapi.h> |
10 | 10 |
(...skipping 76 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
87 | 87 |
88 if (paused_) | 88 if (paused_) |
89 speech_synthesizer_->Resume(); | 89 speech_synthesizer_->Resume(); |
90 speech_synthesizer_->Speak( | 90 speech_synthesizer_->Speak( |
91 utterance.c_str(), SPF_ASYNC | SPF_PURGEBEFORESPEAK, NULL); | 91 utterance.c_str(), SPF_ASYNC | SPF_PURGEBEFORESPEAK, NULL); |
92 | 92 |
93 return true; | 93 return true; |
94 } | 94 } |
95 | 95 |
96 bool ExtensionTtsPlatformImplWin::StopSpeaking() { | 96 bool ExtensionTtsPlatformImplWin::StopSpeaking() { |
97 if (!speech_synthesizer_ && !paused_) { | 97 if (speech_synthesizer_ && !paused_) { |
98 speech_synthesizer_->Pause(); | 98 speech_synthesizer_->Pause(); |
99 paused_ = true; | 99 paused_ = true; |
100 } | 100 } |
101 return true; | 101 return true; |
102 } | 102 } |
103 | 103 |
104 bool ExtensionTtsPlatformImplWin::IsSpeaking() { | 104 bool ExtensionTtsPlatformImplWin::IsSpeaking() { |
| 105 if (speech_synthesizer_ && !paused_) { |
| 106 SPVOICESTATUS status; |
| 107 HRESULT result = speech_synthesizer_->GetStatus(&status, NULL); |
| 108 if (result == S_OK && status.dwRunningState == SPRS_IS_SPEAKING) |
| 109 return true; |
| 110 } |
105 return false; | 111 return false; |
106 } | 112 } |
107 | 113 |
108 ExtensionTtsPlatformImplWin::ExtensionTtsPlatformImplWin() | 114 ExtensionTtsPlatformImplWin::ExtensionTtsPlatformImplWin() |
109 : speech_synthesizer_(NULL), | 115 : speech_synthesizer_(NULL), |
110 paused_(false) { | 116 paused_(false) { |
111 CoCreateInstance( | 117 CoCreateInstance( |
112 CLSID_SpVoice, | 118 CLSID_SpVoice, |
113 NULL, | 119 NULL, |
114 CLSCTX_SERVER, | 120 CLSCTX_SERVER, |
115 IID_ISpVoice, | 121 IID_ISpVoice, |
116 reinterpret_cast<void**>(&speech_synthesizer_)); | 122 reinterpret_cast<void**>(&speech_synthesizer_)); |
117 } | 123 } |
118 | 124 |
119 // static | 125 // static |
120 ExtensionTtsPlatformImplWin* ExtensionTtsPlatformImplWin::GetInstance() { | 126 ExtensionTtsPlatformImplWin* ExtensionTtsPlatformImplWin::GetInstance() { |
121 return Singleton<ExtensionTtsPlatformImplWin>::get(); | 127 return Singleton<ExtensionTtsPlatformImplWin>::get(); |
122 } | 128 } |
OLD | NEW |