Skip to content

Commit e94ab0c

Browse files
authored
Merge pull request #3445 from VisualSJ/develop-createGain
check context integrity
2 parents c3f7000 + 8f34253 commit e94ab0c

File tree

1 file changed

+9
-0
lines changed

1 file changed

+9
-0
lines changed

cocos2d/audio/CCAudio.js

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -352,6 +352,15 @@ cc.Audio.WebAudio.prototype = {
352352
if (SWA) {
353353
var context = new (window.AudioContext || window.webkitAudioContext || window.mozAudioContext)();
354354
cc.Audio._context = context;
355+
// check context integrity
356+
if (
357+
!context["createBufferSource"] ||
358+
!context["createGain"] ||
359+
!context["destination"] ||
360+
!context["decodeAudioData"]
361+
) {
362+
throw 'context is incomplete';
363+
}
355364
if (polyfill.DELAY_CREATE_CTX)
356365
setTimeout(function () {
357366
context = new (window.AudioContext || window.webkitAudioContext || window.mozAudioContext)();

0 commit comments

Comments
 (0)