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

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

Issue 10790121: First step towards moving AudioDevice from content/ to media/audio. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Update comments after closing ppapi bug Created 8 years, 5 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/webrtc_audio_device_impl.h" 5 #include "content/renderer/media/webrtc_audio_device_impl.h"
6 6
7 #include "base/bind.h" 7 #include "base/bind.h"
8 #include "base/metrics/histogram.h" 8 #include "base/metrics/histogram.h"
9 #include "base/string_util.h" 9 #include "base/string_util.h"
10 #include "base/win/windows_version.h" 10 #include "base/win/windows_version.h"
(...skipping 129 matching lines...) Expand 10 before | Expand all | Expand 10 after
140 bytes_per_sample_(0), 140 bytes_per_sample_(0),
141 initialized_(false), 141 initialized_(false),
142 playing_(false), 142 playing_(false),
143 recording_(false), 143 recording_(false),
144 agc_is_enabled_(false) { 144 agc_is_enabled_(false) {
145 DVLOG(1) << "WebRtcAudioDeviceImpl::WebRtcAudioDeviceImpl()"; 145 DVLOG(1) << "WebRtcAudioDeviceImpl::WebRtcAudioDeviceImpl()";
146 // TODO(henrika): remove this restriction when factory is used for the 146 // TODO(henrika): remove this restriction when factory is used for the
147 // input side as well. 147 // input side as well.
148 DCHECK(RenderThreadImpl::current()) << 148 DCHECK(RenderThreadImpl::current()) <<
149 "WebRtcAudioDeviceImpl must be constructed on the render thread"; 149 "WebRtcAudioDeviceImpl must be constructed on the render thread";
150 audio_output_device_ = AudioDeviceFactory::Create(); 150 audio_output_device_ = AudioDeviceFactory::NewOutputDevice();
151 DCHECK(audio_output_device_); 151 DCHECK(audio_output_device_);
152 } 152 }
153 153
154 WebRtcAudioDeviceImpl::~WebRtcAudioDeviceImpl() { 154 WebRtcAudioDeviceImpl::~WebRtcAudioDeviceImpl() {
155 DVLOG(1) << "WebRtcAudioDeviceImpl::~WebRtcAudioDeviceImpl()"; 155 DVLOG(1) << "WebRtcAudioDeviceImpl::~WebRtcAudioDeviceImpl()";
156 if (playing_) 156 if (playing_)
157 StopPlayout(); 157 StopPlayout();
158 if (recording_) 158 if (recording_)
159 StopRecording(); 159 StopRecording();
160 if (initialized_) 160 if (initialized_)
(...skipping 230 matching lines...) Expand 10 before | Expand all | Expand 10 after
391 LOG(ERROR) << "Unable to (de)register transport during active media"; 391 LOG(ERROR) << "Unable to (de)register transport during active media";
392 return -1; 392 return -1;
393 } 393 }
394 audio_transport_callback_ = audio_callback; 394 audio_transport_callback_ = audio_callback;
395 return 0; 395 return 0;
396 } 396 }
397 397
398 int32_t WebRtcAudioDeviceImpl::Init() { 398 int32_t WebRtcAudioDeviceImpl::Init() {
399 DVLOG(1) << "Init()"; 399 DVLOG(1) << "Init()";
400 400
401 // TODO(henrika): After switching to using the AudioDeviceFactory for
402 // instantiating the input device, maybe this isn't a requirement anymore?
401 if (!render_loop_->BelongsToCurrentThread()) { 403 if (!render_loop_->BelongsToCurrentThread()) {
402 int32_t error = 0; 404 int32_t error = 0;
403 base::WaitableEvent event(false, false); 405 base::WaitableEvent event(false, false);
404 // Ensure that we call Init() from the main render thread since 406 // Ensure that we call Init() from the main render thread since
405 // the audio clients can only be created on this thread. 407 // the audio clients can only be created on this thread.
406 render_loop_->PostTask( 408 render_loop_->PostTask(
407 FROM_HERE, 409 FROM_HERE,
408 base::Bind(&WebRtcAudioDeviceImpl::InitOnRenderThread, 410 base::Bind(&WebRtcAudioDeviceImpl::InitOnRenderThread,
409 this, &error, &event)); 411 this, &error, &event));
410 event.Wait(); 412 event.Wait();
(...skipping 160 matching lines...) Expand 10 before | Expand all | Expand 10 after
571 // after a successful initialization. 573 // after a successful initialization.
572 output_audio_parameters_.Reset( 574 output_audio_parameters_.Reset(
573 AudioParameters::AUDIO_PCM_LOW_LATENCY, out_channel_layout, 575 AudioParameters::AUDIO_PCM_LOW_LATENCY, out_channel_layout,
574 out_sample_rate, 16, out_buffer_size); 576 out_sample_rate, 16, out_buffer_size);
575 577
576 input_audio_parameters_.Reset( 578 input_audio_parameters_.Reset(
577 in_format, in_channel_layout, in_sample_rate, 579 in_format, in_channel_layout, in_sample_rate,
578 16, in_buffer_size); 580 16, in_buffer_size);
579 581
580 // Create and configure the audio capturing client. 582 // Create and configure the audio capturing client.
581 audio_input_device_ = new AudioInputDevice( 583 audio_input_device_ = AudioDeviceFactory::NewInputDevice();
582 input_audio_parameters_, this, this); 584 audio_input_device_->Initialize(input_audio_parameters_, this, this);
583 585
584 UMA_HISTOGRAM_ENUMERATION("WebRTC.AudioOutputChannelLayout", 586 UMA_HISTOGRAM_ENUMERATION("WebRTC.AudioOutputChannelLayout",
585 out_channel_layout, CHANNEL_LAYOUT_MAX); 587 out_channel_layout, CHANNEL_LAYOUT_MAX);
586 UMA_HISTOGRAM_ENUMERATION("WebRTC.AudioInputChannelLayout", 588 UMA_HISTOGRAM_ENUMERATION("WebRTC.AudioInputChannelLayout",
587 in_channel_layout, CHANNEL_LAYOUT_MAX); 589 in_channel_layout, CHANNEL_LAYOUT_MAX);
588 AddHistogramFramesPerBuffer(kAudioOutput, out_buffer_size); 590 AddHistogramFramesPerBuffer(kAudioOutput, out_buffer_size);
589 AddHistogramFramesPerBuffer(kAudioInput, in_buffer_size); 591 AddHistogramFramesPerBuffer(kAudioInput, in_buffer_size);
590 592
591 // Configure the audio rendering client. 593 // Configure the audio rendering client.
592 audio_output_device_->Initialize(output_audio_parameters_, this); 594 audio_output_device_->Initialize(output_audio_parameters_, this);
(...skipping 572 matching lines...) Expand 10 before | Expand all | Expand 10 after
1165 } 1167 }
1166 1168
1167 int32_t WebRtcAudioDeviceImpl::GetLoudspeakerStatus(bool* enabled) const { 1169 int32_t WebRtcAudioDeviceImpl::GetLoudspeakerStatus(bool* enabled) const {
1168 NOTIMPLEMENTED(); 1170 NOTIMPLEMENTED();
1169 return -1; 1171 return -1;
1170 } 1172 }
1171 1173
1172 void WebRtcAudioDeviceImpl::SetSessionId(int session_id) { 1174 void WebRtcAudioDeviceImpl::SetSessionId(int session_id) {
1173 session_id_ = session_id; 1175 session_id_ = session_id;
1174 } 1176 }
OLDNEW
« no previous file with comments | « content/renderer/media/renderer_webaudiodevice_impl.cc ('k') | content/renderer/pepper/pepper_platform_audio_input_impl.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698