Package limn.video

Interface VideoFrame.Recycler

All Known Implementing Classes:
FramePool
Enclosing class:
VideoFrame
Functional Interface:
This is a functional interface and can therefore be used as the assignment target for a lambda expression or method reference.

@FunctionalInterface public static interface VideoFrame.Recycler
How a producer gets a released frame's memory back. The pool lives entirely on the producer's side: this carries VideoFrame.slot() and never an address, so a native producer's implementation is one call passing that integer across the boundary and a pure-Java producer's is that integer pushed onto a free list.

Invoked once per released frame, on whichever thread released it, so implementations must be thread-safe. It must not wait for anything: a producer blocked for a free slot stays blocked until this returns.

  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    static final VideoFrame.Recycler
    Recycles nothing, and exists for frames backed by ordinary garbage-collected memory whose producer will never refill the slot.
  • Method Summary

    Modifier and Type
    Method
    Description
    void
    Takes back the memory of a frame whose consumer has just released it.
  • Field Details

    • NONE

      static final VideoFrame.Recycler NONE
      Recycles nothing, and exists for frames backed by ordinary garbage-collected memory whose producer will never refill the slot. VideoFrame.release() is still required against this: it is what stops the planes being readable, and a consumer that omits it here will omit it against a real producer too.
  • Method Details

    • recycle

      void recycle(VideoFrame frame)
      Takes back the memory of a frame whose consumer has just released it. The slot is already marked free when this runs, so VideoFrame.plane(int) throws here and the frame is usable only through VideoFrame.slot() and the descriptive accessors, which is everything a free list or a native handback needs.
      Parameters:
      frame - the frame whose slot came free; never null