Chromium Code Reviews| 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/renderer_webaudiodevice_impl.h" | 5 #include "content/renderer/media/renderer_webaudiodevice_impl.h" |
| 6 | 6 |
| 7 #include <stddef.h> | 7 #include <stddef.h> |
| 8 | 8 |
| 9 #include <string> | 9 #include <string> |
| 10 | 10 |
| (...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 69 const url::Origin& security_origin) { | 69 const url::Origin& security_origin) { |
| 70 return AudioDeviceFactory::GetOutputDeviceInfo(frame_id, session_id, | 70 return AudioDeviceFactory::GetOutputDeviceInfo(frame_id, session_id, |
| 71 device_id, security_origin) | 71 device_id, security_origin) |
| 72 .output_params(); | 72 .output_params(); |
| 73 } | 73 } |
| 74 | 74 |
| 75 } // namespace | 75 } // namespace |
| 76 | 76 |
| 77 RendererWebAudioDeviceImpl* RendererWebAudioDeviceImpl::Create( | 77 RendererWebAudioDeviceImpl* RendererWebAudioDeviceImpl::Create( |
| 78 media::ChannelLayout layout, | 78 media::ChannelLayout layout, |
| 79 int channels, | |
| 79 const blink::WebAudioLatencyHint& latency_hint, | 80 const blink::WebAudioLatencyHint& latency_hint, |
| 80 WebAudioDevice::RenderCallback* callback, | 81 WebAudioDevice::RenderCallback* callback, |
| 81 int session_id, | 82 int session_id, |
| 82 const url::Origin& security_origin) { | 83 const url::Origin& security_origin) { |
| 83 return new RendererWebAudioDeviceImpl(layout, latency_hint, callback, | 84 return new RendererWebAudioDeviceImpl(layout, channels, latency_hint, |
| 84 session_id, security_origin, | 85 callback, session_id, security_origin, |
| 85 base::Bind(&GetOutputDeviceParameters), | 86 base::Bind(&GetOutputDeviceParameters), |
| 86 base::Bind(&FrameIdFromCurrentContext)); | 87 base::Bind(&FrameIdFromCurrentContext)); |
| 87 } | 88 } |
| 88 | 89 |
| 89 RendererWebAudioDeviceImpl::RendererWebAudioDeviceImpl( | 90 RendererWebAudioDeviceImpl::RendererWebAudioDeviceImpl( |
| 90 media::ChannelLayout layout, | 91 media::ChannelLayout layout, |
| 92 int channels, | |
| 91 const blink::WebAudioLatencyHint& latency_hint, | 93 const blink::WebAudioLatencyHint& latency_hint, |
| 92 WebAudioDevice::RenderCallback* callback, | 94 WebAudioDevice::RenderCallback* callback, |
| 93 int session_id, | 95 int session_id, |
| 94 const url::Origin& security_origin, | 96 const url::Origin& security_origin, |
| 95 const OutputDeviceParamsCallback& device_params_cb, | 97 const OutputDeviceParamsCallback& device_params_cb, |
| 96 const RenderFrameIdCallback& render_frame_id_cb) | 98 const RenderFrameIdCallback& render_frame_id_cb) |
| 97 : latency_hint_(latency_hint), | 99 : latency_hint_(latency_hint), |
| 98 client_callback_(callback), | 100 client_callback_(callback), |
| 99 session_id_(session_id), | 101 session_id_(session_id), |
| 100 security_origin_(security_origin), | 102 security_origin_(security_origin), |
| (...skipping 27 matching lines...) Expand all Loading... | |
| 128 case media::AudioLatency::LATENCY_EXACT_MS: | 130 case media::AudioLatency::LATENCY_EXACT_MS: |
| 129 // TODO(olka): add support when WebAudio requires it. | 131 // TODO(olka): add support when WebAudio requires it. |
| 130 default: | 132 default: |
| 131 NOTREACHED(); | 133 NOTREACHED(); |
| 132 } | 134 } |
| 133 | 135 |
| 134 DCHECK_NE(output_buffer_size, 0); | 136 DCHECK_NE(output_buffer_size, 0); |
| 135 | 137 |
| 136 sink_params_.Reset(media::AudioParameters::AUDIO_PCM_LOW_LATENCY, layout, | 138 sink_params_.Reset(media::AudioParameters::AUDIO_PCM_LOW_LATENCY, layout, |
| 137 hardware_params.sample_rate(), 16, output_buffer_size); | 139 hardware_params.sample_rate(), 16, output_buffer_size); |
| 140 sink_params_.set_channels_for_discrete(channels); | |
|
hongchan
2017/02/23 18:43:37
Can we add a comment why this is necessary here? W
DaleCurtis
2017/02/23 20:06:07
Done.
| |
| 138 | 141 |
| 139 // Specify the latency info to be passed to the browser side. | 142 // Specify the latency info to be passed to the browser side. |
| 140 sink_params_.set_latency_tag(latency); | 143 sink_params_.set_latency_tag(latency); |
| 141 } | 144 } |
| 142 | 145 |
| 143 RendererWebAudioDeviceImpl::~RendererWebAudioDeviceImpl() { | 146 RendererWebAudioDeviceImpl::~RendererWebAudioDeviceImpl() { |
| 144 DCHECK(!sink_); | 147 DCHECK(!sink_); |
| 145 } | 148 } |
| 146 | 149 |
| 147 void RendererWebAudioDeviceImpl::start() { | 150 void RendererWebAudioDeviceImpl::start() { |
| (...skipping 77 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 225 const scoped_refptr<base::SingleThreadTaskRunner>& | 228 const scoped_refptr<base::SingleThreadTaskRunner>& |
| 226 RendererWebAudioDeviceImpl::GetMediaTaskRunner() { | 229 RendererWebAudioDeviceImpl::GetMediaTaskRunner() { |
| 227 if (!media_task_runner_) { | 230 if (!media_task_runner_) { |
| 228 media_task_runner_ = | 231 media_task_runner_ = |
| 229 RenderThreadImpl::current()->GetMediaThreadTaskRunner(); | 232 RenderThreadImpl::current()->GetMediaThreadTaskRunner(); |
| 230 } | 233 } |
| 231 return media_task_runner_; | 234 return media_task_runner_; |
| 232 } | 235 } |
| 233 | 236 |
| 234 } // namespace content | 237 } // namespace content |
| OLD | NEW |