From 6af51aaeacf65922b93d5994fc3ee9600ab3deb6 Mon Sep 17 00:00:00 2001 From: Andrew MacPherson Date: Tue, 26 Mar 2019 13:54:45 +0000 Subject: [PATCH] Bug 1532151 [wpt PR 15520] - Add support for AudioContextOptions sampleRate, a=testonly Automatic update from web-platform-tests Add support for AudioContextOptions sampleRate Optional sampleRate parameter to AudioContextOptions, if provided then the AudioContext will run at this sampleRate, otherwise it will run at the hardware rate. Running the AudioContext at a lower sample rate can allow running a heavier graph on low-end devices, for example if a given device is able to run with X nodes at a sample rate of 48k, it can support roughly 2X nodes at 24k or 4X nodes at 12k. Bug: 432248 Change-Id: I835f28b4625763bd6a6ddbee9b89636ef8a8a066 Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1482957 Reviewed-by: Kent Tamura Reviewed-by: Raymond Toy Reviewed-by: Hongchan Choi Commit-Queue: Andrew MacPherson Cr-Commit-Position: refs/heads/master@{#638498} -- wpt-commits: 9b994b36003246370b352fa70c563866a8443e4e wpt-pr: 15520 --- .../audiocontextoptions.html | 39 +++++++++++++++++++ 1 file changed, 39 insertions(+) diff --git a/testing/web-platform/tests/webaudio/the-audio-api/the-audiocontext-interface/audiocontextoptions.html b/testing/web-platform/tests/webaudio/the-audio-api/the-audiocontext-interface/audiocontextoptions.html index 3a11074a41c0..bee1aa835bf6 100644 --- a/testing/web-platform/tests/webaudio/the-audio-api/the-audiocontext-interface/audiocontextoptions.html +++ b/testing/web-platform/tests/webaudio/the-audio-api/the-audiocontext-interface/audiocontextoptions.html @@ -156,6 +156,45 @@ }); }); + audit.define( + { + label: 'test-audiocontextoptions-sampleRate', + description: + 'Test creating contexts with non-default sampleRate values.' + }, + function(task, should) { + // A sampleRate of 1 is unlikely to be supported on any browser, + // test that this rate is rejected. + should( + () => { + context = new AudioContext({sampleRate: 1}) + }, + 'context = new AudioContext({sampleRate: 1})') + .throw(DOMException); + + // A sampleRate of 1,000,000 is unlikely to be supported on any + // browser, test that this rate is also rejected. + should( + () => { + context = new AudioContext({sampleRate: 1000000}) + }, + 'context = new AudioContext({sampleRate: 1000000})') + .throw(DOMException); + + should( + () => { + context = new AudioContext({sampleRate: 24000}) + }, + 'context = new AudioContext({sampleRate: 24000})') + .notThrow(); + should( + context.sampleRate, 'sampleRate inrange') + .beEqualTo(24000); + + context.close(); + task.done(); + }); + audit.run();