Skip to content

Commit

Permalink
Fix infinite loop on some active sources that do not properly call `s…
Browse files Browse the repository at this point in the history
…elf#has_ticked` (#3560)
  • Loading branch information
toots authored Nov 28, 2023
1 parent f44be68 commit 4181a8c
Show file tree
Hide file tree
Showing 7 changed files with 12 additions and 5 deletions.
2 changes: 2 additions & 0 deletions CHANGES.md
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,8 @@ Fixed:
(#3563)
- Fixed playlist parsers not being registered
when evaluatin top-level script (#3553)
- Fixed infinite loop on some active sources
(#3544)

---

Expand Down
10 changes: 5 additions & 5 deletions src/core/operators/muxer.ml
Original file line number Diff line number Diff line change
Expand Up @@ -53,11 +53,11 @@ class muxer tracks =

method abort_track = List.iter (fun s -> s#abort_track) sources

method private sources_ready ?frame () =
List.for_all (fun s -> s#is_ready ?frame ()) sources
method private sources_ready =
List.for_all (fun s -> s#is_ready ?frame:None ()) sources

method private _is_ready ?frame () =
Generator.length self#buffer > 0 || self#sources_ready ?frame ()
method private _is_ready ?frame:_ () =
Generator.length self#buffer > 0 || self#sources_ready

method! seek len =
let gen_len = min (Generator.length self#buffer) len in
Expand Down Expand Up @@ -130,7 +130,7 @@ class muxer tracks =
method private feed ~force buf =
let filled = Frame.position buf in
if
self#sources_ready ()
self#sources_ready
&& (force
|| Generator.remaining self#buffer = -1
&& filled + Generator.length self#buffer < Lazy.force Frame.size)
Expand Down
1 change: 1 addition & 0 deletions src/core/operators/noblank.ml
Original file line number Diff line number Diff line change
Expand Up @@ -142,6 +142,7 @@ class strip ~start_blank ~max_blank ~min_noise ~threshold ~track_sensitive
if self#is_blank then AFrame.set_breaks ab (p0 :: b0)

method private output =
self#has_ticked;
(* We only #get once in memo; this is why we can set_breaks every time in
#get_frame. This behavior makes time flow slower than expected, but
doesn't seem harmful. The advantage of doing this is that if stripping
Expand Down
1 change: 1 addition & 0 deletions src/core/sources/harbor_input.ml
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,7 @@ class http_input_server ~pos ~transport ~dumpfile ~logfile ~bufferize ~max ~icy
| None -> "no source client connected"

method private output =
self#has_ticked;
if self#is_ready ~frame:self#memo () && AFrame.is_partial self#memo then
self#get self#memo

Expand Down
1 change: 1 addition & 0 deletions src/core/synth/keyboard.ml
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,7 @@ class keyboard =
method self_sync = (`Static, false)

method output =
self#has_ticked;
if self#is_ready ~frame:self#memo () && AFrame.is_partial self#memo then
self#get self#memo

Expand Down
1 change: 1 addition & 0 deletions src/core/synth/keyboard_sdl.ml
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,7 @@ class keyboard velocity =
method self_sync = (`Static, false)

method output =
self#has_ticked;
if self#is_ready ~frame:self#memo () && AFrame.is_partial self#memo then
self#get self#memo

Expand Down
1 change: 1 addition & 0 deletions src/core/tools/start_stop.ml
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,7 @@ class virtual active_source ?get_clock ~name ~clock_safe
method virtual private memo : Frame.t

method private output =
self#has_ticked;
if self#is_ready ~frame:self#memo () && AFrame.is_partial self#memo then
self#get self#memo
end
Expand Down

0 comments on commit 4181a8c

Please sign in to comment.