Index: content/browser/speech/speech_recognizer_impl.h |
diff --git a/content/browser/speech/speech_recognizer_impl.h b/content/browser/speech/speech_recognizer_impl.h |
index 7f6d7789a51619bd8d995f7206139f345977ea45..d14cdf407158794a35ae3dd9b634c14044db75ac 100644 |
--- a/content/browser/speech/speech_recognizer_impl.h |
+++ b/content/browser/speech/speech_recognizer_impl.h |
@@ -9,6 +9,7 @@ |
#include <string> |
#include "base/macros.h" |
+#include "base/memory/weak_ptr.h" |
#include "content/browser/speech/endpointer/endpointer.h" |
#include "content/browser/speech/speech_recognition_engine.h" |
#include "content/browser/speech/speech_recognizer.h" |
@@ -20,7 +21,7 @@ |
namespace media { |
class AudioBus; |
-class AudioManager; |
+class AudioSystem; |
} |
namespace content { |
@@ -42,9 +43,10 @@ class CONTENT_EXPORT SpeechRecognizerImpl |
static const int kNoSpeechTimeoutMs; |
static const int kEndpointerEstimationTimeMs; |
- static void SetAudioManagerForTesting(media::AudioManager* audio_manager); |
+ static void SetAudioSystemForTesting(media::AudioSystem* audio_system); |
SpeechRecognizerImpl(SpeechRecognitionEventListener* listener, |
+ media::AudioSystem* audio_system, |
int session_id, |
bool continuous, |
bool provisional_results, |
@@ -62,6 +64,7 @@ class CONTENT_EXPORT SpeechRecognizerImpl |
enum FSMState { |
STATE_IDLE = 0, |
+ STATE_PREPARING, |
STATE_STARTING, |
STATE_ESTIMATING_ENVIRONMENT, |
STATE_WAITING_FOR_SPEECH, |
@@ -73,6 +76,7 @@ class CONTENT_EXPORT SpeechRecognizerImpl |
enum FSMEvent { |
EVENT_ABORT = 0, |
+ EVENT_PREPARE, |
EVENT_START, |
EVENT_STOP_CAPTURE, |
EVENT_AUDIO_DATA, |
@@ -105,7 +109,11 @@ class CONTENT_EXPORT SpeechRecognizerImpl |
// Process a new audio chunk in the audio pipeline (endpointer, vumeter, etc). |
void ProcessAudioPipeline(const AudioChunk& raw_audio); |
+ // Callback from AudioSystem. |
+ void OnDeviceInfo(const media::AudioParameters& params); |
+ |
// The methods below handle transitions of the recognizer FSM. |
+ FSMState PrepareRecognition(const FSMEventArgs&); |
FSMState StartRecording(const FSMEventArgs& event_args); |
FSMState StartRecognitionEngine(const FSMEventArgs& event_args); |
FSMState WaitEnvironmentEstimationCompletion(const FSMEventArgs& event_args); |
@@ -153,8 +161,11 @@ class CONTENT_EXPORT SpeechRecognizerImpl |
void OnSpeechRecognitionEngineError( |
const SpeechRecognitionError& error) override; |
- static media::AudioManager* audio_manager_for_tests_; |
+ media::AudioSystem* GetAudioSystem(); |
+ // Substitutes the real audio system in browser tests. |
+ static media::AudioSystem* audio_system_for_tests_; |
+ media::AudioSystem* audio_system_; |
std::unique_ptr<SpeechRecognitionEngine> recognition_engine_; |
Endpointer endpointer_; |
scoped_refptr<media::AudioInputController> audio_controller_; |
@@ -166,6 +177,7 @@ class CONTENT_EXPORT SpeechRecognizerImpl |
bool end_of_utterance_; |
FSMState state_; |
std::string device_id_; |
+ media::AudioParameters device_params_; |
class OnDataConverter; |
@@ -173,6 +185,7 @@ class CONTENT_EXPORT SpeechRecognizerImpl |
// output format. |
std::unique_ptr<SpeechRecognizerImpl::OnDataConverter> audio_converter_; |
+ base::WeakPtrFactory<SpeechRecognizerImpl> weak_ptr_factory_; |
DISALLOW_COPY_AND_ASSIGN(SpeechRecognizerImpl); |
}; |