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

Side by Side Diff: content/renderer/media/webaudio_capturer_source.cc

Issue 1304973005: Refactor AudioParameters member setting. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: More cross-platform. Created 5 years, 3 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 "content/renderer/media/webaudio_capturer_source.h" 5 #include "content/renderer/media/webaudio_capturer_source.h"
6 6
7 #include "base/logging.h" 7 #include "base/logging.h"
8 #include "base/time/time.h" 8 #include "base/time/time.h"
9 #include "content/renderer/media/webrtc_local_audio_track.h" 9 #include "content/renderer/media/webrtc_local_audio_track.h"
10 10
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after
42 return; 42 return;
43 } 43 }
44 44
45 ChannelLayout channel_layout = 45 ChannelLayout channel_layout =
46 number_of_channels == 1 ? CHANNEL_LAYOUT_MONO : CHANNEL_LAYOUT_STEREO; 46 number_of_channels == 1 ? CHANNEL_LAYOUT_MONO : CHANNEL_LAYOUT_STEREO;
47 47
48 base::AutoLock auto_lock(lock_); 48 base::AutoLock auto_lock(lock_);
49 // Set the format used by this WebAudioCapturerSource. We are using 10ms data 49 // Set the format used by this WebAudioCapturerSource. We are using 10ms data
50 // as buffer size since that is the native buffer size of WebRtc packet 50 // as buffer size since that is the native buffer size of WebRtc packet
51 // running on. 51 // running on.
52 params_.Reset(media::AudioParameters::AUDIO_PCM_LOW_LATENCY, 52 params_.Reset(media::AudioParameters::AUDIO_PCM_LOW_LATENCY, channel_layout,
53 channel_layout, number_of_channels, sample_rate, 16, 53 sample_rate, 16, sample_rate / 100);
54 sample_rate / 100);
55 audio_format_changed_ = true; 54 audio_format_changed_ = true;
56 55
57 wrapper_bus_ = AudioBus::CreateWrapper(params_.channels()); 56 wrapper_bus_ = AudioBus::CreateWrapper(params_.channels());
58 capture_bus_ = AudioBus::Create(params_); 57 capture_bus_ = AudioBus::Create(params_);
59 fifo_.reset(new AudioFifo( 58 fifo_.reset(new AudioFifo(
60 params_.channels(), 59 params_.channels(),
61 kMaxNumberOfBuffersInFifo * params_.frames_per_buffer())); 60 kMaxNumberOfBuffersInFifo * params_.frames_per_buffer()));
62 } 61 }
63 62
64 void WebAudioCapturerSource::Start(WebRtcLocalAudioTrack* track) { 63 void WebAudioCapturerSource::Start(WebRtcLocalAudioTrack* track) {
(...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after
131 // WebAudioCapturerSource reference still registered as an audio consumer on 130 // WebAudioCapturerSource reference still registered as an audio consumer on
132 // the blink side. 131 // the blink side.
133 void WebAudioCapturerSource::removeFromBlinkSource() { 132 void WebAudioCapturerSource::removeFromBlinkSource() {
134 if (!blink_source_.isNull()) { 133 if (!blink_source_.isNull()) {
135 blink_source_.removeAudioConsumer(this); 134 blink_source_.removeAudioConsumer(this);
136 blink_source_.reset(); 135 blink_source_.reset();
137 } 136 }
138 } 137 }
139 138
140 } // namespace content 139 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698