@@ -45,45 +45,40 @@ defmodule Membrane.Core.Element.ActionHandler do
45
45
46
46
defguardp is_demand_size ( size ) when is_integer ( size ) or is_function ( size )
47
47
48
+ # Match in the function below is caused by a fact, that handle_spec_started is the only callback, that
49
+ # might be executed in between handling actions returned from other callbacks.
50
+ # This callback has been deprecated and should be removed in v2.0.0, along with the if statement below.
51
+
48
52
@ impl CallbackHandler
49
- def handle_end_of_actions ( callback , state ) do
53
+ def handle_end_of_actions ( :handle_spec_started , state ) , do: state
54
+
55
+ def handle_end_of_actions ( _callback , state ) do
50
56
# Fixed order of handling demand of manual and auto pads would lead to
51
57
# favoring manual pads over auto pads (or vice versa), especially after
52
58
# introducting auto flow queues.
53
59
54
- # Condition in if below is caused by a fact, that handle_spec_started is the only callback, that might
55
- # be executed in between handling actions returned from other callbacks.
56
- # This callback has been deprecated and should be removed in v2.0.0, along with the if statement below.
57
-
58
- if callback != :handle_spec_started do
59
- if Enum . random ( [ 1 , 2 ] ) == 1 do
60
- snapshot ( callback , state )
61
- |> hdd ( )
62
- else
63
- state
64
- |> hdd ( )
65
- |> then ( & snapshot ( callback , & 1 ) )
66
- end
60
+ if Enum . random ( [ true , false ] ) do
61
+ state
62
+ |> handle_pads_to_snapshot ( )
63
+ |> maybe_handle_delayed_demands ( )
67
64
else
68
65
state
66
+ |> maybe_handle_delayed_demands ( )
67
+ |> handle_pads_to_snapshot ( )
69
68
end
70
69
end
71
70
72
- defp hdd ( state ) do
71
+ defp maybe_handle_delayed_demands ( state ) do
73
72
with % { delay_demands?: false } <- state do
74
73
ManualFlowController . handle_delayed_demands ( state )
75
74
end
76
75
end
77
76
78
- defp snapshot ( callback , state ) do
79
- if callback != :handle_spec_started do
80
- state . pads_to_snapshot
81
- |> Enum . shuffle ( )
82
- |> Enum . reduce ( state , & DemandController . snapshot_atomic_demand / 2 )
83
- |> Map . put ( :pads_to_snapshot , MapSet . new ( ) )
84
- else
85
- state
86
- end
77
+ defp handle_pads_to_snapshot ( state ) do
78
+ state . pads_to_snapshot
79
+ |> Enum . shuffle ( )
80
+ |> Enum . reduce ( state , & DemandController . snapshot_atomic_demand / 2 )
81
+ |> Map . put ( :pads_to_snapshot , MapSet . new ( ) )
87
82
end
88
83
89
84
@ impl CallbackHandler
@@ -245,7 +240,7 @@ defmodule Membrane.Core.Element.ActionHandler do
245
240
% State { type: type } = state
246
241
)
247
242
when is_pad_ref ( pad_ref ) and is_demand_size ( size ) and type in [ :sink , :filter , :endpoint ] do
248
- delay_supplying_demand ( pad_ref , size , state )
243
+ delay_supplying_demand ( pad_ref , size , state )
249
244
end
250
245
251
246
@ impl CallbackHandler
0 commit comments