@@ -24,26 +24,37 @@ open Mm
24
24
open Source
25
25
26
26
class blank duration =
27
- let ticks = if duration < 0. then - 1 else Frame. main_of_seconds duration in
27
+ let ticks () =
28
+ let d = duration () in
29
+ if d < 0. then - 1 else Frame. main_of_seconds d
30
+ in
28
31
object (self )
29
32
inherit source ~name: " blank" ()
30
33
31
34
(* * Remaining time, -1 for infinity. *)
32
- val mutable remaining = ticks
35
+ val mutable remaining = None
36
+
37
+ method remaining =
38
+ match remaining with
39
+ | Some r -> r
40
+ | None ->
41
+ let r = ticks () in
42
+ remaining < - Some r;
43
+ r
33
44
34
- method remaining = remaining
35
45
method stype = `Infallible
36
46
method private _is_ready ?frame : _ _ = true
37
47
method self_sync = (`Static , false )
38
48
method! seek x = x
39
49
method seek_source = (self :> Source.source )
40
- method abort_track = remaining < - 0
50
+ method abort_track = remaining < - Some 0
41
51
42
52
method get_frame ab =
43
53
let position = Frame. position ab in
54
+ let rem = self#remaining in
44
55
let length =
45
- if remaining < 0 then Lazy. force Frame. size - position
46
- else min remaining (Lazy. force Frame. size - position)
56
+ if rem < 0 then Lazy. force Frame. size - position
57
+ else min rem (Lazy. force Frame. size - position)
47
58
in
48
59
let audio_pos = Frame. audio_of_main position in
49
60
let audio_len = Frame. audio_of_main length in
@@ -73,8 +84,8 @@ class blank duration =
73
84
self#content_type;
74
85
75
86
Frame. add_break ab (position + length);
76
- if Frame. is_partial ab then remaining < - ticks
77
- else if remaining > 0 then remaining < - remaining - length
87
+ if Frame. is_partial ab then remaining < - None
88
+ else if rem > 0 then remaining < - Some (rem - length)
78
89
end
79
90
80
91
let blank =
@@ -83,12 +94,12 @@ let blank =
83
94
~descr: " Produce silence and blank images." ~return_t
84
95
[
85
96
( " duration" ,
86
- Lang. float_t,
97
+ Lang. getter_t Lang. float_t,
87
98
Some (Lang. float (- 1. )),
88
99
Some
89
100
" Duration of blank tracks in seconds, Negative value means forever."
90
101
);
91
102
]
92
103
(fun p ->
93
- let d = Lang. to_float (List. assoc " duration" p) in
104
+ let d = Lang. to_float_getter (List. assoc " duration" p) in
94
105
(new blank d :> source ))
0 commit comments