| 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 1a054204c4477a7e6c4c09abfd11a54aeea7443c..78f31080a69e5985ac01311a3b8024e7af4e7ddd 100644
|
| --- a/content/browser/speech/speech_recognition_manager_impl.cc
|
| +++ b/content/browser/speech/speech_recognition_manager_impl.cc
|
| @@ -149,6 +149,8 @@ int SpeechRecognitionManagerImpl::CreateSession(
|
| session_id,
|
| config.continuous,
|
| config.interim_results,
|
| + config.using_audio_track,
|
| + config.peer_process_handle,
|
| google_remote_engine);
|
| #else
|
| session->recognizer = new SpeechRecognizerImplAndroid(this, session_id);
|
| @@ -192,7 +194,7 @@ void SpeechRecognitionManagerImpl::RecognitionAllowedCallback(int session_id,
|
| if (session->abort_requested)
|
| return;
|
|
|
| - if (ask_user) {
|
| + if (ask_user && !session->config.using_audio_track) {
|
| SpeechRecognitionSessionContext& context = session->context;
|
| context.label = media_stream_manager_->MakeMediaAccessRequest(
|
| context.render_process_id,
|
| @@ -206,7 +208,7 @@ void SpeechRecognitionManagerImpl::RecognitionAllowedCallback(int session_id,
|
| return;
|
| }
|
|
|
| - if (is_allowed) {
|
| + if (is_allowed || session->config.using_audio_track) {
|
| base::MessageLoop::current()->PostTask(
|
| FROM_HERE,
|
| base::Bind(&SpeechRecognitionManagerImpl::DispatchEvent,
|
| @@ -430,11 +432,24 @@ void SpeechRecognitionManagerImpl::OnRecognitionEnd(int session_id) {
|
| EVENT_RECOGNITION_ENDED));
|
| }
|
|
|
| +void SpeechRecognitionManagerImpl::OnAudioReceiverReady(
|
| + int session_id,
|
| + const media::AudioParameters& params,
|
| + const base::SharedMemoryHandle memory,
|
| + const base::SyncSocket::TransitDescriptor socket) {
|
| + DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO));
|
| + if (!SessionExists(session_id))
|
| + return;
|
| +
|
| + if (SpeechRecognitionEventListener* listener = GetListener(session_id))
|
| + listener->OnAudioReceiverReady(session_id, params, memory, socket);
|
| +}
|
| +
|
| int SpeechRecognitionManagerImpl::GetSession(
|
| int render_process_id, int render_view_id, int request_id) const {
|
| DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO));
|
| SessionsTable::const_iterator iter;
|
| - for(iter = sessions_.begin(); iter != sessions_.end(); ++iter) {
|
| + for (iter = sessions_.begin(); iter != sessions_.end(); ++iter) {
|
| const int session_id = iter->first;
|
| const SpeechRecognitionSessionContext& context = iter->second->context;
|
| if (context.render_process_id == render_process_id &&
|
| @@ -583,16 +598,18 @@ void SpeechRecognitionManagerImpl::SessionStart(const Session& session) {
|
| DCHECK_EQ(primary_session_id_, session.id);
|
| const MediaStreamDevices& devices = session.context.devices;
|
| 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;
|
| + if (!session.config.using_audio_track) {
|
| + 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(device_id);
|
|
|