Skip to content

Commit

Permalink
Make frame slice be really at most. (#4104)
Browse files Browse the repository at this point in the history
  • Loading branch information
toots authored Aug 24, 2024
1 parent 7ea8632 commit 4980bc0
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 1 deletion.
2 changes: 1 addition & 1 deletion src/core/stream/frame.ml
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ let create ~length content_type =

let content_type = Fields.map Content.format
let sub frame ofs len = Fields.map (fun c -> Content.sub c ofs len) frame
let slice frame len = sub frame 0 len
let slice frame len = sub frame 0 (min len (position frame))
let after frame offset = sub frame offset (position frame - offset)

let append f f' =
Expand Down
4 changes: 4 additions & 0 deletions tests/core/frame_test.ml
Original file line number Diff line number Diff line change
Expand Up @@ -4,3 +4,7 @@ let () =
(Frame.Fields.make ~audio:(Format_type.audio ()) ())
in
Typing.(pcm_t <: Lang.univ_t ())

let () =
let f = Frame.create ~length:10 (Frame.Fields.from_list []) in
assert (Frame.position (Frame.slice f 20) = 10)

0 comments on commit 4980bc0

Please sign in to comment.