mwg API
    Preparing search index...

    Function guardBlockSource

    • Wraps a BlockSource so a misbehaving decoder cannot hurt the game: a read that claims more frames than it was given room for is an error, non-finite or wildly loud samples are zeroed or clamped, the stream ends at maxSeconds whatever the file says, and a source that keeps taking longer to produce audio than the audio lasts is cut after maxStarvedReads in a row rather than being allowed to starve the page.

      Parameters

      Returns BlockSource

      import { guardBlockSource, type BlockSource } from '@datamoc/mwg/audio';

      declare const untrusted: BlockSource;

      const safe = guardBlockSource(untrusted, { maxSeconds: 600 });