Documentation ¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
var ErrPanic = &PanicErr{}
ErrPanic is used to check for a PanicErr with errors.Is, and should not be used for anything else.
Functions ¶
This section is empty.
Types ¶
type FrameLoop ¶
type FrameLoop struct {
// contains filtered or unexported fields
}
func New ¶
func New( ctx context.Context, target io.Writer, frameRate int, frames <-chan *Frame, sent chan *Frame, ) *FrameLoop
New creates a new frame loop.
The frames channel is used to get the frames to be written to the target writer. The given frameRate will be maintained by writing the last received frame again if a new frame was not received in time.
If the sent channel is not nil, then every written frame will be sent to it right after it was written. If the same frame was written again due to not receiving a new one, then that frame will be sent again. However, a full sent channel will lose frames (non-blocking sends).
Every received frame will be written at least once before a new frame is accepted, unless the frame loop ends first.
The loop will start when the first frame is received, and will end after ctx is done, or Stop() is called, or a write error occurs.
func (*FrameLoop) Done ¶
func (fl *FrameLoop) Done() <-chan struct{}
Done returns a channel that will be closed when the frame loop has ended and will not write any more frames.
func (*FrameLoop) Err ¶
Err will return any error that occurred in the frame loop. It will be valid once the frame loop has ended, and the Stop channel is closed.
func (*FrameLoop) Stop ¶
func (fl *FrameLoop) Stop()
Stop will cause the frame loop to end, and not write out any more frames.
Calling Stop may cause a received frame to not be written out, if the time to write it out has not yet arrived. However, a frame that is already being written will be completed before the loop is ended, to avoid writing partial frames.
type PanicErr ¶
type PanicErr struct { // Where is where the panic occurred, and is used in the message. Where string // Value is the recovered value from the panic. Value interface{} }
PanicErr is used when a panic is turned into an error.
If the panic value is an error, this error unwraps into that error.