diff options
author | primiano@chromium.org <primiano@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2012-03-27 14:01:12 +0000 |
---|---|---|
committer | primiano@chromium.org <primiano@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2012-03-27 14:01:12 +0000 |
commit | 3652800bfca27dd1817b2175abecec91572895b4 (patch) | |
tree | abdb3a263db26df357e3368fff2a2a968b0dd72f /content/browser/speech/speech_recognizer_impl.cc | |
parent | 013f614070bab1555df4b789040b2f534630fd48 (diff) | |
download | chromium_src-3652800bfca27dd1817b2175abecec91572895b4.zip chromium_src-3652800bfca27dd1817b2175abecec91572895b4.tar.gz chromium_src-3652800bfca27dd1817b2175abecec91572895b4.tar.bz2 |
Fixed a regression on speech input caused by issue 9858007 (r128895) that caused renderer hang on speech input complete / abort.
BUG=120173
TEST=Speech input must not freeze the page upon abort/completion.
Review URL: http://codereview.chromium.org/9856021
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@129173 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'content/browser/speech/speech_recognizer_impl.cc')
-rw-r--r-- | content/browser/speech/speech_recognizer_impl.cc | 22 |
1 files changed, 10 insertions, 12 deletions
diff --git a/content/browser/speech/speech_recognizer_impl.cc b/content/browser/speech/speech_recognizer_impl.cc index 007f3ee..2e8cc48 100644 --- a/content/browser/speech/speech_recognizer_impl.cc +++ b/content/browser/speech/speech_recognizer_impl.cc @@ -57,6 +57,7 @@ bool DetectClipping(const speech::AudioChunk& chunk) { return false; } +void OnAudioClosed(AudioInputController*) {} } // namespace SpeechRecognizer* SpeechRecognizer::Create( @@ -157,7 +158,7 @@ void SpeechRecognizerImpl::AbortRecognition() { // Stop recording if required. if (audio_controller_.get()) { - CloseAudioControllerSynchronously(); + CloseAudioControllerAsynchronously(); } VLOG(1) << "SpeechRecognizer canceling recognition."; @@ -172,7 +173,7 @@ void SpeechRecognizerImpl::StopAudioCapture() { if (!audio_controller_.get()) return; - CloseAudioControllerSynchronously(); + CloseAudioControllerAsynchronously(); listener_->OnSoundEnd(caller_id_); listener_->OnAudioEnd(caller_id_); @@ -323,17 +324,14 @@ void SpeechRecognizerImpl::InformErrorAndAbortRecognition( listener_->OnRecognitionError(caller_id_, error); } -void SpeechRecognizerImpl::CloseAudioControllerSynchronously() { +void SpeechRecognizerImpl::CloseAudioControllerAsynchronously() { VLOG(1) << "SpeechRecognizer stopping record."; - - // TODO(satish): investigate the possibility to utilize the closure - // and switch to async. version of this method. Compare with how - // it's done in e.g. the AudioRendererHost. - base::WaitableEvent closed_event(true, false); - audio_controller_->Close(base::Bind(&base::WaitableEvent::Signal, - base::Unretained(&closed_event))); - closed_event.Wait(); - audio_controller_ = NULL; // Releases the ref ptr. + // Issues a Close on the audio controller, passing an empty callback. The only + // purpose of such callback is to keep the audio controller refcounted until + // Close has completed (in the audio thread) and automatically destroy it + // afterwards (upon return from OnAudioClosed). + audio_controller_->Close(base::Bind(&OnAudioClosed, audio_controller_)); + audio_controller_ = NULL; // The controller is still refcounted by Bind. } bool SpeechRecognizerImpl::IsActive() const { |