Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1626)

Unified Diff: chrome/browser/extensions/extension_tts_api_win.cc

Issue 7792015: An improved fix for TTS Extension API problems on Windows. (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: Created 9 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/browser/extensions/extension_tts_api_win.cc
===================================================================
--- chrome/browser/extensions/extension_tts_api_win.cc (revision 98609)
+++ chrome/browser/extensions/extension_tts_api_win.cc (working copy)
@@ -43,7 +43,6 @@
void OnSpeechEvent();
base::win::ScopedComPtr<ISpVoice> speech_synthesizer_;
- bool paused_;
// These apply to the current utterance only.
std::wstring utterance_;
@@ -99,11 +98,6 @@
speech_synthesizer_->SetVolume(static_cast<uint16>(params.volume * 100));
}
- if (paused_) {
- speech_synthesizer_->Resume();
- paused_ = false;
- }
-
// TODO(dmazzoni): convert SSML to SAPI xml. http://crbug.com/88072
utterance_ = UTF8ToWide(src_utterance);
@@ -112,7 +106,6 @@
std::wstring merged_utterance = prefix + utterance_ + suffix;
prefix_len_ = prefix.size();
-
HRESULT result = speech_synthesizer_->Speak(
merged_utterance.c_str(),
SPF_ASYNC,
@@ -121,19 +114,21 @@
}
bool ExtensionTtsPlatformImplWin::StopSpeaking() {
- if (speech_synthesizer_ && !paused_) {
+ if (speech_synthesizer_) {
// Clear the stream number so that any further events relating to this
// utterance are ignored.
stream_number_ = 0;
- speech_synthesizer_->Pause();
- paused_ = true;
+ if (IsSpeaking()) {
+ // Stop speech by speaking the empty string with the purge flag.
+ speech_synthesizer_->Speak(L"", SPF_ASYNC | SPF_PURGEBEFORESPEAK, NULL);
+ }
}
return true;
}
bool ExtensionTtsPlatformImplWin::IsSpeaking() {
- if (speech_synthesizer_ && !paused_) {
+ if (speech_synthesizer_) {
SPVOICESTATUS status;
HRESULT result = speech_synthesizer_->GetStatus(&status, NULL);
if (result == S_OK) {
@@ -192,8 +187,7 @@
}
ExtensionTtsPlatformImplWin::ExtensionTtsPlatformImplWin()
- : speech_synthesizer_(NULL),
- paused_(false) {
+ : speech_synthesizer_(NULL) {
CoCreateInstance(
CLSID_SpVoice,
NULL,
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698