Use matching sample rate for the context as for the reference file

The reference file has a certain sample rate.  Use the same for the
context to reduce the amount of resampling that might be required.

Regenerated the webm-decode-expected.wave file with the fixed sample rate.  This also
changed the SNR slightly, so update the SNR test accordingly.  Also manually compared
the new and old files.  These differ by at most 1 LSB (16-bit).

Bug: 940970
Change-Id: I979bbeb512c36d7e2eb4cba85550fa4177b8aabd
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1516723
Commit-Queue: Raymond Toy <rtoy@chromium.org>
Reviewed-by: Hongchan Choi <hongchan@chromium.org>
Cr-Commit-Position: refs/heads/master@{#640341}
diff --git a/third_party/blink/web_tests/external/wpt/webaudio/the-audio-api/the-mediaelementaudiosourcenode-interface/mediaElementAudioSourceToScriptProcessorTest.html b/third_party/blink/web_tests/external/wpt/webaudio/the-audio-api/the-mediaelementaudiosourcenode-interface/mediaElementAudioSourceToScriptProcessorTest.html
index 2c1162d4..3e364eb7 100644
--- a/third_party/blink/web_tests/external/wpt/webaudio/the-audio-api/the-mediaelementaudiosourcenode-interface/mediaElementAudioSourceToScriptProcessorTest.html
+++ b/third_party/blink/web_tests/external/wpt/webaudio/the-audio-api/the-mediaelementaudiosourcenode-interface/mediaElementAudioSourceToScriptProcessorTest.html
@@ -51,8 +51,10 @@
    return result;
  }
 
- // Create Audio context
- context = new AudioContext();
+ // Create Audio context.  The reference wav file is sampled at 44.1 kHz so
+ // use the same rate for the context to remove extra resampling that might
+ // be required.
+ context = new AudioContext({sampleRate: 44100});
 
  // Create an audio element, and a media element source
  audio = document.createElement('audio');
diff --git a/third_party/blink/web_tests/webaudio/codec-tests/webm/resources/webm-decode-expected.wav b/third_party/blink/web_tests/webaudio/codec-tests/webm/resources/webm-decode-expected.wav
index e058abc..b023c98 100644
--- a/third_party/blink/web_tests/webaudio/codec-tests/webm/resources/webm-decode-expected.wav
+++ b/third_party/blink/web_tests/webaudio/codec-tests/webm/resources/webm-decode-expected.wav
Binary files differ
diff --git a/third_party/blink/web_tests/webaudio/codec-tests/webm/webm-decode.html b/third_party/blink/web_tests/webaudio/codec-tests/webm/webm-decode.html
index be139a9..26c636e 100644
--- a/third_party/blink/web_tests/webaudio/codec-tests/webm/webm-decode.html
+++ b/third_party/blink/web_tests/webaudio/codec-tests/webm/webm-decode.html
@@ -21,7 +21,10 @@
           {label: 'test', description: 'Test webm decoding'},
           function(task, should) {
 
-            let context = new AudioContext();
+            // Set the sample rate to match to encoded rate in the reference
+            // files, which is 48 kHz, to eliminate any resampling from
+            // decodeAudioData.
+            let context = new AudioContext({sampleRate: 48000});
 
             let bufferLoader = new BufferLoader(
                 context, ['resources/webm-decode-expected.wav', 'test-webm.webm'],
@@ -29,6 +32,10 @@
                   expectedAudio = bufferList[0];
                   decodedAudio = bufferList[1];
 
+                  // Just for information
+                  should(context.sampleRate, 'context.sampleRate')
+                    .beEqualTo(context.sampleRate);
+
                   // Verify that we have the right number of channels and
                   // frames.
                   should(decodedAudio.numberOfChannels, 'Number of channels')
@@ -44,7 +51,7 @@
                             decodedAudio.getChannelData(c),
                             expectedAudio.getChannelData(c)));
                     should(snrdB, 'SNR between actual expected channel ' + c)
-                        .beGreaterThanOrEqualTo(109.56);
+                        .beGreaterThanOrEqualTo(110.97);
                     should(
                         decodedAudio.getChannelData(c), 'Decoded channel ' + c)
                         .beCloseToArray(