| 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_renderer.h" | 5 #include "content/renderer/media/webrtc_audio_renderer.h" |
| 6 | 6 |
| 7 #include "base/logging.h" | 7 #include "base/logging.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 "content/renderer/media/audio_device_factory.h" | 10 #include "content/renderer/media/audio_device_factory.h" |
| 11 #include "content/renderer/media/audio_hardware.h" | 11 #include "content/renderer/media/audio_hardware.h" |
| 12 #include "content/renderer/media/renderer_audio_output_device.h" |
| 12 #include "content/renderer/media/webrtc_audio_device_impl.h" | 13 #include "content/renderer/media/webrtc_audio_device_impl.h" |
| 13 #include "media/audio/audio_util.h" | 14 #include "media/audio/audio_util.h" |
| 14 #include "media/audio/sample_rates.h" | 15 #include "media/audio/sample_rates.h" |
| 15 #if defined(OS_WIN) | 16 #if defined(OS_WIN) |
| 16 #include "media/audio/win/core_audio_util_win.h" | 17 #include "media/audio/win/core_audio_util_win.h" |
| 17 #endif | 18 #endif |
| 18 | 19 |
| 19 namespace content { | 20 namespace content { |
| 20 | 21 |
| 21 namespace { | 22 namespace { |
| (...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 73 UMA_HISTOGRAM_ENUMERATION("WebRTC.AudioOutputFramesPerBuffer", | 74 UMA_HISTOGRAM_ENUMERATION("WebRTC.AudioOutputFramesPerBuffer", |
| 74 afpb, kUnexpectedAudioBufferSize); | 75 afpb, kUnexpectedAudioBufferSize); |
| 75 } else { | 76 } else { |
| 76 // Report unexpected sample rates using a unique histogram name. | 77 // Report unexpected sample rates using a unique histogram name. |
| 77 UMA_HISTOGRAM_COUNTS("WebRTC.AudioOutputFramesPerBufferUnexpected", param); | 78 UMA_HISTOGRAM_COUNTS("WebRTC.AudioOutputFramesPerBufferUnexpected", param); |
| 78 } | 79 } |
| 79 } | 80 } |
| 80 | 81 |
| 81 } // namespace | 82 } // namespace |
| 82 | 83 |
| 83 WebRtcAudioRenderer::WebRtcAudioRenderer() | 84 WebRtcAudioRenderer::WebRtcAudioRenderer(int source_render_view_id) |
| 84 : state_(UNINITIALIZED), | 85 : state_(UNINITIALIZED), |
| 86 source_render_view_id_(source_render_view_id), |
| 85 source_(NULL) { | 87 source_(NULL) { |
| 86 } | 88 } |
| 87 | 89 |
| 88 WebRtcAudioRenderer::~WebRtcAudioRenderer() { | 90 WebRtcAudioRenderer::~WebRtcAudioRenderer() { |
| 89 DCHECK_EQ(state_, UNINITIALIZED); | 91 DCHECK_EQ(state_, UNINITIALIZED); |
| 90 buffer_.reset(); | 92 buffer_.reset(); |
| 91 } | 93 } |
| 92 | 94 |
| 93 bool WebRtcAudioRenderer::Initialize(WebRtcAudioRendererSource* source) { | 95 bool WebRtcAudioRenderer::Initialize(WebRtcAudioRendererSource* source) { |
| 94 base::AutoLock auto_lock(lock_); | 96 base::AutoLock auto_lock(lock_); |
| (...skipping 89 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 184 // It is assumed that each audio sample contains 16 bits and each | 186 // It is assumed that each audio sample contains 16 bits and each |
| 185 // audio frame contains one or two audio samples depending on the | 187 // audio frame contains one or two audio samples depending on the |
| 186 // number of channels. | 188 // number of channels. |
| 187 buffer_.reset(new int16[params_.frames_per_buffer() * params_.channels()]); | 189 buffer_.reset(new int16[params_.frames_per_buffer() * params_.channels()]); |
| 188 | 190 |
| 189 source_ = source; | 191 source_ = source; |
| 190 source->SetRenderFormat(params_); | 192 source->SetRenderFormat(params_); |
| 191 | 193 |
| 192 // Configure the audio rendering client and start the rendering. | 194 // Configure the audio rendering client and start the rendering. |
| 193 sink_->Initialize(params_, this); | 195 sink_->Initialize(params_, this); |
| 194 | 196 sink_->SetSourceRenderView(source_render_view_id_); |
| 195 sink_->Start(); | 197 sink_->Start(); |
| 196 | 198 |
| 197 state_ = PAUSED; | 199 state_ = PAUSED; |
| 198 | 200 |
| 199 UMA_HISTOGRAM_ENUMERATION("WebRTC.AudioOutputChannelLayout", | 201 UMA_HISTOGRAM_ENUMERATION("WebRTC.AudioOutputChannelLayout", |
| 200 channel_layout, media::CHANNEL_LAYOUT_MAX); | 202 channel_layout, media::CHANNEL_LAYOUT_MAX); |
| 201 UMA_HISTOGRAM_ENUMERATION("WebRTC.AudioOutputFramesPerBuffer", | 203 UMA_HISTOGRAM_ENUMERATION("WebRTC.AudioOutputFramesPerBuffer", |
| 202 buffer_size, kUnexpectedAudioBufferSize); | 204 buffer_size, kUnexpectedAudioBufferSize); |
| 203 AddHistogramFramesPerBuffer(buffer_size); | 205 AddHistogramFramesPerBuffer(buffer_size); |
| 204 | 206 |
| (...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 263 params_.bits_per_sample() / 8); | 265 params_.bits_per_sample() / 8); |
| 264 return audio_bus->frames(); | 266 return audio_bus->frames(); |
| 265 } | 267 } |
| 266 | 268 |
| 267 void WebRtcAudioRenderer::OnRenderError() { | 269 void WebRtcAudioRenderer::OnRenderError() { |
| 268 NOTIMPLEMENTED(); | 270 NOTIMPLEMENTED(); |
| 269 LOG(ERROR) << "OnRenderError()"; | 271 LOG(ERROR) << "OnRenderError()"; |
| 270 } | 272 } |
| 271 | 273 |
| 272 } // namespace content | 274 } // namespace content |
| OLD | NEW |