@meframe/core 0.6.13 → 0.7.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +83 -0
- package/README.md +17 -5
- package/dist/Meframe.d.ts +14 -3
- package/dist/Meframe.d.ts.map +1 -1
- package/dist/Meframe.js +22 -12
- package/dist/Meframe.js.map +1 -1
- package/dist/cache/CacheManager.d.ts +2 -0
- package/dist/cache/CacheManager.d.ts.map +1 -1
- package/dist/cache/CacheManager.js +5 -0
- package/dist/cache/CacheManager.js.map +1 -1
- package/dist/cache/l1/VideoL1Cache.d.ts +2 -0
- package/dist/cache/l1/VideoL1Cache.d.ts.map +1 -1
- package/dist/cache/l1/VideoL1Cache.js +13 -7
- package/dist/cache/l1/VideoL1Cache.js.map +1 -1
- package/dist/cache/l2/IndexedDBStore.d.ts +1 -2
- package/dist/cache/l2/IndexedDBStore.d.ts.map +1 -1
- package/dist/cache/l2/L2Cache.d.ts +3 -2
- package/dist/cache/l2/L2Cache.d.ts.map +1 -1
- package/dist/cache/l2/L2OPFSStore.d.ts +3 -3
- package/dist/cache/l2/L2OPFSStore.d.ts.map +1 -1
- package/dist/cache/l2/OPFSStore.d.ts +1 -2
- package/dist/cache/l2/OPFSStore.d.ts.map +1 -1
- package/dist/cache/resource/AudioSampleCache.d.ts +12 -0
- package/dist/cache/resource/AudioSampleCache.d.ts.map +1 -1
- package/dist/cache/resource/AudioSampleCache.js +39 -5
- package/dist/cache/resource/AudioSampleCache.js.map +1 -1
- package/dist/cache/resource/ResourceCache.d.ts +4 -12
- package/dist/cache/resource/ResourceCache.d.ts.map +1 -1
- package/dist/cache/resource/ResourceCache.js +7 -24
- package/dist/cache/resource/ResourceCache.js.map +1 -1
- package/dist/config/defaults.d.ts.map +1 -1
- package/dist/config/defaults.js +4 -1
- package/dist/config/defaults.js.map +1 -1
- package/dist/config/index.d.ts +1 -1
- package/dist/config/index.d.ts.map +1 -1
- package/dist/config/types.d.ts +29 -0
- package/dist/config/types.d.ts.map +1 -1
- package/dist/config/validation.d.ts.map +1 -1
- package/dist/config/validation.js +3 -0
- package/dist/config/validation.js.map +1 -1
- package/dist/controllers/PlaybackController.d.ts +38 -9
- package/dist/controllers/PlaybackController.d.ts.map +1 -1
- package/dist/controllers/PlaybackController.js +269 -154
- package/dist/controllers/PlaybackController.js.map +1 -1
- package/dist/controllers/PlaybackStateMachine.d.ts.map +1 -1
- package/dist/controllers/PlaybackStateMachine.js +2 -1
- package/dist/controllers/PlaybackStateMachine.js.map +1 -1
- package/dist/controllers/types.d.ts +10 -2
- package/dist/controllers/types.d.ts.map +1 -1
- package/dist/controllers/types.js.map +1 -1
- package/dist/event/events.d.ts +2 -0
- package/dist/event/events.d.ts.map +1 -1
- package/dist/event/events.js.map +1 -1
- package/dist/index.d.ts +2 -2
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +1 -1
- package/dist/index.js.map +1 -1
- package/dist/model/CompositionModel.d.ts +0 -1
- package/dist/model/CompositionModel.d.ts.map +1 -1
- package/dist/model/CompositionModel.js +0 -6
- package/dist/model/CompositionModel.js.map +1 -1
- package/dist/model/patch.js +12 -12
- package/dist/model/patch.js.map +1 -1
- package/dist/node_modules/.pnpm/{mp4-muxer@5.2.2 → mp4-muxer@5.2.2_patch_hash_452653ac44da4ef32d244694e500e34d084eaa3c4232515ddec962eacc5f30ea}/node_modules/mp4-muxer/build/mp4-muxer.js +17 -3
- package/dist/node_modules/.pnpm/mp4-muxer@5.2.2_patch_hash_452653ac44da4ef32d244694e500e34d084eaa3c4232515ddec962eacc5f30ea/node_modules/mp4-muxer/build/mp4-muxer.js.map +1 -0
- package/dist/orchestrator/AudioExportSession.d.ts +28 -3
- package/dist/orchestrator/AudioExportSession.d.ts.map +1 -1
- package/dist/orchestrator/AudioExportSession.js +131 -15
- package/dist/orchestrator/AudioExportSession.js.map +1 -1
- package/dist/orchestrator/AudioPreviewSession.d.ts +6 -1
- package/dist/orchestrator/AudioPreviewSession.d.ts.map +1 -1
- package/dist/orchestrator/AudioPreviewSession.js +57 -18
- package/dist/orchestrator/AudioPreviewSession.js.map +1 -1
- package/dist/orchestrator/AudioWindowPreparer.d.ts +6 -4
- package/dist/orchestrator/AudioWindowPreparer.d.ts.map +1 -1
- package/dist/orchestrator/AudioWindowPreparer.js +247 -54
- package/dist/orchestrator/AudioWindowPreparer.js.map +1 -1
- package/dist/orchestrator/CompositionPlanner.d.ts +5 -2
- package/dist/orchestrator/CompositionPlanner.d.ts.map +1 -1
- package/dist/orchestrator/CompositionPlanner.js +8 -3
- package/dist/orchestrator/CompositionPlanner.js.map +1 -1
- package/dist/orchestrator/ExportScheduler.d.ts +1 -0
- package/dist/orchestrator/ExportScheduler.d.ts.map +1 -1
- package/dist/orchestrator/ExportScheduler.js +177 -106
- package/dist/orchestrator/ExportScheduler.js.map +1 -1
- package/dist/orchestrator/Orchestrator.d.ts +30 -4
- package/dist/orchestrator/Orchestrator.d.ts.map +1 -1
- package/dist/orchestrator/Orchestrator.js +264 -111
- package/dist/orchestrator/Orchestrator.js.map +1 -1
- package/dist/orchestrator/PreviewFrameScheduler.d.ts +21 -1
- package/dist/orchestrator/PreviewFrameScheduler.d.ts.map +1 -1
- package/dist/orchestrator/PreviewFrameScheduler.js +129 -30
- package/dist/orchestrator/PreviewFrameScheduler.js.map +1 -1
- package/dist/orchestrator/VideoWindowDecodeSession.d.ts +22 -1
- package/dist/orchestrator/VideoWindowDecodeSession.d.ts.map +1 -1
- package/dist/orchestrator/VideoWindowDecodeSession.js +426 -198
- package/dist/orchestrator/VideoWindowDecodeSession.js.map +1 -1
- package/dist/orchestrator/aac-window-timeline.d.ts +6 -2
- package/dist/orchestrator/aac-window-timeline.d.ts.map +1 -1
- package/dist/orchestrator/aac-window-timeline.js +156 -19
- package/dist/orchestrator/aac-window-timeline.js.map +1 -1
- package/dist/orchestrator/types.d.ts +5 -1
- package/dist/orchestrator/types.d.ts.map +1 -1
- package/dist/stages/compose/FrameRateConverter.d.ts +2 -1
- package/dist/stages/compose/FrameRateConverter.d.ts.map +1 -1
- package/dist/stages/compose/LayerRenderPolicy.d.ts +14 -0
- package/dist/stages/compose/LayerRenderPolicy.d.ts.map +1 -0
- package/dist/stages/compose/LayerRenderPolicy.js +18 -0
- package/dist/stages/compose/LayerRenderPolicy.js.map +1 -0
- package/dist/stages/compose/OfflineAudioMixer.d.ts +2 -0
- package/dist/stages/compose/OfflineAudioMixer.d.ts.map +1 -1
- package/dist/stages/compose/OfflineAudioMixer.js +14 -2
- package/dist/stages/compose/OfflineAudioMixer.js.map +1 -1
- package/dist/stages/compose/OwnedFrameTransform.d.ts +52 -0
- package/dist/stages/compose/OwnedFrameTransform.d.ts.map +1 -0
- package/dist/stages/compose/OwnedFrameTransform.js +154 -0
- package/dist/stages/compose/OwnedFrameTransform.js.map +1 -0
- package/dist/stages/compose/TransitionProcessor.js +0 -1
- package/dist/stages/compose/TransitionProcessor.js.map +1 -1
- package/dist/stages/compose/VideoComposer.d.ts +12 -2
- package/dist/stages/compose/VideoComposer.d.ts.map +1 -1
- package/dist/stages/compose/VideoComposer.js +100 -92
- package/dist/stages/compose/VideoComposer.js.map +1 -1
- package/dist/stages/compose/text-renderers/basic-text-renderer.d.ts.map +1 -1
- package/dist/stages/compose/text-renderers/basic-text-renderer.js +24 -21
- package/dist/stages/compose/text-renderers/basic-text-renderer.js.map +1 -1
- package/dist/stages/compose/text-renderers/caption-stagger-entrance-renderer.d.ts.map +1 -1
- package/dist/stages/compose/text-renderers/caption-stagger-entrance-renderer.js +110 -99
- package/dist/stages/compose/text-renderers/caption-stagger-entrance-renderer.js.map +1 -1
- package/dist/stages/compose/text-renderers/character-ktv-renderer.d.ts.map +1 -1
- package/dist/stages/compose/text-renderers/character-ktv-renderer.js +41 -38
- package/dist/stages/compose/text-renderers/character-ktv-renderer.js.map +1 -1
- package/dist/stages/compose/text-renderers/word-by-word-renderer.d.ts.map +1 -1
- package/dist/stages/compose/text-renderers/word-by-word-renderer.js +47 -39
- package/dist/stages/compose/text-renderers/word-by-word-renderer.js.map +1 -1
- package/dist/stages/compose/text-renderers/word-fancy-renderer.d.ts.map +1 -1
- package/dist/stages/compose/text-renderers/word-fancy-renderer.js +54 -48
- package/dist/stages/compose/text-renderers/word-fancy-renderer.js.map +1 -1
- package/dist/stages/compose/text-utils/text-metrics.d.ts.map +1 -1
- package/dist/stages/compose/text-utils/text-metrics.js +6 -4
- package/dist/stages/compose/text-utils/text-metrics.js.map +1 -1
- package/dist/stages/compose/types.d.ts +12 -0
- package/dist/stages/compose/types.d.ts.map +1 -1
- package/dist/stages/decode/BaseDecoder.d.ts +5 -0
- package/dist/stages/decode/BaseDecoder.d.ts.map +1 -1
- package/dist/stages/decode/BaseDecoder.js +52 -10
- package/dist/stages/decode/BaseDecoder.js.map +1 -1
- package/dist/stages/decode/preview-video-decoder.d.ts +48 -2
- package/dist/stages/decode/preview-video-decoder.d.ts.map +1 -1
- package/dist/stages/decode/preview-video-decoder.js +241 -71
- package/dist/stages/decode/preview-video-decoder.js.map +1 -1
- package/dist/stages/decode/video-decoder.d.ts +2 -11
- package/dist/stages/decode/video-decoder.d.ts.map +1 -1
- package/dist/stages/decode/video-decoder.js +60 -61
- package/dist/stages/decode/video-decoder.js.map +1 -1
- package/dist/stages/demux/MP3FrameParser.d.ts +18 -0
- package/dist/stages/demux/MP3FrameParser.d.ts.map +1 -1
- package/dist/stages/demux/MP3FrameParser.js +143 -11
- package/dist/stages/demux/MP3FrameParser.js.map +1 -1
- package/dist/stages/demux/MP4IndexParser.d.ts +32 -21
- package/dist/stages/demux/MP4IndexParser.d.ts.map +1 -1
- package/dist/stages/demux/MP4IndexParser.js +202 -309
- package/dist/stages/demux/MP4IndexParser.js.map +1 -1
- package/dist/stages/demux/sample-collector.d.ts +35 -0
- package/dist/stages/demux/sample-collector.d.ts.map +1 -0
- package/dist/stages/demux/sample-collector.js +105 -0
- package/dist/stages/demux/sample-collector.js.map +1 -0
- package/dist/stages/encode/BaseEncoder.d.ts +9 -2
- package/dist/stages/encode/BaseEncoder.d.ts.map +1 -1
- package/dist/stages/encode/BaseEncoder.js +90 -59
- package/dist/stages/encode/BaseEncoder.js.map +1 -1
- package/dist/stages/load/ResourceLoader.d.ts +71 -18
- package/dist/stages/load/ResourceLoader.d.ts.map +1 -1
- package/dist/stages/load/ResourceLoader.js +369 -143
- package/dist/stages/load/ResourceLoader.js.map +1 -1
- package/dist/stages/load/TaskManager.d.ts.map +1 -1
- package/dist/stages/load/TaskManager.js +9 -3
- package/dist/stages/load/TaskManager.js.map +1 -1
- package/dist/stages/load/types.d.ts +2 -2
- package/dist/stages/load/types.d.ts.map +1 -1
- package/dist/stages/mux/MP4Muxer.d.ts +7 -1
- package/dist/stages/mux/MP4Muxer.d.ts.map +1 -1
- package/dist/stages/mux/MP4Muxer.js +8 -10
- package/dist/stages/mux/MP4Muxer.js.map +1 -1
- package/dist/stages/mux/MuxManager.d.ts +7 -0
- package/dist/stages/mux/MuxManager.d.ts.map +1 -1
- package/dist/stages/mux/MuxManager.js +9 -0
- package/dist/stages/mux/MuxManager.js.map +1 -1
- package/dist/types.d.ts +1 -1
- package/dist/types.d.ts.map +1 -1
- package/dist/utils/errors.d.ts +2 -0
- package/dist/utils/errors.d.ts.map +1 -1
- package/dist/utils/errors.js +10 -1
- package/dist/utils/errors.js.map +1 -1
- package/dist/utils/until-aborted.d.ts +8 -0
- package/dist/utils/until-aborted.d.ts.map +1 -0
- package/dist/utils/until-aborted.js +33 -0
- package/dist/utils/until-aborted.js.map +1 -0
- package/dist/worker/WorkerChannel.d.ts.map +1 -1
- package/dist/worker/WorkerChannel.js +45 -10
- package/dist/worker/WorkerChannel.js.map +1 -1
- package/dist/worker/worker-manifest.js +1 -1
- package/dist/worker/worker-manifest.js.map +1 -1
- package/dist/workers/stages/export/{export.worker.C8jKSbVj.js → export.worker.BG8HA7dY.js} +745 -450
- package/dist/workers/stages/export/export.worker.BG8HA7dY.js.map +1 -0
- package/dist/workers/worker-manifest.json +1 -1
- package/package.json +23 -22
- package/dist/node_modules/.pnpm/mp4-muxer@5.2.2/node_modules/mp4-muxer/build/mp4-muxer.js.map +0 -1
- package/dist/workers/stages/export/export.worker.C8jKSbVj.js.map +0 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"AudioWindowPreparer.d.ts","sourceRoot":"","sources":["../../src/orchestrator/AudioWindowPreparer.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,IAAI,EAAE,QAAQ,EAAE,MAAM,EAAE,MAAM,gBAAgB,CAAC;AAC7D,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,UAAU,CAAC;AACjD,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,+BAA+B,CAAC;AACpE,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,mBAAmB,CAAC;AAClD,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,iBAAiB,CAAC;AAEvD,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,uBAAuB,CAAC;AAC1D,OAAO,KAAK,EAAE,iBAAiB,
|
|
1
|
+
{"version":3,"file":"AudioWindowPreparer.d.ts","sourceRoot":"","sources":["../../src/orchestrator/AudioWindowPreparer.ts"],"names":[],"mappings":"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"}
|
|
@@ -3,14 +3,16 @@ import { AudioChunkDecoder } from "../stages/decode/AudioChunkDecoder.js";
|
|
|
3
3
|
import { decodeWavPCM } from "../stages/demux/WAVIndexParser.js";
|
|
4
4
|
import { hasResourceId, isAudioClip, clipPlaybackRate } from "../model/types.js";
|
|
5
5
|
import { buildLoopedResourceSegments } from "../utils/loop-utils.js";
|
|
6
|
-
import {
|
|
7
|
-
import {
|
|
6
|
+
import { extractPlanesFromAudioData } from "../utils/audio-data.js";
|
|
7
|
+
import { isTerminalMediaResourceError, markReportedToHost } from "../utils/errors.js";
|
|
8
|
+
import { untilAborted } from "../utils/until-aborted.js";
|
|
9
|
+
import { binarySearchFirst } from "../utils/binary-search.js";
|
|
10
|
+
import { prepareAACTimeline, readIndexedAACWindow, readSampleByteSlice, getAACWindow } from "./aac-window-timeline.js";
|
|
8
11
|
class AudioWindowPreparer {
|
|
9
12
|
activeClips = /* @__PURE__ */ new Set();
|
|
10
13
|
/** 解码确定失败的 clip(坏包等):本会话不再重试,避免重试风暴;reset 清空 */
|
|
11
14
|
failedDecodeClips = /* @__PURE__ */ new Set();
|
|
12
15
|
deps;
|
|
13
|
-
model = null;
|
|
14
16
|
revision = 0;
|
|
15
17
|
decodeQueue = Promise.resolve();
|
|
16
18
|
pendingReads = 0;
|
|
@@ -19,6 +21,9 @@ class AudioWindowPreparer {
|
|
|
19
21
|
nextRecordId = 0;
|
|
20
22
|
aacTimelines = /* @__PURE__ */ new WeakMap();
|
|
21
23
|
lifecycle = new AbortController();
|
|
24
|
+
get model() {
|
|
25
|
+
return this.deps.getCompositionModel();
|
|
26
|
+
}
|
|
22
27
|
get generation() {
|
|
23
28
|
return this.revision;
|
|
24
29
|
}
|
|
@@ -49,7 +54,7 @@ class AudioWindowPreparer {
|
|
|
49
54
|
throw new DOMException("Audio request superseded", "AbortError");
|
|
50
55
|
}
|
|
51
56
|
}
|
|
52
|
-
async prepareSource(source, strictMode = false) {
|
|
57
|
+
async prepareSource(source, strictMode = false, signal) {
|
|
53
58
|
this.checkCurrent(source);
|
|
54
59
|
const { clip, resource } = source;
|
|
55
60
|
if (resource.state === "error" && resource.error?.terminal) {
|
|
@@ -81,14 +86,20 @@ class AudioWindowPreparer {
|
|
|
81
86
|
this.deps.cacheManager.setAudioSource(clip.id, cacheKey);
|
|
82
87
|
let pendingTimeline = this.aacTimelines.get(record);
|
|
83
88
|
if (!pendingTimeline) {
|
|
84
|
-
|
|
89
|
+
const lifecycle = this.lifecycle.signal;
|
|
90
|
+
const timeline = pendingTimeline = this.decodeQueue.then(async () => {
|
|
85
91
|
this.decoding++;
|
|
86
92
|
try {
|
|
87
|
-
return await prepareAACTimeline(record);
|
|
93
|
+
return await prepareAACTimeline(record, lifecycle);
|
|
88
94
|
} finally {
|
|
89
95
|
this.decoding--;
|
|
90
96
|
}
|
|
91
97
|
});
|
|
98
|
+
timeline.catch(() => {
|
|
99
|
+
if (lifecycle.aborted && this.aacTimelines.get(record) === timeline) {
|
|
100
|
+
this.aacTimelines.delete(record);
|
|
101
|
+
}
|
|
102
|
+
});
|
|
92
103
|
this.decodeQueue = pendingTimeline.then(
|
|
93
104
|
() => void 0,
|
|
94
105
|
() => void 0
|
|
@@ -97,8 +108,9 @@ class AudioWindowPreparer {
|
|
|
97
108
|
}
|
|
98
109
|
let aacTimeline;
|
|
99
110
|
try {
|
|
100
|
-
aacTimeline = await pendingTimeline;
|
|
111
|
+
aacTimeline = await untilAborted(pendingTimeline, signal);
|
|
101
112
|
} catch (error) {
|
|
113
|
+
signal?.throwIfAborted();
|
|
102
114
|
this.checkCurrent(source);
|
|
103
115
|
await this.handleDecodeFailure(clip.id, error, strictMode);
|
|
104
116
|
return null;
|
|
@@ -121,11 +133,13 @@ class AudioWindowPreparer {
|
|
|
121
133
|
);
|
|
122
134
|
}
|
|
123
135
|
/** Decode and consume under one lease. Other readers cannot evict these slots between awaits. */
|
|
124
|
-
async withPCM(source, startUs, endUs, consume, strictMode = false) {
|
|
136
|
+
async withPCM(source, startUs, endUs, consume, strictMode = false, signal) {
|
|
125
137
|
this.pendingReads++;
|
|
126
138
|
const run = async () => {
|
|
139
|
+
signal?.throwIfAborted();
|
|
127
140
|
this.checkCurrent(source);
|
|
128
|
-
const
|
|
141
|
+
const firstSampleTimestamp = source.record.indexed ? source.record.indexed.samples[0]?.timestamp : source.record.samples[0]?.timestamp;
|
|
142
|
+
const firstUs = source.record.gapless ? 0 : firstSampleTimestamp ?? 0;
|
|
129
143
|
const readStartUs = Math.max(firstUs, startUs);
|
|
130
144
|
const readEndUs = Math.min(endUs, source.record.durationUs);
|
|
131
145
|
if (readEndUs <= readStartUs) return consume(null);
|
|
@@ -138,7 +152,14 @@ class AudioWindowPreparer {
|
|
|
138
152
|
);
|
|
139
153
|
this.decoding++;
|
|
140
154
|
try {
|
|
141
|
-
await this.decodeAudioWindow(
|
|
155
|
+
await this.decodeAudioWindow(
|
|
156
|
+
source.clip.id,
|
|
157
|
+
readStartUs,
|
|
158
|
+
readEndUs,
|
|
159
|
+
strictMode,
|
|
160
|
+
source,
|
|
161
|
+
signal
|
|
162
|
+
);
|
|
142
163
|
this.checkCurrent(source);
|
|
143
164
|
if (this.failedDecodeClips.has(source.clip.id) && !strictMode) return consume(null);
|
|
144
165
|
const threshold = Math.max(
|
|
@@ -172,16 +193,14 @@ class AudioWindowPreparer {
|
|
|
172
193
|
lease.release();
|
|
173
194
|
}
|
|
174
195
|
};
|
|
175
|
-
const task = this.decodeQueue.then(run, run)
|
|
196
|
+
const task = this.decodeQueue.then(run, run).finally(() => {
|
|
197
|
+
this.pendingReads--;
|
|
198
|
+
});
|
|
176
199
|
this.decodeQueue = task.then(
|
|
177
200
|
() => void 0,
|
|
178
201
|
() => void 0
|
|
179
202
|
);
|
|
180
|
-
|
|
181
|
-
return await task;
|
|
182
|
-
} finally {
|
|
183
|
-
this.pendingReads--;
|
|
184
|
-
}
|
|
203
|
+
return untilAborted(task, signal);
|
|
185
204
|
}
|
|
186
205
|
async drain() {
|
|
187
206
|
await this.decodeQueue;
|
|
@@ -189,9 +208,8 @@ class AudioWindowPreparer {
|
|
|
189
208
|
constructor(deps) {
|
|
190
209
|
this.deps = deps;
|
|
191
210
|
}
|
|
192
|
-
setModel(
|
|
211
|
+
setModel(_model) {
|
|
193
212
|
this.invalidate();
|
|
194
|
-
this.model = model;
|
|
195
213
|
}
|
|
196
214
|
getModel() {
|
|
197
215
|
return this.model;
|
|
@@ -386,7 +404,7 @@ class AudioWindowPreparer {
|
|
|
386
404
|
/**
|
|
387
405
|
* Decode audio window for a clip
|
|
388
406
|
*/
|
|
389
|
-
async decodeAudioWindow(clipId, startUs, endUs, strictMode = false, source) {
|
|
407
|
+
async decodeAudioWindow(clipId, startUs, endUs, strictMode = false, source, signal) {
|
|
390
408
|
if (source) this.checkCurrent(source);
|
|
391
409
|
if (this.failedDecodeClips.has(clipId)) {
|
|
392
410
|
if (strictMode) {
|
|
@@ -413,6 +431,7 @@ class AudioWindowPreparer {
|
|
|
413
431
|
return;
|
|
414
432
|
}
|
|
415
433
|
if (audioRecord.pcm) {
|
|
434
|
+
const owner = signal ? AbortSignal.any([this.lifecycle.signal, signal]) : this.lifecycle.signal;
|
|
416
435
|
try {
|
|
417
436
|
await this.decodeWavWindow(
|
|
418
437
|
clipId,
|
|
@@ -421,15 +440,154 @@ class AudioWindowPreparer {
|
|
|
421
440
|
endUs,
|
|
422
441
|
clip.durationUs,
|
|
423
442
|
clip.startUs,
|
|
424
|
-
source
|
|
443
|
+
source,
|
|
444
|
+
owner
|
|
425
445
|
);
|
|
426
446
|
} catch (error) {
|
|
447
|
+
if (owner.aborted) {
|
|
448
|
+
throw owner.reason ?? new DOMException("Audio decode cancelled", "AbortError");
|
|
449
|
+
}
|
|
427
450
|
if (source) this.checkCurrent(source);
|
|
428
451
|
if (error instanceof RangeError) throw error;
|
|
429
452
|
await this.handleDecodeFailure(clipId, error, strictMode);
|
|
430
453
|
}
|
|
431
454
|
return;
|
|
432
455
|
}
|
|
456
|
+
if (audioRecord.indexed) {
|
|
457
|
+
const owner = signal ? AbortSignal.any([this.lifecycle.signal, signal]) : this.lifecycle.signal;
|
|
458
|
+
let windowChunks2;
|
|
459
|
+
let trim2;
|
|
460
|
+
try {
|
|
461
|
+
if (audioRecord.metadata.codec.startsWith("mp4a")) {
|
|
462
|
+
const { chunks, preroll } = await readIndexedAACWindow(
|
|
463
|
+
audioRecord.indexed,
|
|
464
|
+
source?.aacTimeline,
|
|
465
|
+
startUs,
|
|
466
|
+
endUs,
|
|
467
|
+
owner
|
|
468
|
+
);
|
|
469
|
+
windowChunks2 = chunks;
|
|
470
|
+
if (preroll > 0) {
|
|
471
|
+
const { sampleRate } = audioRecord.metadata;
|
|
472
|
+
const toFrames = (us) => Math.round(us * sampleRate / 1e6);
|
|
473
|
+
trim2 = {
|
|
474
|
+
skipSamples: 0,
|
|
475
|
+
sampleRate,
|
|
476
|
+
physicalStart: toFrames(chunks[0].timestamp),
|
|
477
|
+
validStart: toFrames(chunks[preroll].timestamp),
|
|
478
|
+
validEnd: Number.POSITIVE_INFINITY
|
|
479
|
+
};
|
|
480
|
+
}
|
|
481
|
+
} else if (audioRecord.gapless) {
|
|
482
|
+
const { skipSamples, trimEndSamples, samplesPerFrame } = audioRecord.gapless;
|
|
483
|
+
const idxSamples = audioRecord.indexed.samples;
|
|
484
|
+
const sampleRate = audioRecord.metadata.sampleRate;
|
|
485
|
+
const validStart = Math.max(
|
|
486
|
+
skipSamples,
|
|
487
|
+
Math.ceil(startUs * sampleRate / 1e6) + skipSamples
|
|
488
|
+
);
|
|
489
|
+
const validEnd = Math.min(
|
|
490
|
+
idxSamples.length * samplesPerFrame - trimEndSamples,
|
|
491
|
+
Math.ceil(endUs * sampleRate / 1e6) + skipSamples
|
|
492
|
+
);
|
|
493
|
+
if (validEnd <= validStart) return;
|
|
494
|
+
const first = Math.floor(validStart / samplesPerFrame);
|
|
495
|
+
const last = Math.min(idxSamples.length, Math.ceil(validEnd / samplesPerFrame));
|
|
496
|
+
const decodeStart = this.indexedMp3PrerollStart(audioRecord.indexed, first);
|
|
497
|
+
const built = new Array(last - decodeStart);
|
|
498
|
+
await readSampleByteSlice(
|
|
499
|
+
idxSamples,
|
|
500
|
+
audioRecord.indexed.readRange,
|
|
501
|
+
decodeStart,
|
|
502
|
+
last,
|
|
503
|
+
(idx, bytes) => {
|
|
504
|
+
const s = idxSamples[idx];
|
|
505
|
+
built[idx - decodeStart] = new EncodedAudioChunk({
|
|
506
|
+
type: "key",
|
|
507
|
+
timestamp: Math.round(s.timestamp),
|
|
508
|
+
duration: Math.max(0, Math.round(s.duration)),
|
|
509
|
+
data: bytes
|
|
510
|
+
});
|
|
511
|
+
},
|
|
512
|
+
owner
|
|
513
|
+
);
|
|
514
|
+
windowChunks2 = built.filter(Boolean);
|
|
515
|
+
trim2 = {
|
|
516
|
+
skipSamples,
|
|
517
|
+
sampleRate,
|
|
518
|
+
validStart: Math.max(skipSamples, first * samplesPerFrame),
|
|
519
|
+
validEnd: Math.min(
|
|
520
|
+
idxSamples.length * samplesPerFrame - trimEndSamples,
|
|
521
|
+
last * samplesPerFrame
|
|
522
|
+
),
|
|
523
|
+
physicalStart: decodeStart * samplesPerFrame
|
|
524
|
+
};
|
|
525
|
+
} else {
|
|
526
|
+
const idxSamples = audioRecord.indexed.samples;
|
|
527
|
+
const first = binarySearchFirst(idxSamples, (s) => s.timestamp + s.duration > startUs);
|
|
528
|
+
let last = first;
|
|
529
|
+
while (last < idxSamples.length && idxSamples[last].timestamp < endUs) last++;
|
|
530
|
+
if (first >= last) {
|
|
531
|
+
windowChunks2 = [];
|
|
532
|
+
} else {
|
|
533
|
+
const isMp3 = audioRecord.metadata.codec === "mp3";
|
|
534
|
+
const decodeStart = isMp3 && first > 0 ? this.indexedMp3PrerollStart(audioRecord.indexed, first) : first;
|
|
535
|
+
const built = new Array(last - decodeStart);
|
|
536
|
+
await readSampleByteSlice(
|
|
537
|
+
idxSamples,
|
|
538
|
+
audioRecord.indexed.readRange,
|
|
539
|
+
decodeStart,
|
|
540
|
+
last,
|
|
541
|
+
(idx, bytes) => {
|
|
542
|
+
const s = idxSamples[idx];
|
|
543
|
+
built[idx - decodeStart] = new EncodedAudioChunk({
|
|
544
|
+
type: s.isKeyframe ? "key" : "delta",
|
|
545
|
+
timestamp: Math.round(s.timestamp),
|
|
546
|
+
duration: Math.max(0, Math.round(s.duration)),
|
|
547
|
+
data: bytes
|
|
548
|
+
});
|
|
549
|
+
},
|
|
550
|
+
owner
|
|
551
|
+
);
|
|
552
|
+
windowChunks2 = built.filter(Boolean);
|
|
553
|
+
if (isMp3 && decodeStart < first) {
|
|
554
|
+
const { sampleRate } = audioRecord.metadata;
|
|
555
|
+
const toFrames = (us) => Math.round(us * sampleRate / 1e6);
|
|
556
|
+
trim2 = {
|
|
557
|
+
skipSamples: 0,
|
|
558
|
+
sampleRate,
|
|
559
|
+
physicalStart: toFrames(idxSamples[decodeStart].timestamp),
|
|
560
|
+
validStart: toFrames(idxSamples[first].timestamp),
|
|
561
|
+
validEnd: Number.POSITIVE_INFINITY
|
|
562
|
+
};
|
|
563
|
+
}
|
|
564
|
+
}
|
|
565
|
+
}
|
|
566
|
+
} catch (error) {
|
|
567
|
+
if (owner.aborted) {
|
|
568
|
+
throw owner.reason ?? new DOMException("Audio decode cancelled", "AbortError");
|
|
569
|
+
}
|
|
570
|
+
this.deps.resourceLoader.reportByteFailure(
|
|
571
|
+
audioRecord.resourceId,
|
|
572
|
+
error,
|
|
573
|
+
() => !owner.aborted && this.deps.cacheManager.audioSampleCache.get(audioRecord.resourceId) === audioRecord
|
|
574
|
+
);
|
|
575
|
+
throw error;
|
|
576
|
+
}
|
|
577
|
+
if (windowChunks2.length === 0) return;
|
|
578
|
+
await this.decodeAudioSamples(
|
|
579
|
+
clipId,
|
|
580
|
+
windowChunks2,
|
|
581
|
+
audioRecord.metadata,
|
|
582
|
+
clip.durationUs,
|
|
583
|
+
clip.startUs,
|
|
584
|
+
strictMode,
|
|
585
|
+
trim2,
|
|
586
|
+
source,
|
|
587
|
+
signal
|
|
588
|
+
);
|
|
589
|
+
return;
|
|
590
|
+
}
|
|
433
591
|
if (audioRecord.gapless) {
|
|
434
592
|
const { skipSamples, trimEndSamples, samplesPerFrame } = audioRecord.gapless;
|
|
435
593
|
const sampleRate = audioRecord.metadata.sampleRate;
|
|
@@ -463,7 +621,8 @@ class AudioWindowPreparer {
|
|
|
463
621
|
),
|
|
464
622
|
physicalStart: decodeStart * samplesPerFrame
|
|
465
623
|
},
|
|
466
|
-
source
|
|
624
|
+
source,
|
|
625
|
+
signal
|
|
467
626
|
);
|
|
468
627
|
return;
|
|
469
628
|
}
|
|
@@ -489,10 +648,16 @@ class AudioWindowPreparer {
|
|
|
489
648
|
};
|
|
490
649
|
}
|
|
491
650
|
} else {
|
|
492
|
-
|
|
493
|
-
|
|
494
|
-
|
|
495
|
-
|
|
651
|
+
const first = binarySearchFirst(
|
|
652
|
+
audioRecord.samples,
|
|
653
|
+
(s) => s.timestamp + (s.duration ?? 0) > startUs
|
|
654
|
+
);
|
|
655
|
+
windowChunks = [];
|
|
656
|
+
for (let i = first; i < audioRecord.samples.length; i++) {
|
|
657
|
+
const s = audioRecord.samples[i];
|
|
658
|
+
if (s.timestamp >= endUs) break;
|
|
659
|
+
if (s.timestamp + (s.duration ?? 0) > startUs) windowChunks.push(s);
|
|
660
|
+
}
|
|
496
661
|
}
|
|
497
662
|
if (windowChunks.length === 0) {
|
|
498
663
|
return;
|
|
@@ -505,10 +670,11 @@ class AudioWindowPreparer {
|
|
|
505
670
|
clip.startUs,
|
|
506
671
|
strictMode,
|
|
507
672
|
trim,
|
|
508
|
-
source
|
|
673
|
+
source,
|
|
674
|
+
signal
|
|
509
675
|
);
|
|
510
676
|
}
|
|
511
|
-
async decodeWavWindow(clipId, record, startUs, endUs, clipDurationUs, clipStartUs, source) {
|
|
677
|
+
async decodeWavWindow(clipId, record, startUs, endUs, clipDurationUs, clipStartUs, source, signal) {
|
|
512
678
|
const index = record.pcm;
|
|
513
679
|
const first = Math.max(0, Math.floor(startUs * index.sampleRate / 1e6));
|
|
514
680
|
const last = Math.min(index.numberOfFrames, Math.ceil(endUs * index.sampleRate / 1e6));
|
|
@@ -544,11 +710,24 @@ class AudioWindowPreparer {
|
|
|
544
710
|
let batchEnd = Math.min(index.numberOfFrames, frame + blockFrames);
|
|
545
711
|
while (batchEnd < last && batchEnd - frame < batchFrames && !covered(batchEnd))
|
|
546
712
|
batchEnd = Math.min(index.numberOfFrames, batchEnd + blockFrames);
|
|
547
|
-
|
|
548
|
-
|
|
549
|
-
|
|
550
|
-
|
|
551
|
-
|
|
713
|
+
let bytes;
|
|
714
|
+
try {
|
|
715
|
+
bytes = await untilAborted(
|
|
716
|
+
this.deps.cacheManager.resourceCache.readAudioRange(
|
|
717
|
+
record.resourceId,
|
|
718
|
+
index.dataOffset + frame * index.blockAlign,
|
|
719
|
+
index.dataOffset + batchEnd * index.blockAlign
|
|
720
|
+
),
|
|
721
|
+
signal
|
|
722
|
+
);
|
|
723
|
+
} catch (error) {
|
|
724
|
+
this.deps.resourceLoader.reportByteFailure(
|
|
725
|
+
record.resourceId,
|
|
726
|
+
error,
|
|
727
|
+
() => !signal?.aborted && this.deps.cacheManager.audioSampleCache.get(record.resourceId) === record
|
|
728
|
+
);
|
|
729
|
+
throw error;
|
|
730
|
+
}
|
|
552
731
|
if (source) this.checkCurrent(source);
|
|
553
732
|
if (bytes.byteLength !== (batchEnd - frame) * index.blockAlign)
|
|
554
733
|
throw new Error("Truncated WAV PCM range");
|
|
@@ -579,6 +758,16 @@ class AudioWindowPreparer {
|
|
|
579
758
|
frame = batchEnd;
|
|
580
759
|
}
|
|
581
760
|
}
|
|
761
|
+
indexedMp3PrerollStart(indexed, first) {
|
|
762
|
+
let start = Math.max(0, first - 2);
|
|
763
|
+
const mainDataBytes = indexed.mainDataBytes;
|
|
764
|
+
if (!mainDataBytes) return start;
|
|
765
|
+
let reservoirBytes = 0;
|
|
766
|
+
while (start > 0 && reservoirBytes < 511) {
|
|
767
|
+
reservoirBytes += mainDataBytes[--start] ?? 0;
|
|
768
|
+
}
|
|
769
|
+
return start;
|
|
770
|
+
}
|
|
582
771
|
/** Restore two synthesis frames plus their maximum bit reservoir before a seek. */
|
|
583
772
|
mp3PrerollStart(record, first) {
|
|
584
773
|
let start = Math.max(0, first - 2);
|
|
@@ -602,6 +791,7 @@ class AudioWindowPreparer {
|
|
|
602
791
|
async handleDecodeFailure(clipId, error, strictMode) {
|
|
603
792
|
console.error(`[AudioWindowPreparer] Decoder error for clip ${clipId}:`, error);
|
|
604
793
|
this.failedDecodeClips.add(clipId);
|
|
794
|
+
markReportedToHost(error);
|
|
605
795
|
this.deps.eventBus.emit(MeframeEvent.DecodeError, {
|
|
606
796
|
clipId,
|
|
607
797
|
error: error instanceof Error ? error : new Error(String(error))
|
|
@@ -613,7 +803,7 @@ class AudioWindowPreparer {
|
|
|
613
803
|
/**
|
|
614
804
|
* Decode audio samples to PCM and cache
|
|
615
805
|
*/
|
|
616
|
-
async decodeAudioSamples(clipId, samples, config, clipDurationUs, clipStartUs, strictMode = false, gapless, source) {
|
|
806
|
+
async decodeAudioSamples(clipId, samples, config, clipDurationUs, clipStartUs, strictMode = false, gapless, source, request) {
|
|
617
807
|
let description;
|
|
618
808
|
if (config.description) {
|
|
619
809
|
if (config.description instanceof ArrayBuffer) {
|
|
@@ -641,6 +831,10 @@ class AudioWindowPreparer {
|
|
|
641
831
|
await this.handleDecodeFailure(clipId, error, strictMode);
|
|
642
832
|
return;
|
|
643
833
|
}
|
|
834
|
+
const signal = request ? AbortSignal.any([this.lifecycle.signal, request]) : this.lifecycle.signal;
|
|
835
|
+
const cancelDecoder = () => decoder.cancel(signal.reason);
|
|
836
|
+
if (signal.aborted) cancelDecoder();
|
|
837
|
+
else signal.addEventListener("abort", cancelDecoder, { once: true });
|
|
644
838
|
try {
|
|
645
839
|
const chunkStream = new ReadableStream({
|
|
646
840
|
start(controller) {
|
|
@@ -690,12 +884,20 @@ class AudioWindowPreparer {
|
|
|
690
884
|
reader.releaseLock();
|
|
691
885
|
}
|
|
692
886
|
} catch (error) {
|
|
887
|
+
if (signal.aborted) {
|
|
888
|
+
throw signal.reason ?? new DOMException("Audio decode cancelled", "AbortError");
|
|
889
|
+
}
|
|
693
890
|
if (source) this.checkCurrent(source);
|
|
694
891
|
if (error instanceof RangeError) throw error;
|
|
695
892
|
await this.handleDecodeFailure(clipId, error, strictMode);
|
|
696
893
|
return;
|
|
697
894
|
} finally {
|
|
698
|
-
|
|
895
|
+
try {
|
|
896
|
+
if (signal.aborted) decoder.cancel(signal.reason);
|
|
897
|
+
else await decoder.close();
|
|
898
|
+
} finally {
|
|
899
|
+
signal.removeEventListener("abort", cancelDecoder);
|
|
900
|
+
}
|
|
699
901
|
}
|
|
700
902
|
}
|
|
701
903
|
/**
|
|
@@ -727,31 +929,22 @@ class AudioWindowPreparer {
|
|
|
727
929
|
}
|
|
728
930
|
function sliceAudioData(src, headFrames, tailFrames, timestamp) {
|
|
729
931
|
const keep = src.numberOfFrames - headFrames - tailFrames;
|
|
730
|
-
const
|
|
731
|
-
const
|
|
732
|
-
const
|
|
733
|
-
|
|
734
|
-
|
|
735
|
-
|
|
736
|
-
|
|
737
|
-
|
|
738
|
-
});
|
|
739
|
-
const buffer = new ArrayBuffer(planeSize * planes);
|
|
740
|
-
for (let plane = 0; plane < planes; plane++) {
|
|
741
|
-
src.copyTo(new Uint8Array(buffer, plane * planeSize, planeSize), {
|
|
742
|
-
planeIndex: plane,
|
|
743
|
-
format,
|
|
744
|
-
frameOffset: headFrames,
|
|
745
|
-
frameLength: keep
|
|
746
|
-
});
|
|
932
|
+
const channels = src.numberOfChannels;
|
|
933
|
+
const planes = extractPlanesFromAudioData(src, channels, src.numberOfFrames);
|
|
934
|
+
const packed = new Float32Array(keep * channels);
|
|
935
|
+
for (let ch = 0; ch < channels; ch++) {
|
|
936
|
+
const channelData = planes[ch];
|
|
937
|
+
if (channelData) {
|
|
938
|
+
packed.set(channelData.subarray(headFrames, headFrames + keep), ch * keep);
|
|
939
|
+
}
|
|
747
940
|
}
|
|
748
941
|
return new AudioData({
|
|
749
|
-
format,
|
|
942
|
+
format: "f32-planar",
|
|
750
943
|
sampleRate: src.sampleRate,
|
|
751
944
|
numberOfFrames: keep,
|
|
752
|
-
numberOfChannels:
|
|
945
|
+
numberOfChannels: channels,
|
|
753
946
|
timestamp,
|
|
754
|
-
data: buffer
|
|
947
|
+
data: packed.buffer
|
|
755
948
|
});
|
|
756
949
|
}
|
|
757
950
|
export {
|