@dawcore/transport 0.0.5 → 0.0.6

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/dist/index.js CHANGED
@@ -889,7 +889,7 @@ var ClipPlayer = class {
889
889
  if (!clip.audioBuffer) continue;
890
890
  const clipStartSample = clip.startSample;
891
891
  const clipEndSample = clipStartSample + clip.durationSamples;
892
- if (clipStartSample <= newSample && clipEndSample > newSample) {
892
+ if (clipStartSample < newSample && clipEndSample > newSample) {
893
893
  const offsetIntoClipSamples = newSample - clipStartSample;
894
894
  const offsetSamples = clip.offsetSamples + offsetIntoClipSamples;
895
895
  let durationSamples = clipEndSample - newSample;
@@ -1816,6 +1816,27 @@ var NativePlayoutAdapter = class {
1816
1816
  }
1817
1817
  if (this._audioContext.state === "suspended") {
1818
1818
  await this._audioContext.resume();
1819
+ const MIN_WARMUP = 0.02;
1820
+ const warmupTarget = Math.max(MIN_WARMUP, this._audioContext.outputLatency ?? MIN_WARMUP);
1821
+ if (this._audioContext.currentTime < warmupTarget) {
1822
+ const MAX_WARMUP_MS = 2e3;
1823
+ await new Promise((resolve) => {
1824
+ const startMs = performance.now();
1825
+ const check = () => {
1826
+ if (this._audioContext.currentTime >= warmupTarget) {
1827
+ resolve();
1828
+ } else if (this._audioContext.state === "closed" || performance.now() - startMs > MAX_WARMUP_MS) {
1829
+ console.warn(
1830
+ "[waveform-playlist] AudioContext warmup timed out (currentTime=" + this._audioContext.currentTime + ", target=" + warmupTarget + ", state=" + this._audioContext.state + "). Proceeding without warmup."
1831
+ );
1832
+ resolve();
1833
+ } else {
1834
+ requestAnimationFrame(check);
1835
+ }
1836
+ };
1837
+ requestAnimationFrame(check);
1838
+ });
1839
+ }
1819
1840
  }
1820
1841
  }
1821
1842
  setTracks(tracks) {