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

Side by Side Diff: content/browser/speech/speech_recognizer_impl.cc

Issue 9805001: Move media/audio files into media namespace (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Fix various compiler errors Created 8 years, 9 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 unified diff | Download patch | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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 "content/browser/speech/speech_recognizer_impl.h" 5 #include "content/browser/speech/speech_recognizer_impl.h"
6 6
7 #include "base/bind.h" 7 #include "base/bind.h"
8 #include "base/time.h" 8 #include "base/time.h"
9 #include "content/browser/browser_main_loop.h" 9 #include "content/browser/browser_main_loop.h"
10 #include "content/browser/speech/audio_buffer.h" 10 #include "content/browser/speech/audio_buffer.h"
(...skipping 114 matching lines...) Expand 10 before | Expand all | Expand 10 after
125 DCHECK(!encoder_.get()); 125 DCHECK(!encoder_.get());
126 126
127 // The endpointer needs to estimate the environment/background noise before 127 // The endpointer needs to estimate the environment/background noise before
128 // starting to treat the audio as user input. In |HandleOnData| we wait until 128 // starting to treat the audio as user input. In |HandleOnData| we wait until
129 // such time has passed before switching to user input mode. 129 // such time has passed before switching to user input mode.
130 endpointer_.SetEnvironmentEstimationMode(); 130 endpointer_.SetEnvironmentEstimationMode();
131 131
132 encoder_.reset(AudioEncoder::Create(codec_, kAudioSampleRate, 132 encoder_.reset(AudioEncoder::Create(codec_, kAudioSampleRate,
133 kNumBitsPerAudioSample)); 133 kNumBitsPerAudioSample));
134 int samples_per_packet = (kAudioSampleRate * kAudioPacketIntervalMs) / 1000; 134 int samples_per_packet = (kAudioSampleRate * kAudioPacketIntervalMs) / 1000;
135 AudioParameters params(AudioParameters::AUDIO_PCM_LINEAR, kChannelLayout, 135 media::AudioParameters params(
136 kAudioSampleRate, kNumBitsPerAudioSample, 136 media::AudioParameters::AUDIO_PCM_LINEAR, kChannelLayout,
137 samples_per_packet); 137 kAudioSampleRate, kNumBitsPerAudioSample, samples_per_packet);
138 audio_controller_ = AudioInputController::Create( 138 audio_controller_ = AudioInputController::Create(
139 audio_manager_ ? audio_manager_ : BrowserMainLoop::GetAudioManager(), 139 audio_manager_ ? audio_manager_ : BrowserMainLoop::GetAudioManager(),
140 this, params); 140 this, params);
141 DCHECK(audio_controller_.get()); 141 DCHECK(audio_controller_.get());
142 VLOG(1) << "SpeechRecognizer starting record."; 142 VLOG(1) << "SpeechRecognizer starting record.";
143 num_samples_recorded_ = 0; 143 num_samples_recorded_ = 0;
144 audio_controller_->Record(); 144 audio_controller_->Record();
145 145
146 return true; 146 return true;
147 } 147 }
(...skipping 184 matching lines...) Expand 10 before | Expand all | Expand 10 after
332 // and switch to async. version of this method. Compare with how 332 // and switch to async. version of this method. Compare with how
333 // it's done in e.g. the AudioRendererHost. 333 // it's done in e.g. the AudioRendererHost.
334 base::WaitableEvent closed_event(true, false); 334 base::WaitableEvent closed_event(true, false);
335 audio_controller_->Close(base::Bind(&base::WaitableEvent::Signal, 335 audio_controller_->Close(base::Bind(&base::WaitableEvent::Signal,
336 base::Unretained(&closed_event))); 336 base::Unretained(&closed_event)));
337 closed_event.Wait(); 337 closed_event.Wait();
338 audio_controller_ = NULL; // Releases the ref ptr. 338 audio_controller_ = NULL; // Releases the ref ptr.
339 } 339 }
340 340
341 void SpeechRecognizerImpl::SetAudioManagerForTesting( 341 void SpeechRecognizerImpl::SetAudioManagerForTesting(
342 AudioManager* audio_manager) { 342 media::AudioManager* audio_manager) {
343 audio_manager_ = audio_manager; 343 audio_manager_ = audio_manager;
344 } 344 }
345 345
346 bool SpeechRecognizerImpl::IsActive() const { 346 bool SpeechRecognizerImpl::IsActive() const {
347 return (request_.get() != NULL); 347 return (request_.get() != NULL);
348 } 348 }
349 349
350 bool SpeechRecognizerImpl::IsCapturingAudio() const { 350 bool SpeechRecognizerImpl::IsCapturingAudio() const {
351 return (audio_controller_.get() != NULL); 351 return (audio_controller_.get() != NULL);
352 } 352 }
353 353
354 } // namespace speech 354 } // namespace speech
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698