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

Unified Diff: content/renderer/media/renderer_webaudiodevice_impl.cc

Issue 2750543003: Support AudioContextOptions latencyHint as double. (Closed)
Patch Set: Fix audiocontextoptions LayoutTest. Created 3 years, 9 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 side-by-side diff with in-line comments
Download patch
Index: content/renderer/media/renderer_webaudiodevice_impl.cc
diff --git a/content/renderer/media/renderer_webaudiodevice_impl.cc b/content/renderer/media/renderer_webaudiodevice_impl.cc
index 2c4f81b185d74fe96ab0a25d677a67fd0d3d9296..8eb0b240b9004af852bd3ff0874a69f4118f8d79 100644
--- a/content/renderer/media/renderer_webaudiodevice_impl.cc
+++ b/content/renderer/media/renderer_webaudiodevice_impl.cc
@@ -41,13 +41,39 @@ AudioDeviceFactory::SourceType GetLatencyHintSourceType(
case WebAudioLatencyHint::kCategoryPlayback:
return AudioDeviceFactory::kSourceWebAudioPlayback;
case WebAudioLatencyHint::kCategoryExact:
- // TODO implement CategoryExact
- return AudioDeviceFactory::kSourceWebAudioInteractive;
+ return AudioDeviceFactory::kSourceWebAudioExact;
}
NOTREACHED();
return AudioDeviceFactory::kSourceWebAudioInteractive;
}
+int GetOutputBufferSize(const blink::WebAudioLatencyHint& latency_hint,
+ const media::AudioLatency::LatencyType latency,
+ const media::AudioParameters& hardware_params) {
+ // Adjust output buffer size according to the latency requirement.
+ switch (latency) {
+ case media::AudioLatency::LATENCY_INTERACTIVE:
+ return media::AudioLatency::GetInteractiveBufferSize(
+ hardware_params.frames_per_buffer());
+ break;
+ case media::AudioLatency::LATENCY_RTC:
+ return media::AudioLatency::GetRtcBufferSize(
+ hardware_params.sample_rate(), hardware_params.frames_per_buffer());
+ break;
+ case media::AudioLatency::LATENCY_PLAYBACK:
+ return media::AudioLatency::GetHighLatencyBufferSize(
DaleCurtis 2017/03/28 17:34:07 I wonder if we should just replace this with GetEx
Andrew MacPherson 2017/03/29 08:34:09 Sounds good!
+ hardware_params.sample_rate(), 0);
+ break;
+ case media::AudioLatency::LATENCY_EXACT_MS:
+ return media::AudioLatency::GetExactBufferSize(latency_hint.seconds(),
+ hardware_params);
+ break;
+ default:
+ NOTREACHED();
+ }
+ return 0;
+}
+
int FrameIdFromCurrentContext() {
// Assumption: This method is being invoked within a V8 call stack. CHECKs
// will fail in the call to frameForCurrentContext() otherwise.
@@ -107,32 +133,11 @@ RendererWebAudioDeviceImpl::RendererWebAudioDeviceImpl(
media::AudioParameters hardware_params(device_params_cb.Run(
frame_id_, session_id_, std::string(), security_origin_));
- int output_buffer_size = 0;
-
media::AudioLatency::LatencyType latency =
AudioDeviceFactory::GetSourceLatencyType(
- GetLatencyHintSourceType(latency_hint_.category()));
-
- // Adjust output buffer size according to the latency requirement.
- switch (latency) {
- case media::AudioLatency::LATENCY_INTERACTIVE:
- output_buffer_size = media::AudioLatency::GetInteractiveBufferSize(
- hardware_params.frames_per_buffer());
- break;
- case media::AudioLatency::LATENCY_RTC:
- output_buffer_size = media::AudioLatency::GetRtcBufferSize(
- hardware_params.sample_rate(), hardware_params.frames_per_buffer());
- break;
- case media::AudioLatency::LATENCY_PLAYBACK:
- output_buffer_size = media::AudioLatency::GetHighLatencyBufferSize(
- hardware_params.sample_rate(), 0);
- break;
- case media::AudioLatency::LATENCY_EXACT_MS:
- // TODO(olka): add support when WebAudio requires it.
- default:
- NOTREACHED();
- }
-
+ GetLatencyHintSourceType(latency_hint.category()));
+ int output_buffer_size =
+ GetOutputBufferSize(latency_hint_, latency, hardware_params);
DCHECK_NE(output_buffer_size, 0);
sink_params_.Reset(media::AudioParameters::AUDIO_PCM_LOW_LATENCY, layout,

Powered by Google App Engine
This is Rietveld 408576698