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

Side by Side Diff: media/audio/cras/cras_input.cc

Issue 551823005: [Hotword] Adding audio parameters to handle audio coming from the DSP. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: update stream type Created 6 years 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
« no previous file with comments | « media/audio/audio_parameters.h ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 "media/audio/cras/cras_input.h" 5 #include "media/audio/cras/cras_input.h"
6 6
7 #include <cras_input.h>
7 #include <math.h> 8 #include <math.h>
8 9
9 #include "base/basictypes.h" 10 #include "base/basictypes.h"
10 #include "base/logging.h" 11 #include "base/logging.h"
11 #include "base/time/time.h" 12 #include "base/time/time.h"
12 #include "media/audio/audio_manager.h" 13 #include "media/audio/audio_manager.h"
13 #include "media/audio/cras/audio_manager_cras.h" 14 #include "media/audio/cras/audio_manager_cras.h"
14 15
15 namespace media { 16 namespace media {
16 17
(...skipping 135 matching lines...) Expand 10 before | Expand all | Expand 10 after
152 for (size_t i = 0; i < arraysize(kChannelMap); ++i) { 153 for (size_t i = 0; i < arraysize(kChannelMap); ++i) {
153 layout[kChannelMap[i]] = ChannelOrder(params_.channel_layout(), 154 layout[kChannelMap[i]] = ChannelOrder(params_.channel_layout(),
154 static_cast<Channels>(i)); 155 static_cast<Channels>(i));
155 } 156 }
156 if (cras_audio_format_set_channel_layout(audio_format, layout) != 0) { 157 if (cras_audio_format_set_channel_layout(audio_format, layout) != 0) {
157 DLOG(WARNING) << "Error setting channel layout."; 158 DLOG(WARNING) << "Error setting channel layout.";
158 callback->OnError(this); 159 callback->OnError(this);
159 return; 160 return;
160 } 161 }
161 162
163 uint32_t flags = 0;
164 if (params_.effects() & AudioParameters::PlatformEffectsMask::HOTWORD)
165 flags = HOTWORD_STREAM;
Steve McKay 2014/12/17 17:41:29 This is still broken for me. Where is this value d
dgreid 2014/12/17 17:44:20 in cras_types.h, you'll need an up to date libcras
166
162 unsigned int frames_per_packet = params_.frames_per_buffer(); 167 unsigned int frames_per_packet = params_.frames_per_buffer();
163 cras_stream_params* stream_params = cras_client_stream_params_create( 168 cras_stream_params* stream_params = cras_client_stream_params_create(
164 stream_direction_, 169 stream_direction_,
165 frames_per_packet, // Total latency. 170 frames_per_packet, // Total latency.
166 frames_per_packet, // Call back when this many ready. 171 frames_per_packet, // Call back when this many ready.
167 frames_per_packet, // Minimum Callback level ignored for capture streams. 172 frames_per_packet, // Minimum Callback level ignored for capture streams.
168 CRAS_STREAM_TYPE_DEFAULT, 173 CRAS_STREAM_TYPE_DEFAULT,
169 0, // Unused flags. 174 flags,
170 this, 175 this,
171 CrasInputStream::SamplesReady, 176 CrasInputStream::SamplesReady,
172 CrasInputStream::StreamError, 177 CrasInputStream::StreamError,
173 audio_format); 178 audio_format);
174 if (!stream_params) { 179 if (!stream_params) {
175 DLOG(WARNING) << "Error setting up stream parameters."; 180 DLOG(WARNING) << "Error setting up stream parameters.";
176 callback_->OnError(this); 181 callback_->OnError(this);
177 callback_ = NULL; 182 callback_ = NULL;
178 cras_audio_format_destroy(audio_format); 183 cras_audio_format_destroy(audio_format);
179 return; 184 return;
(...skipping 127 matching lines...) Expand 10 before | Expand all | Expand 10 after
307 312
308 double CrasInputStream::GetVolumeRatioFromDecibels(double dB) const { 313 double CrasInputStream::GetVolumeRatioFromDecibels(double dB) const {
309 return pow(10, dB / 20.0); 314 return pow(10, dB / 20.0);
310 } 315 }
311 316
312 double CrasInputStream::GetDecibelsFromVolumeRatio(double volume_ratio) const { 317 double CrasInputStream::GetDecibelsFromVolumeRatio(double volume_ratio) const {
313 return 20 * log10(volume_ratio); 318 return 20 * log10(volume_ratio);
314 } 319 }
315 320
316 } // namespace media 321 } // namespace media
OLDNEW
« no previous file with comments | « media/audio/audio_parameters.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698