| 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 28 matching lines...) Expand all Loading... |
| 39 | 39 |
| 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 currentTi
me when read in JS |
| 50 // since currentTime is continuously increasing on audio thread. And cachin
g of the currentTime | 50 // since currentTime is continuously increasing on audio thread. |
| 51 // can cause playbackTime to be one block behind. So allow for that. | |
| 52 | 51 |
| 53 var closeEnough = Math.abs(playbackTime - expectedTime) <= allowedTimeGap; | 52 shouldBeCloseTo("playbackTime", expectedTime, allowedTimeGap, true); |
| 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 } | |
| 61 | 53 |
| 62 buffer = event.outputBuffer; | 54 buffer = event.outputBuffer; |
| 63 if (buffer.numberOfChannels != outputChannels) | 55 if (buffer.numberOfChannels != outputChannels) |
| 64 testFailed("numberOfOutputChannels doesn't match!"); | 56 testFailed("numberOfOutputChannels doesn't match!"); |
| 65 | 57 |
| 66 if (buffer.length != bufferSize) | 58 if (buffer.length != bufferSize) |
| 67 testFailed("numberOfOutputChannels doesn't match!"); | 59 testFailed("numberOfOutputChannels doesn't match!"); |
| 68 | 60 |
| 69 buffer = event.inputBuffer; | 61 buffer = event.inputBuffer; |
| 70 var bufferDataL = buffer.getChannelData(0); | 62 var bufferDataL = buffer.getChannelData(0); |
| (...skipping 100 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 171 context.oncomplete = finishJSTest; | 163 context.oncomplete = finishJSTest; |
| 172 context.startRendering(); | 164 context.startRendering(); |
| 173 } | 165 } |
| 174 | 166 |
| 175 runTest(); | 167 runTest(); |
| 176 | 168 |
| 177 </script> | 169 </script> |
| 178 | 170 |
| 179 </body> | 171 </body> |
| 180 </html> | 172 </html> |
| OLD | NEW |