diff --git a/adapters/platforms/wechat/res/workers/ipc-worker.js b/adapters/platforms/wechat/res/workers/ipc-worker.js index cdb019b8..9271c2c3 100644 --- a/adapters/platforms/wechat/res/workers/ipc-worker.js +++ b/adapters/platforms/wechat/res/workers/ipc-worker.js @@ -145,6 +145,7 @@ function _initFromWorker(id, meta) { CC_WORKER_FS_SYNC, CC_WORKER_ASSET_PIPELINE, CC_WORKER_AUDIO_SYSTEM, + CC_WORKER_AUDIO_SYSTEM_SYNC_INTERVAL, ] = meta; for (const wrapper of wrappers) { @@ -160,6 +161,7 @@ function _initFromWorker(id, meta) { globalThis.CC_WORKER_FS_SYNC = CC_WORKER_FS_SYNC; globalThis.CC_WORKER_ASSET_PIPELINE = CC_WORKER_ASSET_PIPELINE; globalThis.CC_WORKER_AUDIO_SYSTEM = CC_WORKER_AUDIO_SYSTEM; + globalThis.CC_WORKER_AUDIO_SYSTEM_SYNC_INTERVAL = CC_WORKER_AUDIO_SYSTEM_SYNC_INTERVAL; _inited = true; if (_initCallback) _initCallback(); diff --git a/adapters/platforms/wechat/res/workers/macro.js b/adapters/platforms/wechat/res/workers/macro.js index d2299a7e..d54c6e0b 100644 --- a/adapters/platforms/wechat/res/workers/macro.js +++ b/adapters/platforms/wechat/res/workers/macro.js @@ -14,3 +14,6 @@ globalThis.CC_WORKER_ASSET_PIPELINE = null; // 是否启用 Worker 驱动音频系统 globalThis.CC_WORKER_AUDIO_SYSTEM = null; + +// Worker 音频系统同步音频属性的间隔时间(单位:毫秒) +globalThis.CC_WORKER_AUDIO_SYSTEM_SYNC_INTERVAL = null; diff --git a/adapters/platforms/wechat/worker/index.js b/adapters/platforms/wechat/worker/index.js index 8b2bf664..1bf93a52 100644 --- a/adapters/platforms/wechat/worker/index.js +++ b/adapters/platforms/wechat/worker/index.js @@ -13,6 +13,7 @@ module.exports = { CC_WORKER_DEBUG, CC_WORKER_ASSET_PIPELINE, CC_WORKER_AUDIO_SYSTEM, + CC_WORKER_AUDIO_SYSTEM_SYNC_INTERVAL, CC_WORKER_SCHEDULER, CC_WORKER_FS_SYNC, CC_WORKER_SUB_PACKAGE, diff --git a/adapters/platforms/wechat/worker/ipc-main.js b/adapters/platforms/wechat/worker/ipc-main.js index 7d7558a5..872fbb85 100644 --- a/adapters/platforms/wechat/worker/ipc-main.js +++ b/adapters/platforms/wechat/worker/ipc-main.js @@ -110,6 +110,7 @@ const ipcMain = { CC_WORKER_FS_SYNC, CC_WORKER_ASSET_PIPELINE, CC_WORKER_AUDIO_SYSTEM, + CC_WORKER_AUDIO_SYSTEM_SYNC_INTERVAL, ]); }, diff --git a/adapters/platforms/wechat/worker/macro.js b/adapters/platforms/wechat/worker/macro.js index d73b9740..73137890 100644 --- a/adapters/platforms/wechat/worker/macro.js +++ b/adapters/platforms/wechat/worker/macro.js @@ -19,11 +19,18 @@ if (!("CC_WORKER_ASSET_PIPELINE" in globalThis)) { // 是否启用 Worker 驱动音频系统 if (!("CC_WORKER_AUDIO_SYSTEM" in globalThis)) { globalThis.CC_WORKER_AUDIO_SYSTEM = false; + // NOTE 截止 2024.10.22,微信未修复 iOS、Windows、Mac 上仅文件系统 API 可以正常使用的问题 + globalThis.CC_WORKER_AUDIO_SYSTEM = (isAndroid || isDevtools) && globalThis.CC_WORKER_AUDIO_SYSTEM; +} + +// Worker 音频系统同步音频属性的间隔时间(单位:毫秒) +if (!("CC_WORKER_AUDIO_SYSTEM_SYNC_INTERVAL" in globalThis)) { + globalThis.CC_WORKER_AUDIO_SYSTEM_SYNC_INTERVAL = 500; } // 是否启用 Worker if (!("CC_USE_WORKER" in globalThis)) { - globalThis.CC_USE_WORKER = (CC_WORKER_ASSET_PIPELINE) && hasWorker && !isSubContext; + globalThis.CC_USE_WORKER = (CC_WORKER_ASSET_PIPELINE || CC_WORKER_AUDIO_SYSTEM) && hasWorker && !isSubContext; } // 是否启用 Worker 调试模式