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

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

Issue 15979027: start/stop the source of the capturer when 1st audiotrack/last audiotrack is added/removed (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: addressed Henrik's comments. Created 7 years, 6 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 | Annotate | Revision Log
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 "content/renderer/media/webrtc_audio_capturer.h" 8 #include "content/renderer/media/webrtc_audio_capturer.h"
9 9
10 using media::AudioBus; 10 using media::AudioBus;
(...skipping 19 matching lines...) Expand all
30 30
31 void WebAudioCapturerSource::setFormat( 31 void WebAudioCapturerSource::setFormat(
32 size_t number_of_channels, float sample_rate) { 32 size_t number_of_channels, float sample_rate) {
33 DVLOG(1) << "WebAudioCapturerSource::setFormat(sample_rate=" 33 DVLOG(1) << "WebAudioCapturerSource::setFormat(sample_rate="
34 << sample_rate << ")"; 34 << sample_rate << ")";
35 if (number_of_channels <= 2) { 35 if (number_of_channels <= 2) {
36 set_format_channels_ = number_of_channels; 36 set_format_channels_ = number_of_channels;
37 ChannelLayout channel_layout = 37 ChannelLayout channel_layout =
38 number_of_channels == 1 ? CHANNEL_LAYOUT_MONO : CHANNEL_LAYOUT_STEREO; 38 number_of_channels == 1 ? CHANNEL_LAYOUT_MONO : CHANNEL_LAYOUT_STEREO;
39 capturer_->SetCapturerSource(this, channel_layout, sample_rate); 39 capturer_->SetCapturerSource(this, channel_layout, sample_rate);
40 capturer_->Start();
41 } else { 40 } else {
42 // TODO(crogers): Handle more than just the mono and stereo cases. 41 // TODO(crogers): Handle more than just the mono and stereo cases.
43 LOG(WARNING) << "WebAudioCapturerSource::setFormat() : unhandled format."; 42 LOG(WARNING) << "WebAudioCapturerSource::setFormat() : unhandled format.";
44 } 43 }
45 } 44 }
46 45
47 void WebAudioCapturerSource::Initialize( 46 void WebAudioCapturerSource::Initialize(
48 const media::AudioParameters& params, 47 const media::AudioParameters& params,
49 media::AudioCapturerSource::CaptureCallback* callback, 48 media::AudioCapturerSource::CaptureCallback* callback,
50 int session_id) { 49 int session_id) {
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after
95 94
96 fifo_->Push(wrapper_bus_.get()); 95 fifo_->Push(wrapper_bus_.get());
97 int capture_frames = params_.frames_per_buffer(); 96 int capture_frames = params_.frames_per_buffer();
98 while (fifo_->frames() >= capture_frames) { 97 while (fifo_->frames() >= capture_frames) {
99 fifo_->Consume(capture_bus_.get(), 0, capture_frames); 98 fifo_->Consume(capture_bus_.get(), 0, capture_frames);
100 callback_->Capture(capture_bus_.get(), 0, 1.0); 99 callback_->Capture(capture_bus_.get(), 0, 1.0);
101 } 100 }
102 } 101 }
103 102
104 } // namespace content 103 } // namespace content
OLDNEW
« no previous file with comments | « content/renderer/media/mock_media_stream_dependency_factory.cc ('k') | content/renderer/media/webrtc_audio_capturer.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698