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

Unified Diff: content/browser/speech/speech_recognition_manager_impl.cc

Issue 17074008: added back support to speech when ask_user=false (Closed) Base URL: http://chromium.googlesource.com/chromium/src.git@master
Patch Set: added a TODO Created 7 years, 6 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
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 19dff5ca152ee343af601cd1aa28dd26af4e5989..63d4c611c6ac584d86fee2316698866dbefa1328 100644
--- a/content/browser/speech/speech_recognition_manager_impl.cc
+++ b/content/browser/speech/speech_recognition_manager_impl.cc
@@ -22,6 +22,7 @@
#include "content/public/common/speech_recognition_error.h"
#include "content/public/common/speech_recognition_result.h"
#include "media/audio/audio_manager.h"
+#include "media/audio/audio_manager_base.h"
#if defined(OS_ANDROID)
#include "content/browser/speech/speech_recognizer_impl_android.h"
@@ -568,10 +569,20 @@ SpeechRecognitionManagerImpl::GetSessionState(int session_id) const {
void SpeechRecognitionManagerImpl::SessionStart(const Session& session) {
DCHECK_EQ(primary_session_id_, session.id);
const MediaStreamDevices& devices = session.context.devices;
- DCHECK_EQ(1u, devices.size());
- DCHECK_EQ(MEDIA_DEVICE_AUDIO_CAPTURE, devices.front().type);
+ std::string device_id;
+ if (devices.empty()) {
+ // From the ask_user=false path, use the default device.
+ // TODO(xians): Abort the session after we do not need to support this path
+ // anymore.
+ device_id = media::AudioManagerBase::kDefaultDeviceId;
+ } else {
+ // From the ask_user=true path, use the selected device.
+ DCHECK_EQ(1u, devices.size());
+ DCHECK_EQ(MEDIA_DEVICE_AUDIO_CAPTURE, devices.front().type);
+ device_id = devices.front().id;
+ }
- session.recognizer->StartRecognition(devices.front().id);
+ session.recognizer->StartRecognition(device_id);
}
void SpeechRecognitionManagerImpl::SessionAbort(const Session& session) {
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698