diff options
author | primiano@chromium.org <primiano@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2012-03-29 10:54:31 +0000 |
---|---|---|
committer | primiano@chromium.org <primiano@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2012-03-29 10:54:31 +0000 |
commit | 2a8c471f6fbeb867cd5187e7149288591de571b2 (patch) | |
tree | 4b6abe7e121fa2dab2e9357aa2fa260fa419da98 /content | |
parent | c28fb310f9737fb901e5638ec3ec04626b7777e2 (diff) | |
download | chromium_src-2a8c471f6fbeb867cd5187e7149288591de571b2.zip chromium_src-2a8c471f6fbeb867cd5187e7149288591de571b2.tar.gz chromium_src-2a8c471f6fbeb867cd5187e7149288591de571b2.tar.bz2 |
Fixed a regression on speech arisen after r129173 .
Made OnAudioClosed a member of SpeechRecognizerImpl. In this way, the closure used in the call to audio_controller_->Close() will hold a reference on SpeechRecognizerImpl until the Close has finished. Without this, the OnData method might be called from the audio thread after the object has been destructed.
BUG=120173
TEST=none.
Review URL: https://chromiumcodereview.appspot.com/9791070
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@129606 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'content')
-rw-r--r-- | content/browser/speech/speech_recognizer_impl.cc | 6 | ||||
-rw-r--r-- | content/browser/speech/speech_recognizer_impl.h | 2 |
2 files changed, 6 insertions, 2 deletions
diff --git a/content/browser/speech/speech_recognizer_impl.cc b/content/browser/speech/speech_recognizer_impl.cc index 3c15e2e..05f81e7 100644 --- a/content/browser/speech/speech_recognizer_impl.cc +++ b/content/browser/speech/speech_recognizer_impl.cc @@ -57,7 +57,6 @@ bool DetectClipping(const speech::AudioChunk& chunk) { return false; } -void OnAudioClosed(AudioInputController*) {} } // namespace SpeechRecognizer* SpeechRecognizer::Create( @@ -302,6 +301,8 @@ void SpeechRecognizerImpl::HandleOnData(scoped_refptr<AudioChunk> raw_audio) { StopAudioCapture(); } +void SpeechRecognizerImpl::OnAudioClosed(AudioInputController*) {} + void SpeechRecognizerImpl::OnSpeechRecognitionEngineResult( const content::SpeechRecognitionResult& result) { // Guard against the listener freeing us until we finish our job. @@ -331,7 +332,8 @@ void SpeechRecognizerImpl::CloseAudioControllerAsynchronously() { // 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_->Close(base::Bind(&SpeechRecognizerImpl::OnAudioClosed, + this, audio_controller_)); audio_controller_ = NULL; // The controller is still refcounted by Bind. } diff --git a/content/browser/speech/speech_recognizer_impl.h b/content/browser/speech/speech_recognizer_impl.h index 8e9adcc..eed04bc 100644 --- a/content/browser/speech/speech_recognizer_impl.h +++ b/content/browser/speech/speech_recognizer_impl.h @@ -85,6 +85,8 @@ class CONTENT_EXPORT SpeechRecognizerImpl // Handles OnData in the IO thread. void HandleOnData(scoped_refptr<AudioChunk> raw_audio); + void OnAudioClosed(media::AudioInputController*); + // Helper method which closes the audio controller and frees it asynchronously // without blocking the IO thread. void CloseAudioControllerAsynchronously(); |