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

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

Issue 2908073002: Make OS audio buffer size limits visible. (Closed)
Patch Set: Move all buffer size calculations to AudioLatency. Created 3 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
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/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 47 matching lines...) Expand 10 before | Expand all | Expand 10 after
58 break; 58 break;
59 case media::AudioLatency::LATENCY_RTC: 59 case media::AudioLatency::LATENCY_RTC:
60 return media::AudioLatency::GetRtcBufferSize( 60 return media::AudioLatency::GetRtcBufferSize(
61 hardware_params.sample_rate(), hardware_params.frames_per_buffer()); 61 hardware_params.sample_rate(), hardware_params.frames_per_buffer());
62 break; 62 break;
63 case media::AudioLatency::LATENCY_PLAYBACK: 63 case media::AudioLatency::LATENCY_PLAYBACK:
64 return media::AudioLatency::GetHighLatencyBufferSize( 64 return media::AudioLatency::GetHighLatencyBufferSize(
65 hardware_params.sample_rate(), 0); 65 hardware_params.sample_rate(), 0);
66 break; 66 break;
67 case media::AudioLatency::LATENCY_EXACT_MS: 67 case media::AudioLatency::LATENCY_EXACT_MS:
68 // TODO(andrew.macpherson@soundtrap.com): http://crbug.com/708917 68 return std::min(media::AudioLatency::GetMaximumAudioBufferSize(
69 return std::min(4096, 69 hardware_params.sample_rate()),
Raymond Toy 2017/05/30 18:05:57 Can't remember the actual value, but make this con
70 media::AudioLatency::GetExactBufferSize( 70 media::AudioLatency::GetExactBufferSize(
71 base::TimeDelta::FromSecondsD(latency_hint.Seconds()), 71 base::TimeDelta::FromSecondsD(latency_hint.Seconds()),
72 hardware_params.sample_rate(), 72 hardware_params.sample_rate(),
73 hardware_params.frames_per_buffer())); 73 media::AudioLatency::GetMinimumAudioBufferSize(
74 hardware_params.sample_rate())));
74 break; 75 break;
75 default: 76 default:
76 NOTREACHED(); 77 NOTREACHED();
77 } 78 }
78 return 0; 79 return 0;
79 } 80 }
80 81
81 int FrameIdFromCurrentContext() { 82 int FrameIdFromCurrentContext() {
82 // Assumption: This method is being invoked within a V8 call stack. CHECKs 83 // Assumption: This method is being invoked within a V8 call stack. CHECKs
83 // will fail in the call to frameForCurrentContext() otherwise. 84 // will fail in the call to frameForCurrentContext() otherwise.
(...skipping 157 matching lines...) Expand 10 before | Expand all | Expand 10 after
241 const scoped_refptr<base::SingleThreadTaskRunner>& 242 const scoped_refptr<base::SingleThreadTaskRunner>&
242 RendererWebAudioDeviceImpl::GetMediaTaskRunner() { 243 RendererWebAudioDeviceImpl::GetMediaTaskRunner() {
243 if (!media_task_runner_) { 244 if (!media_task_runner_) {
244 media_task_runner_ = 245 media_task_runner_ =
245 RenderThreadImpl::current()->GetMediaThreadTaskRunner(); 246 RenderThreadImpl::current()->GetMediaThreadTaskRunner();
246 } 247 }
247 return media_task_runner_; 248 return media_task_runner_;
248 } 249 }
249 250
250 } // namespace content 251 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698