[adapters] 修复宏的一些问题,并增加 CC_WORKER_AUDIO_SYSTEM_SYNC_INTERVAL 宏

This commit is contained in:
SmallMain 2024-10-29 15:22:05 +08:00
parent d28997bcbb
commit 3ffea9ae23
No known key found for this signature in database
5 changed files with 15 additions and 1 deletions

View File

@ -145,6 +145,7 @@ function _initFromWorker(id, meta) {
CC_WORKER_FS_SYNC, CC_WORKER_FS_SYNC,
CC_WORKER_ASSET_PIPELINE, CC_WORKER_ASSET_PIPELINE,
CC_WORKER_AUDIO_SYSTEM, CC_WORKER_AUDIO_SYSTEM,
CC_WORKER_AUDIO_SYSTEM_SYNC_INTERVAL,
] = meta; ] = meta;
for (const wrapper of wrappers) { 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_FS_SYNC = CC_WORKER_FS_SYNC;
globalThis.CC_WORKER_ASSET_PIPELINE = CC_WORKER_ASSET_PIPELINE; globalThis.CC_WORKER_ASSET_PIPELINE = CC_WORKER_ASSET_PIPELINE;
globalThis.CC_WORKER_AUDIO_SYSTEM = CC_WORKER_AUDIO_SYSTEM; globalThis.CC_WORKER_AUDIO_SYSTEM = CC_WORKER_AUDIO_SYSTEM;
globalThis.CC_WORKER_AUDIO_SYSTEM_SYNC_INTERVAL = CC_WORKER_AUDIO_SYSTEM_SYNC_INTERVAL;
_inited = true; _inited = true;
if (_initCallback) _initCallback(); if (_initCallback) _initCallback();

View File

@ -14,3 +14,6 @@ globalThis.CC_WORKER_ASSET_PIPELINE = null;
// 是否启用 Worker 驱动音频系统 // 是否启用 Worker 驱动音频系统
globalThis.CC_WORKER_AUDIO_SYSTEM = null; globalThis.CC_WORKER_AUDIO_SYSTEM = null;
// Worker 音频系统同步音频属性的间隔时间(单位:毫秒)
globalThis.CC_WORKER_AUDIO_SYSTEM_SYNC_INTERVAL = null;

View File

@ -13,6 +13,7 @@ module.exports = {
CC_WORKER_DEBUG, CC_WORKER_DEBUG,
CC_WORKER_ASSET_PIPELINE, CC_WORKER_ASSET_PIPELINE,
CC_WORKER_AUDIO_SYSTEM, CC_WORKER_AUDIO_SYSTEM,
CC_WORKER_AUDIO_SYSTEM_SYNC_INTERVAL,
CC_WORKER_SCHEDULER, CC_WORKER_SCHEDULER,
CC_WORKER_FS_SYNC, CC_WORKER_FS_SYNC,
CC_WORKER_SUB_PACKAGE, CC_WORKER_SUB_PACKAGE,

View File

@ -110,6 +110,7 @@ const ipcMain = {
CC_WORKER_FS_SYNC, CC_WORKER_FS_SYNC,
CC_WORKER_ASSET_PIPELINE, CC_WORKER_ASSET_PIPELINE,
CC_WORKER_AUDIO_SYSTEM, CC_WORKER_AUDIO_SYSTEM,
CC_WORKER_AUDIO_SYSTEM_SYNC_INTERVAL,
]); ]);
}, },

View File

@ -19,11 +19,18 @@ if (!("CC_WORKER_ASSET_PIPELINE" in globalThis)) {
// 是否启用 Worker 驱动音频系统 // 是否启用 Worker 驱动音频系统
if (!("CC_WORKER_AUDIO_SYSTEM" in globalThis)) { if (!("CC_WORKER_AUDIO_SYSTEM" in globalThis)) {
globalThis.CC_WORKER_AUDIO_SYSTEM = false; 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 // 是否启用 Worker
if (!("CC_USE_WORKER" in globalThis)) { 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 调试模式 // 是否启用 Worker 调试模式