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

Side by Side Diff: media/audio/audio_parameters.cc

Issue 115413002: Enable platform echo cancellation through the AudioRecord path. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: . Created 7 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') | media/audio/cras/audio_manager_cras.cc » ('j') | 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/audio_parameters.h" 5 #include "media/audio/audio_parameters.h"
6 6
7 #include "base/logging.h" 7 #include "base/logging.h"
8 #include "media/base/limits.h" 8 #include "media/base/limits.h"
9 9
10 namespace media { 10 namespace media {
11 11
12 AudioParameters::AudioParameters() 12 AudioParameters::AudioParameters()
13 : format_(AUDIO_PCM_LINEAR), 13 : format_(AUDIO_PCM_LINEAR),
14 channel_layout_(CHANNEL_LAYOUT_NONE), 14 channel_layout_(CHANNEL_LAYOUT_NONE),
15 sample_rate_(0), 15 sample_rate_(0),
16 bits_per_sample_(0), 16 bits_per_sample_(0),
17 frames_per_buffer_(0), 17 frames_per_buffer_(0),
18 channels_(0), 18 channels_(0),
19 input_channels_(0) { 19 input_channels_(0),
20 effects_(NO_EFFECTS) {
20 } 21 }
21 22
22 AudioParameters::AudioParameters(Format format, ChannelLayout channel_layout, 23 AudioParameters::AudioParameters(Format format, ChannelLayout channel_layout,
23 int sample_rate, int bits_per_sample, 24 int sample_rate, int bits_per_sample,
24 int frames_per_buffer) 25 int frames_per_buffer)
25 : format_(format), 26 : format_(format),
26 channel_layout_(channel_layout), 27 channel_layout_(channel_layout),
27 sample_rate_(sample_rate), 28 sample_rate_(sample_rate),
28 bits_per_sample_(bits_per_sample), 29 bits_per_sample_(bits_per_sample),
29 frames_per_buffer_(frames_per_buffer), 30 frames_per_buffer_(frames_per_buffer),
30 channels_(ChannelLayoutToChannelCount(channel_layout)), 31 channels_(ChannelLayoutToChannelCount(channel_layout)),
31 input_channels_(0) { 32 input_channels_(0),
33 effects_(NO_EFFECTS) {
32 } 34 }
33 35
34 AudioParameters::AudioParameters(Format format, ChannelLayout channel_layout, 36 AudioParameters::AudioParameters(Format format, ChannelLayout channel_layout,
35 int input_channels, 37 int input_channels,
36 int sample_rate, int bits_per_sample, 38 int sample_rate, int bits_per_sample,
37 int frames_per_buffer) 39 int frames_per_buffer, int effects)
38 : format_(format), 40 : format_(format),
39 channel_layout_(channel_layout), 41 channel_layout_(channel_layout),
40 sample_rate_(sample_rate), 42 sample_rate_(sample_rate),
41 bits_per_sample_(bits_per_sample), 43 bits_per_sample_(bits_per_sample),
42 frames_per_buffer_(frames_per_buffer), 44 frames_per_buffer_(frames_per_buffer),
43 channels_(ChannelLayoutToChannelCount(channel_layout)), 45 channels_(ChannelLayoutToChannelCount(channel_layout)),
44 input_channels_(input_channels) { 46 input_channels_(input_channels),
47 effects_(effects) {
48 }
49
50 AudioParameters::AudioParameters(Format format, ChannelLayout channel_layout,
51 int channels, int input_channels,
52 int sample_rate, int bits_per_sample,
53 int frames_per_buffer, int effects)
54 : format_(format),
55 channel_layout_(channel_layout),
56 sample_rate_(sample_rate),
57 bits_per_sample_(bits_per_sample),
58 frames_per_buffer_(frames_per_buffer),
59 channels_(channels),
60 input_channels_(input_channels),
61 effects_(effects) {
62 if (channel_layout != CHANNEL_LAYOUT_DISCRETE)
63 DCHECK_EQ(channels, ChannelLayoutToChannelCount(channel_layout));
45 } 64 }
46 65
47 void AudioParameters::Reset(Format format, ChannelLayout channel_layout, 66 void AudioParameters::Reset(Format format, ChannelLayout channel_layout,
48 int channels, int input_channels, 67 int channels, int input_channels,
49 int sample_rate, int bits_per_sample, 68 int sample_rate, int bits_per_sample,
50 int frames_per_buffer) { 69 int frames_per_buffer) {
51 if (channel_layout != CHANNEL_LAYOUT_DISCRETE) 70 if (channel_layout != CHANNEL_LAYOUT_DISCRETE)
52 DCHECK_EQ(channels, ChannelLayoutToChannelCount(channel_layout)); 71 DCHECK_EQ(channels, ChannelLayoutToChannelCount(channel_layout));
53 72
54 format_ = format; 73 format_ = format;
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after
88 int AudioParameters::GetBytesPerFrame() const { 107 int AudioParameters::GetBytesPerFrame() const {
89 return channels_ * bits_per_sample_ / 8; 108 return channels_ * bits_per_sample_ / 8;
90 } 109 }
91 110
92 base::TimeDelta AudioParameters::GetBufferDuration() const { 111 base::TimeDelta AudioParameters::GetBufferDuration() const {
93 return base::TimeDelta::FromMicroseconds( 112 return base::TimeDelta::FromMicroseconds(
94 frames_per_buffer_ * base::Time::kMicrosecondsPerSecond / 113 frames_per_buffer_ * base::Time::kMicrosecondsPerSecond /
95 static_cast<float>(sample_rate_)); 114 static_cast<float>(sample_rate_));
96 } 115 }
97 116
98 void AudioParameters::SetDiscreteChannels(int channels) {
99 channel_layout_ = CHANNEL_LAYOUT_DISCRETE;
100 channels_ = channels;
101 }
102
103 } // namespace media 117 } // namespace media
OLDNEW
« no previous file with comments | « media/audio/audio_parameters.h ('k') | media/audio/cras/audio_manager_cras.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698