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

Side by Side Diff: chrome/browser/speech/speech_recognizer.cc

Issue 4661001: Simplified AudioOutputStream interface. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: - Created 10 years, 1 month 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 unified diff | Download patch | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2010 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "chrome/browser/speech/speech_recognizer.h" 5 #include "chrome/browser/speech/speech_recognizer.h"
6 6
7 #include "base/ref_counted.h" 7 #include "base/ref_counted.h"
8 #include "base/scoped_ptr.h" 8 #include "base/scoped_ptr.h"
9 #include "base/time.h" 9 #include "base/time.h"
10 #include "chrome/browser/browser_thread.h" 10 #include "chrome/browser/browser_thread.h"
(...skipping 131 matching lines...) Expand 10 before | Expand all | Expand 10 after
142 DCHECK(!request_.get() || !request_->HasPendingRequest()); 142 DCHECK(!request_.get() || !request_->HasPendingRequest());
143 143
144 // The endpointer needs to estimate the environment/background noise before 144 // The endpointer needs to estimate the environment/background noise before
145 // starting to treat the audio as user input. In |HandleOnData| we wait until 145 // starting to treat the audio as user input. In |HandleOnData| we wait until
146 // such time has passed before switching to user input mode. 146 // such time has passed before switching to user input mode.
147 endpointer_.SetEnvironmentEstimationMode(); 147 endpointer_.SetEnvironmentEstimationMode();
148 148
149 int samples_per_packet = (kAudioSampleRate * kAudioPacketIntervalMs) / 1000; 149 int samples_per_packet = (kAudioSampleRate * kAudioPacketIntervalMs) / 1000;
150 DCHECK((samples_per_packet % encoder_->samples_per_frame()) == 0); 150 DCHECK((samples_per_packet % encoder_->samples_per_frame()) == 0);
151 AudioParameters params(AudioParameters::AUDIO_PCM_LINEAR, kNumAudioChannels, 151 AudioParameters params(AudioParameters::AUDIO_PCM_LINEAR, kNumAudioChannels,
152 kAudioSampleRate, kNumBitsPerAudioSample); 152 kAudioSampleRate, kNumBitsPerAudioSample,
153 audio_controller_ = 153 samples_per_packet);
154 AudioInputController::Create(this, params, samples_per_packet); 154 audio_controller_ = AudioInputController::Create(this, params);
155 DCHECK(audio_controller_.get()); 155 DCHECK(audio_controller_.get());
156 VLOG(1) << "SpeechRecognizer starting record."; 156 VLOG(1) << "SpeechRecognizer starting record.";
157 num_samples_recorded_ = 0; 157 num_samples_recorded_ = 0;
158 audio_controller_->Record(); 158 audio_controller_->Record();
159 159
160 return true; 160 return true;
161 } 161 }
162 162
163 void SpeechRecognizer::CancelRecognition() { 163 void SpeechRecognizer::CancelRecognition() {
164 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); 164 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO));
(...skipping 167 matching lines...) Expand 10 before | Expand all | Expand 10 after
332 332
333 void SpeechRecognizer::InformErrorAndCancelRecognition(ErrorCode error) { 333 void SpeechRecognizer::InformErrorAndCancelRecognition(ErrorCode error) {
334 CancelRecognition(); 334 CancelRecognition();
335 335
336 // Guard against the delegate freeing us until we finish our job. 336 // Guard against the delegate freeing us until we finish our job.
337 scoped_refptr<SpeechRecognizer> me(this); 337 scoped_refptr<SpeechRecognizer> me(this);
338 delegate_->OnRecognizerError(caller_id_, error); 338 delegate_->OnRecognizerError(caller_id_, error);
339 } 339 }
340 340
341 } // namespace speech_input 341 } // namespace speech_input
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698