Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(250)

Side by Side Diff: content/renderer/media/audio_device_factory.cc

Issue 2043883005: Implementing AudioOutputDevice authorization timeout (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Dale's comments addressed: code simplified, comments fixed. Created 4 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « no previous file | media/audio/audio_output_device.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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>
8
7 #include "base/logging.h" 9 #include "base/logging.h"
10 #include "content/common/content_constants_internal.h"
8 #include "content/renderer/media/audio_input_message_filter.h" 11 #include "content/renderer/media/audio_input_message_filter.h"
9 #include "content/renderer/media/audio_message_filter.h" 12 #include "content/renderer/media/audio_message_filter.h"
10 #include "content/renderer/media/audio_renderer_mixer_manager.h" 13 #include "content/renderer/media/audio_renderer_mixer_manager.h"
11 #include "content/renderer/render_thread_impl.h" 14 #include "content/renderer/render_thread_impl.h"
12 #include "media/audio/audio_input_device.h" 15 #include "media/audio/audio_input_device.h"
13 #include "media/audio/audio_output_device.h" 16 #include "media/audio/audio_output_device.h"
14 #include "media/base/audio_renderer_mixer_input.h" 17 #include "media/base/audio_renderer_mixer_input.h"
15 #include "url/origin.h" 18 #include "url/origin.h"
16 19
17 namespace content { 20 namespace content {
18 21
19 // static 22 // static
20 AudioDeviceFactory* AudioDeviceFactory::factory_ = NULL; 23 AudioDeviceFactory* AudioDeviceFactory::factory_ = NULL;
21 24
22 namespace { 25 namespace {
26 const int64_t kMaxAuthorizationTimeoutMs = 4000;
23 27
24 scoped_refptr<media::AudioOutputDevice> NewOutputDevice( 28 scoped_refptr<media::AudioOutputDevice> NewOutputDevice(
25 int render_frame_id, 29 int render_frame_id,
26 int session_id, 30 int session_id,
27 const std::string& device_id, 31 const std::string& device_id,
28 const url::Origin& security_origin) { 32 const url::Origin& security_origin) {
29 AudioMessageFilter* const filter = AudioMessageFilter::Get(); 33 AudioMessageFilter* const filter = AudioMessageFilter::Get();
30 scoped_refptr<media::AudioOutputDevice> device(new media::AudioOutputDevice( 34 scoped_refptr<media::AudioOutputDevice> device(new media::AudioOutputDevice(
31 filter->CreateAudioOutputIPC(render_frame_id), filter->io_task_runner(), 35 filter->CreateAudioOutputIPC(render_frame_id), filter->io_task_runner(),
32 session_id, device_id, security_origin)); 36 session_id, device_id, security_origin,
37 // Set authorization request timeout at 80% of renderer hung timeout, but
38 // no more than kMaxAuthorizationTimeout.
39 base::TimeDelta::FromMilliseconds(std::min(kHungRendererDelayMs * 8 / 10,
40 kMaxAuthorizationTimeoutMs))));
33 device->RequestDeviceAuthorization(); 41 device->RequestDeviceAuthorization();
34 return device; 42 return device;
35 } 43 }
36 44
37 // This is where we decide which audio will go to mixers and which one to 45 // This is where we decide which audio will go to mixers and which one to
38 // AudioOutpuDevice directly. 46 // AudioOutpuDevice directly.
39 bool IsMixable(AudioDeviceFactory::SourceType source_type) { 47 bool IsMixable(AudioDeviceFactory::SourceType source_type) {
40 if (source_type == AudioDeviceFactory::kSourceMediaElement) 48 if (source_type == AudioDeviceFactory::kSourceMediaElement)
41 return true; // Must ALWAYS go through mixer. 49 return true; // Must ALWAYS go through mixer.
42 50
(...skipping 126 matching lines...) Expand 10 before | Expand all | Expand 10 after
169 device_id, security_origin); 177 device_id, security_origin);
170 if (sink) 178 if (sink)
171 return sink; 179 return sink;
172 } 180 }
173 181
174 return NewOutputDevice(render_frame_id, session_id, device_id, 182 return NewOutputDevice(render_frame_id, session_id, device_id,
175 security_origin); 183 security_origin);
176 } 184 }
177 185
178 } // namespace content 186 } // namespace content
OLDNEW
« no previous file with comments | « no previous file | media/audio/audio_output_device.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698