Commit 579d6996 authored by xians@chromium.org's avatar xians@chromium.org

added back support to speech when ask_user=false. We should use the default...

added back support to speech when ask_user=false. We should use the default device for the deprecated API.

TBR=henrika@chromium.org

BUG=252848
TEST=
<script>
recognition = new webkitSpeechRecognition();
recognition.start();
</script>

Review URL: https://codereview.chromium.org/17074008

git-svn-id: svn://svn.chromium.org/chrome/trunk/src@208020 0039d316-1c4b-4281-b951-d872f2087c98
parent f29f42b9
...@@ -22,6 +22,7 @@ ...@@ -22,6 +22,7 @@
#include "content/public/common/speech_recognition_error.h" #include "content/public/common/speech_recognition_error.h"
#include "content/public/common/speech_recognition_result.h" #include "content/public/common/speech_recognition_result.h"
#include "media/audio/audio_manager.h" #include "media/audio/audio_manager.h"
#include "media/audio/audio_manager_base.h"
#if defined(OS_ANDROID) #if defined(OS_ANDROID)
#include "content/browser/speech/speech_recognizer_impl_android.h" #include "content/browser/speech/speech_recognizer_impl_android.h"
...@@ -568,10 +569,20 @@ SpeechRecognitionManagerImpl::GetSessionState(int session_id) const { ...@@ -568,10 +569,20 @@ SpeechRecognitionManagerImpl::GetSessionState(int session_id) const {
void SpeechRecognitionManagerImpl::SessionStart(const Session& session) { void SpeechRecognitionManagerImpl::SessionStart(const Session& session) {
DCHECK_EQ(primary_session_id_, session.id); DCHECK_EQ(primary_session_id_, session.id);
const MediaStreamDevices& devices = session.context.devices; const MediaStreamDevices& devices = session.context.devices;
DCHECK_EQ(1u, devices.size()); std::string device_id;
DCHECK_EQ(MEDIA_DEVICE_AUDIO_CAPTURE, devices.front().type); 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) { void SpeechRecognitionManagerImpl::SessionAbort(const Session& session) {
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment