@@ -32,7 +32,7 @@ defmodule Membrane.Core.Element.DemandHandler do
32
32
output, `handle_demand` is invoked right away, so that the demand can be synchronously supplied.
33
33
"""
34
34
@ spec handle_redemand ( Pad . ref ( ) , State . t ( ) ) :: State . t ( )
35
- def handle_redemand ( pad_ref , % State { supplying_demand ?: true } = state ) do
35
+ def handle_redemand ( pad_ref , % State { delay_consuming_queues ?: true } = state ) do
36
36
Map . update! ( state , :delayed_demands , & MapSet . put ( & 1 , { pad_ref , :redemand } ) )
37
37
end
38
38
@@ -42,9 +42,9 @@ defmodule Membrane.Core.Element.DemandHandler do
42
42
end
43
43
44
44
defp do_handle_redemand ( pad_ref , state ) do
45
- state = % { state | supplying_demand ?: true }
45
+ state = % { state | delay_consuming_queues ?: true }
46
46
state = exec_handle_demand ( pad_ref , state )
47
- % { state | supplying_demand ?: false }
47
+ % { state | delay_consuming_queues ?: false }
48
48
end
49
49
50
50
@ doc """
@@ -74,7 +74,7 @@ defmodule Membrane.Core.Element.DemandHandler do
74
74
end
75
75
76
76
@ spec supply_demand ( Pad . ref ( ) , State . t ( ) ) :: State . t ( )
77
- def supply_demand ( pad_ref , % State { supplying_demand ?: true } = state ) do
77
+ def supply_demand ( pad_ref , % State { delay_consuming_queues ?: true } = state ) do
78
78
Map . update! ( state , :delayed_demands , & MapSet . put ( & 1 , { pad_ref , :supply } ) )
79
79
end
80
80
@@ -85,7 +85,7 @@ defmodule Membrane.Core.Element.DemandHandler do
85
85
86
86
defp do_supply_demand ( pad_ref , state ) do
87
87
# marking is state that actual demand supply has been started (note changing back to false when finished)
88
- state = % State { state | supplying_demand ?: true }
88
+ state = % State { state | delay_consuming_queues ?: true }
89
89
90
90
pad_data = state |> PadModel . get_data! ( pad_ref )
91
91
@@ -94,7 +94,7 @@ defmodule Membrane.Core.Element.DemandHandler do
94
94
95
95
state = PadModel . set_data! ( state , pad_ref , :input_queue , new_input_queue )
96
96
state = handle_input_queue_output ( pad_ref , popped_data , state )
97
- % State { state | supplying_demand ?: false }
97
+ % State { state | delay_consuming_queues ?: false }
98
98
end
99
99
100
100
defp update_demand ( pad_ref , size , state ) when is_integer ( size ) do
@@ -120,8 +120,9 @@ defmodule Membrane.Core.Element.DemandHandler do
120
120
# one pad are supplied right away while another one is waiting for buffers
121
121
# potentially for a long time.
122
122
123
+ state =
123
124
cond do
124
- state . supplying_demand ? ->
125
+ state . delay_consuming_queues ? ->
125
126
raise "Cannot handle delayed demands while already supplying demand"
126
127
127
128
state . handle_demand_loop_counter >= @ handle_demand_loop_limit ->
@@ -144,6 +145,10 @@ defmodule Membrane.Core.Element.DemandHandler do
144
145
:redemand -> handle_redemand ( pad_ref , state )
145
146
end
146
147
end
148
+
149
+ Enum . reduce ( state . pads_to_snapshot , state , & Membrane.Core.Element.DemandController . snapshot_atomic_demand / 2 )
150
+ |> Map . put ( :pads_to_snapshot , MapSet . new ( ) )
151
+
147
152
end
148
153
149
154
@ spec remove_pad_from_delayed_demands ( Pad . ref ( ) , State . t ( ) ) :: State . t ( )
0 commit comments