Index: content/browser/speech/speech_recognition_manager_impl.cc |
diff --git a/content/browser/speech/speech_recognition_manager_impl.cc b/content/browser/speech/speech_recognition_manager_impl.cc |
index 46e26137ee4944c34917cb889c13448de5b2cca8..ec267b71245f695c919535b4218c9ef0b0aeb0f3 100644 |
--- a/content/browser/speech/speech_recognition_manager_impl.cc |
+++ b/content/browser/speech/speech_recognition_manager_impl.cc |
@@ -203,24 +203,11 @@ void SpeechRecognitionManagerImpl::StartRecognitionForRequest(int caller_id) { |
// If we are currently recording audio for another caller, abort that cleanly. |
if (recording_caller_id_) |
CancelRecognitionAndInformDelegate(recording_caller_id_); |
- |
- if (!HasAudioInputDevices()) { |
- if (delegate_) { |
- delegate_->ShowMicError(caller_id, |
- SpeechRecognitionManagerDelegate::MIC_ERROR_NO_DEVICE_AVAILABLE); |
- } |
- } else if (IsCapturingAudio()) { |
- if (delegate_) { |
- delegate_->ShowMicError( |
- caller_id, SpeechRecognitionManagerDelegate::MIC_ERROR_DEVICE_IN_USE); |
- } |
- } else { |
- recording_caller_id_ = caller_id; |
- requests_[caller_id].is_active = true; |
- requests_[caller_id].recognizer->StartRecognition(); |
- if (delegate_) |
- delegate_->ShowWarmUp(caller_id); |
- } |
+ recording_caller_id_ = caller_id; |
+ requests_[caller_id].is_active = true; |
+ requests_[caller_id].recognizer->StartRecognition(); |
Satish
2012/03/21 13:29:48
I see the checks present here before have now move
Primiano Tucci (use gerrit)
2012/03/22 11:20:41
Yes. Errors are not propagated to the dispatcher.
|
+ if (delegate_) |
+ delegate_->ShowWarmUp(caller_id); |
} |
void SpeechRecognitionManagerImpl::CancelRecognitionForRequest(int caller_id) { |
@@ -284,12 +271,17 @@ void SpeechRecognitionManagerImpl::StopRecording(int caller_id) { |
void SpeechRecognitionManagerImpl::OnRecognitionResult( |
int caller_id, const content::SpeechRecognitionResult& result) { |
DCHECK(HasPendingRequest(caller_id)); |
+ DCHECK(result.error == content::SPEECH_RECOGNITION_ERROR_NONE); |
GetDelegate(caller_id)->SetRecognitionResult(caller_id, result); |
} |
void SpeechRecognitionManagerImpl::OnAudioEnd(int caller_id) { |
+ if (recording_caller_id_ != caller_id) |
Satish
2012/03/21 13:29:48
this check shouldn't be here as we have a DCHECK f
Primiano Tucci (use gerrit)
2012/03/22 11:20:41
Basically this checks were introduced because the
|
+ return; |
DCHECK_EQ(recording_caller_id_, caller_id); |
DCHECK(HasPendingRequest(caller_id)); |
+ if (!requests_[caller_id].is_active) |
Satish
2012/03/21 13:29:48
any reason why this check was added? seems like an
Primiano Tucci (use gerrit)
2012/03/22 11:20:41
Same as above. We could receive an AudioEnd of a r
|
+ return; |
recording_caller_id_ = 0; |
GetDelegate(caller_id)->DidCompleteRecording(caller_id); |
if (delegate_) |
@@ -297,6 +289,8 @@ void SpeechRecognitionManagerImpl::OnAudioEnd(int caller_id) { |
} |
void SpeechRecognitionManagerImpl::OnRecognitionEnd(int caller_id) { |
+ if (!HasPendingRequest(caller_id) || !requests_[caller_id].is_active) |
Satish
2012/03/21 13:29:48
ditto, could be a DCHECK if you really want to che
Primiano Tucci (use gerrit)
2012/03/22 11:20:41
Same as above.
|
+ return; |
GetDelegate(caller_id)->DidCompleteRecognition(caller_id); |
requests_.erase(caller_id); |
if (delegate_) |
@@ -310,12 +304,24 @@ void SpeechRecognitionManagerImpl::OnSoundEnd(int caller_id) { |
} |
void SpeechRecognitionManagerImpl::OnRecognitionError( |
- int caller_id, const content::SpeechRecognitionErrorCode& error) { |
+ int caller_id, const content::SpeechRecognitionError& error) { |
+ DCHECK(HasPendingRequest(caller_id)); |
if (caller_id == recording_caller_id_) |
recording_caller_id_ = 0; |
requests_[caller_id].is_active = false; |
- if (delegate_) |
- delegate_->ShowRecognizerError(caller_id, error); |
+ if (delegate_) { |
+ if (error.code == content::SPEECH_RECOGNITION_ERROR_AUDIO && |
+ error.details == content::AUDIO_ERROR_NO_MIC) { |
+ delegate_->ShowMicError(caller_id, |
+ SpeechRecognitionManagerDelegate::MIC_ERROR_NO_DEVICE_AVAILABLE); |
+ } else if (error.code == content::SPEECH_RECOGNITION_ERROR_AUDIO && |
+ error.details == content::AUDIO_ERROR_MIC_IN_USE) { |
+ delegate_->ShowMicError( |
+ caller_id, SpeechRecognitionManagerDelegate::MIC_ERROR_DEVICE_IN_USE); |
+ } else { |
+ delegate_->ShowRecognizerError(caller_id, error.code); |
+ } |
+ } |
} |
void SpeechRecognitionManagerImpl::OnAudioStart(int caller_id) { |