From 3ffea9ae23199e10d413e28ef333b34dc3c06d97 Mon Sep 17 00:00:00 2001 From: SmallMain Date: Tue, 29 Oct 2024 15:22:05 +0800 Subject: [PATCH] =?UTF-8?q?[adapters]=20=E4=BF=AE=E5=A4=8D=E5=AE=8F?= =?UTF-8?q?=E7=9A=84=E4=B8=80=E4=BA=9B=E9=97=AE=E9=A2=98=EF=BC=8C=E5=B9=B6?= =?UTF-8?q?=E5=A2=9E=E5=8A=A0=20CC=5FWORKER=5FAUDIO=5FSYSTEM=5FSYNC=5FINTE?= =?UTF-8?q?RVAL=20=E5=AE=8F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- adapters/platforms/wechat/res/workers/ipc-worker.js | 2 ++ adapters/platforms/wechat/res/workers/macro.js | 3 +++ adapters/platforms/wechat/worker/index.js | 1 + adapters/platforms/wechat/worker/ipc-main.js | 1 + adapters/platforms/wechat/worker/macro.js | 9 ++++++++- 5 files changed, 15 insertions(+), 1 deletion(-) 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 调试模式