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 | 8 |
9 #include "base/logging.h" | 9 #include "base/logging.h" |
10 #include "base/metrics/histogram_macros.h" | 10 #include "base/metrics/histogram_macros.h" |
11 #include "build/build_config.h" | 11 #include "build/build_config.h" |
12 #include "content/common/content_constants_internal.h" | 12 #include "content/common/content_constants_internal.h" |
13 #include "content/renderer/media/audio_input_message_filter.h" | 13 #include "content/renderer/media/audio_input_message_filter.h" |
14 #include "content/renderer/media/audio_message_filter.h" | 14 #include "content/renderer/media/audio_output_ipc_factory.h" |
15 #include "content/renderer/media/audio_renderer_mixer_manager.h" | 15 #include "content/renderer/media/audio_renderer_mixer_manager.h" |
16 #include "content/renderer/render_thread_impl.h" | 16 #include "content/renderer/render_thread_impl.h" |
17 #include "media/audio/audio_input_device.h" | 17 #include "media/audio/audio_input_device.h" |
18 #include "media/audio/audio_output_device.h" | 18 #include "media/audio/audio_output_device.h" |
19 #include "media/base/audio_renderer_mixer_input.h" | 19 #include "media/base/audio_renderer_mixer_input.h" |
20 #include "media/base/media_switches.h" | 20 #include "media/base/media_switches.h" |
21 #include "media/media_features.h" | |
Henrik Grunell
2016/09/01 15:09:07
Needed?
| |
21 #include "url/origin.h" | 22 #include "url/origin.h" |
22 | 23 |
23 namespace content { | 24 namespace content { |
24 | 25 |
25 // static | 26 // static |
26 AudioDeviceFactory* AudioDeviceFactory::factory_ = NULL; | 27 AudioDeviceFactory* AudioDeviceFactory::factory_ = NULL; |
27 | 28 |
28 namespace { | 29 namespace { |
29 #if defined(OS_WIN) | 30 #if defined(OS_WIN) |
30 // Due to driver deadlock issues on Windows (http://crbug/422522) there is a | 31 // Due to driver deadlock issues on Windows (http://crbug/422522) there is a |
31 // chance device authorization response is never received from the browser side. | 32 // chance device authorization response is never received from the browser side. |
32 // In this case we will time out, to avoid renderer hang forever waiting for | 33 // In this case we will time out, to avoid renderer hang forever waiting for |
33 // device authorization (http://crbug/615589). This will result in "no audio". | 34 // device authorization (http://crbug/615589). This will result in "no audio". |
34 const int64_t kMaxAuthorizationTimeoutMs = 1000; | 35 const int64_t kMaxAuthorizationTimeoutMs = 1000; |
35 #else | 36 #else |
36 const int64_t kMaxAuthorizationTimeoutMs = 0; // No timeout. | 37 const int64_t kMaxAuthorizationTimeoutMs = 0; // No timeout. |
37 #endif // defined(OS_WIN) | 38 #endif // defined(OS_WIN) |
38 | 39 |
39 scoped_refptr<media::AudioOutputDevice> NewOutputDevice( | 40 scoped_refptr<media::AudioOutputDevice> NewOutputDevice( |
40 int render_frame_id, | 41 int render_frame_id, |
41 int session_id, | 42 int session_id, |
42 const std::string& device_id, | 43 const std::string& device_id, |
43 const url::Origin& security_origin) { | 44 const url::Origin& security_origin) { |
44 AudioMessageFilter* const filter = AudioMessageFilter::Get(); | 45 const scoped_refptr<AudioOutputIPCFactory> factory = |
46 AudioOutputIPCFactory::Get(); | |
45 scoped_refptr<media::AudioOutputDevice> device(new media::AudioOutputDevice( | 47 scoped_refptr<media::AudioOutputDevice> device(new media::AudioOutputDevice( |
46 filter->CreateAudioOutputIPC(render_frame_id), filter->io_task_runner(), | 48 factory->CreateAudioOutputIPC(render_frame_id), factory->io_task_runner(), |
Henrik Grunell
2016/09/01 15:09:07
Could AudioOutputDevice access the stream directly
| |
47 session_id, device_id, security_origin, | 49 session_id, device_id, security_origin, |
48 // Set authorization request timeout at 80% of renderer hung timeout, but | 50 // Set authorization request timeout at 80% of renderer hung timeout, but |
49 // no more than kMaxAuthorizationTimeout. | 51 // no more than kMaxAuthorizationTimeout. |
50 base::TimeDelta::FromMilliseconds(std::min(kHungRendererDelayMs * 8 / 10, | 52 base::TimeDelta::FromMilliseconds(std::min(kHungRendererDelayMs * 8 / 10, |
51 kMaxAuthorizationTimeoutMs)))); | 53 kMaxAuthorizationTimeoutMs)))); |
52 device->RequestDeviceAuthorization(); | 54 device->RequestDeviceAuthorization(); |
53 return device; | 55 return device; |
54 } | 56 } |
55 | 57 |
56 // This is where we decide which audio will go to mixers and which one to | 58 // This is where we decide which audio will go to mixers and which one to |
(...skipping 154 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
211 device_id, security_origin); | 213 device_id, security_origin); |
212 if (sink) | 214 if (sink) |
213 return sink; | 215 return sink; |
214 } | 216 } |
215 | 217 |
216 return NewOutputDevice(render_frame_id, session_id, device_id, | 218 return NewOutputDevice(render_frame_id, session_id, device_id, |
217 security_origin); | 219 security_origin); |
218 } | 220 } |
219 | 221 |
220 } // namespace content | 222 } // namespace content |
OLD | NEW |