@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.mjs CHANGED
@@ -852,7 +852,7 @@ var ClipPlayer = class {
852
852
  if (!clip.audioBuffer) continue;
853
853
  const clipStartSample = clip.startSample;
854
854
  const clipEndSample = clipStartSample + clip.durationSamples;
855
- if (clipStartSample <= newSample && clipEndSample > newSample) {
855
+ if (clipStartSample < newSample && clipEndSample > newSample) {
856
856
  const offsetIntoClipSamples = newSample - clipStartSample;
857
857
  const offsetSamples = clip.offsetSamples + offsetIntoClipSamples;
858
858
  let durationSamples = clipEndSample - newSample;
@@ -1779,6 +1779,27 @@ var NativePlayoutAdapter = class {
1779
1779
  }
1780
1780
  if (this._audioContext.state === "suspended") {
1781
1781
  await this._audioContext.resume();
1782
+ const MIN_WARMUP = 0.02;
1783
+ const warmupTarget = Math.max(MIN_WARMUP, this._audioContext.outputLatency ?? MIN_WARMUP);
1784
+ if (this._audioContext.currentTime < warmupTarget) {
1785
+ const MAX_WARMUP_MS = 2e3;
1786
+ await new Promise((resolve) => {
1787
+ const startMs = performance.now();
1788
+ const check = () => {
1789
+ if (this._audioContext.currentTime >= warmupTarget) {
1790
+ resolve();
1791
+ } else if (this._audioContext.state === "closed" || performance.now() - startMs > MAX_WARMUP_MS) {
1792
+ console.warn(
1793
+ "[waveform-playlist] AudioContext warmup timed out (currentTime=" + this._audioContext.currentTime + ", target=" + warmupTarget + ", state=" + this._audioContext.state + "). Proceeding without warmup."
1794
+ );
1795
+ resolve();
1796
+ } else {
1797
+ requestAnimationFrame(check);
1798
+ }
1799
+ };
1800
+ requestAnimationFrame(check);
1801
+ });
1802
+ }
1782
1803
  }
1783
1804
  }
1784
1805
  setTracks(tracks) {