| OLD | NEW |
| 1 <!DOCTYPE html> | 1 <!DOCTYPE html> |
| 2 <html> | 2 <html> |
| 3 <head> | 3 <head> |
| 4 <script src="../resources/js-test.js"></script> | 4 <script src="../resources/js-test.js"></script> |
| 5 <script src="resources/compatibility.js"></script> | 5 <script src="resources/compatibility.js"></script> |
| 6 <script type="text/javascript" src="resources/audio-testing.js"></script> | 6 <script type="text/javascript" src="resources/audio-testing.js"></script> |
| 7 </head> | 7 </head> |
| 8 | 8 |
| 9 <body> | 9 <body> |
| 10 | 10 |
| (...skipping 29 matching lines...) Expand all Loading... |
| 40 return audioBuffer; | 40 return audioBuffer; |
| 41 } | 41 } |
| 42 | 42 |
| 43 function processAudioData(event) { | 43 function processAudioData(event) { |
| 44 playbackTime = event.playbackTime; | 44 playbackTime = event.playbackTime; |
| 45 var expectedTime = context.currentTime + (bufferSize / context.sampleRate); | 45 var expectedTime = context.currentTime + (bufferSize / context.sampleRate); |
| 46 var allowedTimeGap = 0.0000001; | 46 var allowedTimeGap = 0.0000001; |
| 47 | 47 |
| 48 // There may be a little time gap which is from different thread operation | 48 // There may be a little time gap which is from different thread operation |
| 49 // between currentTime when main thread fires onaudioprocess() and currenTim
e when read in JS | 49 // between currentTime when main thread fires onaudioprocess() and currenTim
e when read in JS |
| 50 // since currentTime is continuously increasing on audio thread. | 50 // since currentTime is continuously increasing on audio thread. And cachin
g of the currentTime |
| 51 shouldBeCloseTo("playbackTime", expectedTime, allowedTimeGap, true); | 51 // can cause playbackTime to be one block behind. So allow for that. |
| 52 |
| 53 var closeEnough = Math.abs(playbackTime - expectedTime) <= allowedTimeGap; |
| 54 closeEnough = closeEnough || (Math.abs(playbackTime - (expectedTime - 128 /
context.sampleRate)) <= allowedTimeGap); |
| 55 |
| 56 if (!closeEnough) { |
| 57 testFailed("playbackTime should be within " + allowedTimeGap + " of eith
er " |
| 58 + expectedTime + " or " + (expectedTime - 128 / context.sampl
eRate) |
| 59 + ". Was " + playbackTime); |
| 60 } |
| 52 | 61 |
| 53 buffer = event.outputBuffer; | 62 buffer = event.outputBuffer; |
| 54 if (buffer.numberOfChannels != outputChannels) | 63 if (buffer.numberOfChannels != outputChannels) |
| 55 testFailed("numberOfOutputChannels doesn't match!"); | 64 testFailed("numberOfOutputChannels doesn't match!"); |
| 56 | 65 |
| 57 if (buffer.length != bufferSize) | 66 if (buffer.length != bufferSize) |
| 58 testFailed("numberOfOutputChannels doesn't match!"); | 67 testFailed("numberOfOutputChannels doesn't match!"); |
| 59 | 68 |
| 60 buffer = event.inputBuffer; | 69 buffer = event.inputBuffer; |
| 61 var bufferDataL = buffer.getChannelData(0); | 70 var bufferDataL = buffer.getChannelData(0); |
| (...skipping 100 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 162 context.oncomplete = finishJSTest; | 171 context.oncomplete = finishJSTest; |
| 163 context.startRendering(); | 172 context.startRendering(); |
| 164 } | 173 } |
| 165 | 174 |
| 166 runTest(); | 175 runTest(); |
| 167 | 176 |
| 168 </script> | 177 </script> |
| 169 | 178 |
| 170 </body> | 179 </body> |
| 171 </html> | 180 </html> |
| OLD | NEW |