| OLD | NEW |
| 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/renderer/media/webrtc_audio_capturer.h" | 5 #include "content/renderer/media/webrtc_audio_capturer.h" |
| 6 | 6 |
| 7 #include "base/bind.h" | 7 #include "base/bind.h" |
| 8 #include "base/logging.h" | 8 #include "base/logging.h" |
| 9 #include "base/metrics/histogram.h" | 9 #include "base/metrics/histogram.h" |
| 10 #include "base/string_util.h" | 10 #include "base/string_util.h" |
| (...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 79 if (!buffer_size) { | 79 if (!buffer_size) { |
| 80 DLOG(ERROR) << "Unsupported sample-rate: " << sample_rate; | 80 DLOG(ERROR) << "Unsupported sample-rate: " << sample_rate; |
| 81 return false; | 81 return false; |
| 82 } | 82 } |
| 83 | 83 |
| 84 media::AudioParameters::Format format = | 84 media::AudioParameters::Format format = |
| 85 media::AudioParameters::AUDIO_PCM_LOW_LATENCY; | 85 media::AudioParameters::AUDIO_PCM_LOW_LATENCY; |
| 86 | 86 |
| 87 // bits_per_sample is always 16 for now. | 87 // bits_per_sample is always 16 for now. |
| 88 int bits_per_sample = 16; | 88 int bits_per_sample = 16; |
| 89 | 89 int channels = ChannelLayoutToChannelCount(channel_layout); |
| 90 params_.Reset(format, channel_layout, 0, sample_rate, bits_per_sample, | 90 params_.Reset(format, channel_layout, channels, 0, |
| 91 buffer_size); | 91 sample_rate, bits_per_sample, buffer_size); |
| 92 buffer_.reset(new int16[params_.frames_per_buffer() * params_.channels()]); | 92 buffer_.reset(new int16[params_.frames_per_buffer() * params_.channels()]); |
| 93 | 93 |
| 94 return true; | 94 return true; |
| 95 } | 95 } |
| 96 | 96 |
| 97 int16* buffer() const { return buffer_.get(); } | 97 int16* buffer() const { return buffer_.get(); } |
| 98 const media::AudioParameters& params() const { return params_; } | 98 const media::AudioParameters& params() const { return params_; } |
| 99 | 99 |
| 100 private: | 100 private: |
| 101 ~ConfiguredBuffer() {} | 101 ~ConfiguredBuffer() {} |
| (...skipping 386 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 488 if (!on_device_stopped_cb_.is_null()) | 488 if (!on_device_stopped_cb_.is_null()) |
| 489 on_device_stopped_cb_.Run(); | 489 on_device_stopped_cb_.Run(); |
| 490 } | 490 } |
| 491 | 491 |
| 492 media::AudioParameters WebRtcAudioCapturer::audio_parameters() const { | 492 media::AudioParameters WebRtcAudioCapturer::audio_parameters() const { |
| 493 base::AutoLock auto_lock(lock_); | 493 base::AutoLock auto_lock(lock_); |
| 494 return buffer_->params(); | 494 return buffer_->params(); |
| 495 } | 495 } |
| 496 | 496 |
| 497 } // namespace content | 497 } // namespace content |
| OLD | NEW |