Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(274)

Unified Diff: content/browser/speech/speech_recognizer_impl.h

Issue 2675713002: Switch Speech Recognition to asynchronous callback-based AudioManager interactions. (Closed)
Patch Set: Created 3 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
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 f28417143d6902e32d769ab6c096e692f8cf2804..79be021344f32e569ad1c0606f9b74822e40193c 100644
--- a/content/browser/speech/speech_recognizer_impl.h
+++ b/content/browser/speech/speech_recognizer_impl.h
@@ -8,6 +8,7 @@
#include <memory>
#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"
@@ -19,7 +20,7 @@
namespace media {
class AudioBus;
-class AudioManager;
+class AudioSystem;
}
namespace content {
@@ -41,9 +42,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,
@@ -61,6 +63,7 @@ class CONTENT_EXPORT SpeechRecognizerImpl
enum FSMState {
STATE_IDLE = 0,
+ STATE_PREPARING,
STATE_STARTING,
STATE_ESTIMATING_ENVIRONMENT,
STATE_WAITING_FOR_SPEECH,
@@ -72,6 +75,7 @@ class CONTENT_EXPORT SpeechRecognizerImpl
enum FSMEvent {
EVENT_ABORT = 0,
+ EVENT_PREPARE,
EVENT_START,
EVENT_STOP_CAPTURE,
EVENT_AUDIO_DATA,
@@ -104,7 +108,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);
@@ -152,8 +160,10 @@ class CONTENT_EXPORT SpeechRecognizerImpl
void OnSpeechRecognitionEngineError(
const SpeechRecognitionError& error) override;
- static media::AudioManager* audio_manager_for_tests_;
+ media::AudioSystem* GetAudioSystem();
+ 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_;
@@ -165,6 +175,7 @@ class CONTENT_EXPORT SpeechRecognizerImpl
bool end_of_utterance_;
FSMState state_;
std::string device_id_;
+ media::AudioParameters device_params_;
class OnDataConverter;
@@ -172,6 +183,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);
};

Powered by Google App Engine
This is Rietveld 408576698