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/audio_device_factory.h" | 5 #include "content/renderer/media/audio_device_factory.h" |
6 | 6 |
7 #include <algorithm> | 7 #include <algorithm> |
8 #include <memory> | |
9 #include <utility> | |
8 | 10 |
9 #include "base/logging.h" | 11 #include "base/logging.h" |
10 #include "base/metrics/histogram_macros.h" | 12 #include "base/metrics/histogram_macros.h" |
11 #include "build/build_config.h" | 13 #include "build/build_config.h" |
12 #include "content/common/content_constants_internal.h" | 14 #include "content/common/content_constants_internal.h" |
15 #include "content/public/common/content_features.h" | |
o1ka
2017/05/11 10:58:40
Not needed?
Max Morin
2017/05/11 15:31:17
Done.
| |
13 #include "content/renderer/media/audio_input_message_filter.h" | 16 #include "content/renderer/media/audio_input_message_filter.h" |
17 #include "content/renderer/media/audio_ipc_factory.h" | |
14 #include "content/renderer/media/audio_message_filter.h" | 18 #include "content/renderer/media/audio_message_filter.h" |
15 #include "content/renderer/media/audio_renderer_mixer_manager.h" | 19 #include "content/renderer/media/audio_renderer_mixer_manager.h" |
16 #include "content/renderer/render_thread_impl.h" | 20 #include "content/renderer/render_thread_impl.h" |
17 #include "media/audio/audio_input_device.h" | 21 #include "media/audio/audio_input_device.h" |
18 #include "media/audio/audio_output_device.h" | 22 #include "media/audio/audio_output_device.h" |
19 #include "media/base/audio_renderer_mixer_input.h" | 23 #include "media/base/audio_renderer_mixer_input.h" |
20 #include "media/base/media_switches.h" | 24 #include "media/base/media_switches.h" |
21 #include "url/origin.h" | 25 #include "url/origin.h" |
22 | 26 |
23 namespace content { | 27 namespace content { |
(...skipping 12 matching lines...) Expand all Loading... | |
36 const int64_t kMaxAuthorizationTimeoutMs = 10000; | 40 const int64_t kMaxAuthorizationTimeoutMs = 10000; |
37 #else | 41 #else |
38 const int64_t kMaxAuthorizationTimeoutMs = 0; // No timeout. | 42 const int64_t kMaxAuthorizationTimeoutMs = 0; // No timeout. |
39 #endif | 43 #endif |
40 | 44 |
41 scoped_refptr<media::AudioOutputDevice> NewOutputDevice( | 45 scoped_refptr<media::AudioOutputDevice> NewOutputDevice( |
42 int render_frame_id, | 46 int render_frame_id, |
43 int session_id, | 47 int session_id, |
44 const std::string& device_id, | 48 const std::string& device_id, |
45 const url::Origin& security_origin) { | 49 const url::Origin& security_origin) { |
46 AudioMessageFilter* const filter = AudioMessageFilter::Get(); | 50 std::unique_ptr<media::AudioOutputIPC> ipc; |
47 scoped_refptr<media::AudioOutputDevice> device(new media::AudioOutputDevice( | 51 scoped_refptr<base::SingleThreadTaskRunner> io_task_runner; |
48 filter->CreateAudioOutputIPC(render_frame_id), filter->io_task_runner(), | 52 ipc = AudioIPCFactory::get()->CreateAudioOutputIPC(render_frame_id); |
49 session_id, device_id, security_origin, | 53 io_task_runner = AudioIPCFactory::get()->io_task_runner(); |
50 // Set authorization request timeout at 80% of renderer hung timeout, but | 54 scoped_refptr<media::AudioOutputDevice> device = new media::AudioOutputDevice( |
51 // no more than kMaxAuthorizationTimeout. | 55 std::move(ipc), io_task_runner, session_id, device_id, security_origin, |
o1ka
2017/05/11 10:58:40
std::move(io_task_runner)?
Max Morin
2017/05/11 15:31:17
Done.
| |
52 base::TimeDelta::FromMilliseconds(std::min(kHungRendererDelayMs * 8 / 10, | 56 // Set authorization request timeout at 80% of renderer hung timeout, |
53 kMaxAuthorizationTimeoutMs)))); | 57 // but no more than kMaxAuthorizationTimeout. |
58 base::TimeDelta::FromMilliseconds( | |
59 std::min(kHungRendererDelayMs * 8 / 10, kMaxAuthorizationTimeoutMs))); | |
54 device->RequestDeviceAuthorization(); | 60 device->RequestDeviceAuthorization(); |
55 return device; | 61 return device; |
56 } | 62 } |
57 | 63 |
58 // This is where we decide which audio will go to mixers and which one to | 64 // This is where we decide which audio will go to mixers and which one to |
59 // AudioOutpuDevice directly. | 65 // AudioOutpuDevice directly. |
60 bool IsMixable(AudioDeviceFactory::SourceType source_type) { | 66 bool IsMixable(AudioDeviceFactory::SourceType source_type) { |
61 if (source_type == AudioDeviceFactory::kSourceMediaElement) | 67 if (source_type == AudioDeviceFactory::kSourceMediaElement) |
62 return true; // Must ALWAYS go through mixer. | 68 return true; // Must ALWAYS go through mixer. |
63 | 69 |
(...skipping 151 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
215 device_id, security_origin); | 221 device_id, security_origin); |
216 if (sink) | 222 if (sink) |
217 return sink; | 223 return sink; |
218 } | 224 } |
219 | 225 |
220 return NewOutputDevice(render_frame_id, session_id, device_id, | 226 return NewOutputDevice(render_frame_id, session_id, device_id, |
221 security_origin); | 227 security_origin); |
222 } | 228 } |
223 | 229 |
224 } // namespace content | 230 } // namespace content |
OLD | NEW |