Index: chrome/browser/speech/tts_win.cc |
diff --git a/chrome/browser/speech/tts_win.cc b/chrome/browser/speech/tts_win.cc |
index 06a16f599d75141a77504ebbb6a1b94741065339..bfa28743165922a524b03ccb4c98f1eb0717e572 100644 |
--- a/chrome/browser/speech/tts_win.cc |
+++ b/chrome/browser/speech/tts_win.cc |
@@ -28,6 +28,10 @@ class TtsPlatformImplWin : public TtsPlatformImpl { |
virtual bool StopSpeaking(); |
+ virtual void Pause(); |
+ |
+ virtual void Resume(); |
+ |
virtual bool IsSpeaking(); |
virtual void GetVoices(std::vector<VoiceData>* out_voices) OVERRIDE; |
@@ -51,6 +55,7 @@ class TtsPlatformImplWin : public TtsPlatformImpl { |
int prefix_len_; |
ULONG stream_number_; |
int char_position_; |
+ bool paused_; |
friend struct DefaultSingletonTraits<TtsPlatformImplWin>; |
@@ -125,10 +130,32 @@ bool TtsPlatformImplWin::StopSpeaking() { |
// Stop speech by speaking the empty string with the purge flag. |
speech_synthesizer_->Speak(L"", SPF_ASYNC | SPF_PURGEBEFORESPEAK, NULL); |
} |
+ if (paused_) { |
+ speech_synthesizer_->Resume(); |
+ paused_ = false; |
+ } |
} |
return true; |
} |
+void TtsPlatformImplWin::Pause() { |
+ if (speech_synthesizer_.get() && utterance_id_ && !paused_) { |
+ speech_synthesizer_->Pause(); |
+ paused_ = true; |
+ TtsController::GetInstance()->OnTtsEvent( |
+ utterance_id_, TTS_EVENT_PAUSE, char_position_, ""); |
+ } |
+} |
+ |
+void TtsPlatformImplWin::Resume() { |
+ if (speech_synthesizer_.get() && utterance_id_ && paused_) { |
+ speech_synthesizer_->Resume(); |
+ paused_ = false; |
+ TtsController::GetInstance()->OnTtsEvent( |
+ utterance_id_, TTS_EVENT_RESUME, char_position_, ""); |
+ } |
+} |
+ |
bool TtsPlatformImplWin::IsSpeaking() { |
if (speech_synthesizer_.get()) { |
SPVOICESTATUS status; |
@@ -156,6 +183,8 @@ void TtsPlatformImplWin::GetVoices( |
voice.events.insert(TTS_EVENT_MARKER); |
voice.events.insert(TTS_EVENT_WORD); |
voice.events.insert(TTS_EVENT_SENTENCE); |
+ voice.events.insert(TTS_EVENT_PAUSE); |
+ voice.events.insert(TTS_EVENT_RESUME); |
} |
void TtsPlatformImplWin::OnSpeechEvent() { |
@@ -199,7 +228,8 @@ TtsPlatformImplWin::TtsPlatformImplWin() |
: utterance_id_(0), |
prefix_len_(0), |
stream_number_(0), |
- char_position_(0) { |
+ char_position_(0), |
+ paused_(false) { |
speech_synthesizer_.CreateInstance(CLSID_SpVoice); |
if (speech_synthesizer_.get()) { |
ULONGLONG event_mask = |