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 // Always set channels, this should be a no-op in all but the discrete case; |
| 141 // this call will fail if channels doesn't match the layout in other cases. |
| 142 sink_params_.set_channels_for_discrete(channels); |
138 | 143 |
139 // Specify the latency info to be passed to the browser side. | 144 // Specify the latency info to be passed to the browser side. |
140 sink_params_.set_latency_tag(latency); | 145 sink_params_.set_latency_tag(latency); |
141 } | 146 } |
142 | 147 |
143 RendererWebAudioDeviceImpl::~RendererWebAudioDeviceImpl() { | 148 RendererWebAudioDeviceImpl::~RendererWebAudioDeviceImpl() { |
144 DCHECK(!sink_); | 149 DCHECK(!sink_); |
145 } | 150 } |
146 | 151 |
147 void RendererWebAudioDeviceImpl::start() { | 152 void RendererWebAudioDeviceImpl::start() { |
(...skipping 77 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
225 const scoped_refptr<base::SingleThreadTaskRunner>& | 230 const scoped_refptr<base::SingleThreadTaskRunner>& |
226 RendererWebAudioDeviceImpl::GetMediaTaskRunner() { | 231 RendererWebAudioDeviceImpl::GetMediaTaskRunner() { |
227 if (!media_task_runner_) { | 232 if (!media_task_runner_) { |
228 media_task_runner_ = | 233 media_task_runner_ = |
229 RenderThreadImpl::current()->GetMediaThreadTaskRunner(); | 234 RenderThreadImpl::current()->GetMediaThreadTaskRunner(); |
230 } | 235 } |
231 return media_task_runner_; | 236 return media_task_runner_; |
232 } | 237 } |
233 | 238 |
234 } // namespace content | 239 } // namespace content |
OLD | NEW |