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

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

Issue 1275783003: Add a virtual beamforming audio device on ChromeOS. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years, 4 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
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 : AudioParameters(AUDIO_PCM_LINEAR, CHANNEL_LAYOUT_NONE, 0, 0, 0) {}
14 channel_layout_(CHANNEL_LAYOUT_NONE),
15 sample_rate_(0),
16 bits_per_sample_(0),
17 frames_per_buffer_(0),
18 channels_(0),
19 effects_(NO_EFFECTS) {
20 }
21 14
22 AudioParameters::AudioParameters(Format format, ChannelLayout channel_layout, 15 AudioParameters::AudioParameters(Format format,
23 int sample_rate, int bits_per_sample, 16 ChannelLayout channel_layout,
24 int frames_per_buffer) 17 int sample_rate,
25 : format_(format), 18 int bits_per_sample,
26 channel_layout_(channel_layout), 19 int frames_per_buffer,
27 sample_rate_(sample_rate), 20 const std::string& mic_positions,
28 bits_per_sample_(bits_per_sample), 21 int effects)
29 frames_per_buffer_(frames_per_buffer), 22 : AudioParameters(format,
30 channels_(ChannelLayoutToChannelCount(channel_layout)), 23 ChannelLayoutToChannelCount(channel_layout),
31 effects_(NO_EFFECTS) { 24 channel_layout,
32 } 25 sample_rate,
26 bits_per_sample,
27 frames_per_buffer,
28 mic_positions,
29 effects) {}
33 30
34 AudioParameters::AudioParameters(Format format, ChannelLayout channel_layout, 31 AudioParameters::AudioParameters(Format format,
35 int sample_rate, int bits_per_sample, 32 int channels,
36 int frames_per_buffer, int effects) 33 ChannelLayout channel_layout,
37 : format_(format), 34 int sample_rate,
38 channel_layout_(channel_layout), 35 int bits_per_sample,
39 sample_rate_(sample_rate), 36 int frames_per_buffer,
40 bits_per_sample_(bits_per_sample), 37 const std::string& mic_positions,
41 frames_per_buffer_(frames_per_buffer),
42 channels_(ChannelLayoutToChannelCount(channel_layout)),
43 effects_(effects) {
44 }
45
46 AudioParameters::AudioParameters(Format format, ChannelLayout channel_layout,
47 int channels, int sample_rate,
48 int bits_per_sample, int frames_per_buffer,
49 int effects) 38 int effects)
50 : format_(format), 39 : format_(format),
51 channel_layout_(channel_layout), 40 channel_layout_(channel_layout),
52 sample_rate_(sample_rate), 41 sample_rate_(sample_rate),
53 bits_per_sample_(bits_per_sample), 42 bits_per_sample_(bits_per_sample),
54 frames_per_buffer_(frames_per_buffer), 43 frames_per_buffer_(frames_per_buffer),
55 channels_(channels), 44 channels_(channels),
56 effects_(effects) { 45 mic_positions_(mic_positions),
57 } 46 effects_(effects) {}
58 47
59 void AudioParameters::Reset(Format format, ChannelLayout channel_layout, 48 void AudioParameters::Reset(Format format, ChannelLayout channel_layout,
60 int channels, int sample_rate, 49 int channels, int sample_rate,
61 int bits_per_sample, int frames_per_buffer) { 50 int bits_per_sample, int frames_per_buffer) {
62 format_ = format; 51 format_ = format;
63 channel_layout_ = channel_layout; 52 channel_layout_ = channel_layout;
64 channels_ = channels; 53 channels_ = channels;
65 sample_rate_ = sample_rate; 54 sample_rate_ = sample_rate;
66 bits_per_sample_ = bits_per_sample; 55 bits_per_sample_ = bits_per_sample;
67 frames_per_buffer_ = frames_per_buffer; 56 frames_per_buffer_ = frames_per_buffer;
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after
103 return channels_ * bits_per_sample_ / 8; 92 return channels_ * bits_per_sample_ / 8;
104 } 93 }
105 94
106 base::TimeDelta AudioParameters::GetBufferDuration() const { 95 base::TimeDelta AudioParameters::GetBufferDuration() const {
107 return base::TimeDelta::FromMicroseconds(static_cast<int64>( 96 return base::TimeDelta::FromMicroseconds(static_cast<int64>(
108 frames_per_buffer_ * base::Time::kMicrosecondsPerSecond / 97 frames_per_buffer_ * base::Time::kMicrosecondsPerSecond /
109 static_cast<float>(sample_rate_))); 98 static_cast<float>(sample_rate_)));
110 } 99 }
111 100
112 bool AudioParameters::Equals(const AudioParameters& other) const { 101 bool AudioParameters::Equals(const AudioParameters& other) const {
113 return format_ == other.format() && 102 return format_ == other.format() && sample_rate_ == other.sample_rate() &&
114 sample_rate_ == other.sample_rate() &&
115 channel_layout_ == other.channel_layout() && 103 channel_layout_ == other.channel_layout() &&
116 channels_ == other.channels() && 104 channels_ == other.channels() &&
117 bits_per_sample_ == other.bits_per_sample() && 105 bits_per_sample_ == other.bits_per_sample() &&
118 frames_per_buffer_ == other.frames_per_buffer() && 106 frames_per_buffer_ == other.frames_per_buffer() &&
119 effects_ == other.effects(); 107 mic_positions_ == other.mic_positions_ && effects_ == other.effects();
120 } 108 }
121 109
122 } // namespace media 110 } // namespace media
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698