| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 "content/browser/speech/speech_recognizer.h" | 5 #include "content/browser/speech/speech_recognizer.h" |
| 6 | 6 |
| 7 #include "base/basictypes.h" | 7 #include "base/basictypes.h" |
| 8 #include "base/bind.h" | 8 #include "base/bind.h" |
| 9 #include "base/time.h" | 9 #include "base/time.h" |
| 10 #include "content/browser/browser_main_loop.h" | 10 #include "content/browser/browser_main_loop.h" |
| (...skipping 144 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 155 | 155 |
| 156 SpeechRecognizer::~SpeechRecognizer() { | 156 SpeechRecognizer::~SpeechRecognizer() { |
| 157 endpointer_.EndSession(); | 157 endpointer_.EndSession(); |
| 158 if (audio_controller_.get()) { | 158 if (audio_controller_.get()) { |
| 159 audio_controller_->Close(base::Bind(&KeepAudioControllerRefcountedForDtor, | 159 audio_controller_->Close(base::Bind(&KeepAudioControllerRefcountedForDtor, |
| 160 audio_controller_)); | 160 audio_controller_)); |
| 161 } | 161 } |
| 162 } | 162 } |
| 163 | 163 |
| 164 // Invoked in the audio thread. | 164 // Invoked in the audio thread. |
| 165 void SpeechRecognizer::OnError(AudioInputController* controller, | 165 void SpeechRecognizer::OnError(AudioInputController* controller) { |
| 166 int error_code) { | |
| 167 FSMEventArgs event_args(EVENT_AUDIO_ERROR); | 166 FSMEventArgs event_args(EVENT_AUDIO_ERROR); |
| 168 event_args.audio_error_code = error_code; | |
| 169 BrowserThread::PostTask(BrowserThread::IO, FROM_HERE, | 167 BrowserThread::PostTask(BrowserThread::IO, FROM_HERE, |
| 170 base::Bind(&SpeechRecognizer::DispatchEvent, | 168 base::Bind(&SpeechRecognizer::DispatchEvent, |
| 171 this, event_args)); | 169 this, event_args)); |
| 172 } | 170 } |
| 173 | 171 |
| 174 void SpeechRecognizer::OnData(AudioInputController* controller, | 172 void SpeechRecognizer::OnData(AudioInputController* controller, |
| 175 const uint8* data, uint32 size) { | 173 const uint8* data, uint32 size) { |
| 176 if (size == 0) // This could happen when audio capture stops and is normal. | 174 if (size == 0) // This could happen when audio capture stops and is normal. |
| 177 return; | 175 return; |
| 178 | 176 |
| (...skipping 472 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 651 session_id_, clip_detected ? 1.0f : audio_level_, noise_level); | 649 session_id_, clip_detected ? 1.0f : audio_level_, noise_level); |
| 652 } | 650 } |
| 653 | 651 |
| 654 void SpeechRecognizer::SetAudioManagerForTests( | 652 void SpeechRecognizer::SetAudioManagerForTests( |
| 655 AudioManager* audio_manager) { | 653 AudioManager* audio_manager) { |
| 656 audio_manager_for_tests_ = audio_manager; | 654 audio_manager_for_tests_ = audio_manager; |
| 657 } | 655 } |
| 658 | 656 |
| 659 SpeechRecognizer::FSMEventArgs::FSMEventArgs(FSMEvent event_value) | 657 SpeechRecognizer::FSMEventArgs::FSMEventArgs(FSMEvent event_value) |
| 660 : event(event_value), | 658 : event(event_value), |
| 661 audio_error_code(0), | |
| 662 audio_data(NULL), | 659 audio_data(NULL), |
| 663 engine_error(SPEECH_RECOGNITION_ERROR_NONE) { | 660 engine_error(SPEECH_RECOGNITION_ERROR_NONE) { |
| 664 } | 661 } |
| 665 | 662 |
| 666 SpeechRecognizer::FSMEventArgs::~FSMEventArgs() { | 663 SpeechRecognizer::FSMEventArgs::~FSMEventArgs() { |
| 667 } | 664 } |
| 668 | 665 |
| 669 } // namespace content | 666 } // namespace content |
| OLD | NEW |