Refactoring #3

Merged
itten merged 87 commits from refactoring into main 2026-09-01 23:52:36 +03:00
Showing only changes of commit 61c770d722 - Show all commits
+1 -25
View File
@@ -102,31 +102,7 @@ func (s *Source) Close() error {
}
func (s *Source) Next(timeout time.Duration) (Frame, error) {
for {
g, err := s.reader.GetGrain(s.idx, timeout)
switch {
case err == nil:
f := Frame{
Index: g.Index,
Width: s.width,
Height: s.height,
Stride: s.stride,
Size: g.GrainSize,
Invalid: g.Invalid(),
Payload: g.Payload,
}
s.idx++
return f, nil
case errors.Is(err, mxl.ErrTimeout):
s.idx = mxl.CurrentIndex(s.rate)
case errors.Is(err, mxl.ErrOutOfRangeEarly):
time.Sleep(10 * time.Millisecond)
case errors.Is(err, mxl.ErrOutOfRangeLate):
s.idx = mxl.CurrentIndex(s.rate)
default:
return Frame{}, fmt.Errorf("GetGrain: %w", err)
}
}
return s.NextCtx(context.Background(), timeout)
}
func (s *Source) NextCtx(ctx context.Context, timeout time.Duration) (Frame, error) {