Skip to content

Commit bc4ba89

Browse files
committed
Remove leftovers
1 parent 93de2fc commit bc4ba89

10 files changed

+21
-47
lines changed

lib/membrane/core/bin/state.ex

-2
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,6 @@ defmodule Membrane.Core.Bin.State do
4545
terminating?: boolean(),
4646
resource_guard: Membrane.ResourceGuard.t(),
4747
setup_incomplete?: boolean(),
48-
# handling_action?: boolean(),
4948
stalker: Membrane.Core.Stalker.t()
5049
}
5150

@@ -73,7 +72,6 @@ defmodule Membrane.Core.Bin.State do
7372
initialized?: false,
7473
terminating?: false,
7574
setup_incomplete?: false,
76-
# handling_action?: false,
7775
stalker: nil,
7876
resource_guard: nil,
7977
subprocess_supervisor: nil,

lib/membrane/core/callback_handler.ex

+1-9
Original file line numberDiff line numberDiff line change
@@ -132,7 +132,7 @@ defmodule Membrane.Core.CallbackHandler do
132132
%{context: context_fun},
133133
%{module: module, internal_state: internal_state} = state
134134
) do
135-
args = args ++ [context_fun.(state) |> Map.put(:s, state), internal_state]
135+
args = args ++ [context_fun.(state), internal_state]
136136

137137
callback_result =
138138
try do
@@ -188,9 +188,6 @@ defmodule Membrane.Core.CallbackHandler do
188188
reraise e, __STACKTRACE__
189189
end
190190

191-
# was_delay_demands? = Map.get(state, :delay_demands?, false)
192-
# state = if Component.is_element?(state), do: %{state | delay_demands?: true}, else: state
193-
194191
state =
195192
Enum.reduce(actions, state, fn action, state ->
196193
try do
@@ -205,11 +202,6 @@ defmodule Membrane.Core.CallbackHandler do
205202
end
206203
end)
207204

208-
# state =
209-
# if Component.is_element?(state) and not was_delay_demands?,
210-
# do: %{state | delay_demands?: false},
211-
# else: state
212-
213205
handler_module.handle_end_of_actions(callback, state)
214206
end
215207
end

lib/membrane/core/element/action_handler.ex

+20-25
Original file line numberDiff line numberDiff line change
@@ -45,45 +45,40 @@ defmodule Membrane.Core.Element.ActionHandler do
4545

4646
defguardp is_demand_size(size) when is_integer(size) or is_function(size)
4747

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+
4852
@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
5056
# Fixed order of handling demand of manual and auto pads would lead to
5157
# favoring manual pads over auto pads (or vice versa), especially after
5258
# introducting auto flow queues.
5359

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()
6764
else
6865
state
66+
|> maybe_handle_delayed_demands()
67+
|> handle_pads_to_snapshot()
6968
end
7069
end
7170

72-
defp hdd(state) do
71+
defp maybe_handle_delayed_demands(state) do
7372
with %{delay_demands?: false} <- state do
7473
ManualFlowController.handle_delayed_demands(state)
7574
end
7675
end
7776

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())
8782
end
8883

8984
@impl CallbackHandler
@@ -245,7 +240,7 @@ defmodule Membrane.Core.Element.ActionHandler do
245240
%State{type: type} = state
246241
)
247242
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)
249244
end
250245

251246
@impl CallbackHandler

lib/membrane/core/element/state.ex

-2
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,6 @@ defmodule Membrane.Core.Element.State do
4242
terminating?: boolean(),
4343
setup_incomplete?: boolean(),
4444
effective_flow_control: EffectiveFlowController.effective_flow_control(),
45-
# handling_action?: boolean(),
4645
popping_auto_flow_queue?: boolean(),
4746
pads_to_snapshot: MapSet.t(),
4847
stalker: Membrane.Core.Stalker.t(),
@@ -75,7 +74,6 @@ defmodule Membrane.Core.Element.State do
7574
terminating?: false,
7675
setup_incomplete?: false,
7776
delay_demands?: false,
78-
# handling_action?: false,
7977
popping_auto_flow_queue?: false,
8078
stalker: nil,
8179
resource_guard: nil,

lib/membrane/core/pipeline/state.ex

-2
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,6 @@ defmodule Membrane.Core.Pipeline.State do
3232
terminating?: boolean(),
3333
resource_guard: Membrane.ResourceGuard.t(),
3434
setup_incomplete?: boolean(),
35-
# handling_action?: boolean(),
3635
stalker: Membrane.Core.Stalker.t(),
3736
subprocess_supervisor: pid(),
3837
awaiting_setup_completition?: boolean()
@@ -56,7 +55,6 @@ defmodule Membrane.Core.Pipeline.State do
5655
initialized?: false,
5756
terminating?: false,
5857
setup_incomplete?: false,
59-
# handling_action?: false,
6058
stalker: nil,
6159
resource_guard: nil,
6260
subprocess_supervisor: nil,

test/membrane/core/element/action_handler_test.exs

-3
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,6 @@ defmodule Membrane.Core.Element.ActionHandlerTest do
2525
playback: :stopped,
2626
synchronization: %{clock: nil, parent_clock: nil},
2727
delayed_demands: MapSet.new(),
28-
# handling_action?: false,
2928
pads_to_snapshot: MapSet.new(),
3029
pads_data: %{
3130
input:
@@ -110,7 +109,6 @@ defmodule Membrane.Core.Element.ActionHandlerTest do
110109
synchronization: %{clock: nil, parent_clock: nil},
111110
delayed_demands: MapSet.new(),
112111
playback: :stopped,
113-
# handling_action?: false,
114112
pads_to_snapshot: MapSet.new(),
115113
pads_data: %{
116114
output: %{
@@ -512,7 +510,6 @@ defmodule Membrane.Core.Element.ActionHandlerTest do
512510
name: :elem_name,
513511
synchronization: %{clock: nil, parent_clock: nil},
514512
type: :source,
515-
# handling_action?: false,
516513
pads_to_snapshot: MapSet.new(),
517514
pads_data: %{
518515
output: %{

test/membrane/core/element/event_controller_test.exs

-1
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,6 @@ defmodule Membrane.Core.Element.EventControllerTest do
5151
playback: :playing,
5252
parent_pid: self(),
5353
synchronization: %{clock: nil, parent_clock: nil, stream_sync: nil},
54-
# handling_action?: false,
5554
delay_demands?: false,
5655
pads_to_snapshot: MapSet.new(),
5756
delayed_demands: MapSet.new(),

test/membrane/core/element/lifecycle_controller_test.exs

-1
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,6 @@ defmodule Membrane.Core.Element.LifecycleControllerTest do
5050
playback: :playing,
5151
parent_pid: self(),
5252
synchronization: %{clock: nil, parent_clock: nil},
53-
# handling_action?: false,
5453
delay_demands?: false,
5554
pads_to_snapshot: MapSet.new(),
5655
delayed_demands: MapSet.new(),

test/membrane/core/element/pad_controller_test.exs

-1
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,6 @@ defmodule Membrane.Core.Element.PadControllerTest do
1818
struct!(State,
1919
name: name,
2020
module: elem_module,
21-
# handling_action?: false,
2221
delay_demands?: false,
2322
pads_to_snapshot: MapSet.new(),
2423
delayed_demands: MapSet.new(),

test/membrane/core/element/stream_format_controller_test.exs

-1
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,6 @@ defmodule Membrane.Core.Element.StreamFormatControllerTest do
4242
type: :filter,
4343
playback: :playing,
4444
synchronization: %{clock: nil, parent_clock: nil},
45-
# handling_action?: false,
4645
delay_demands?: false,
4746
pads_to_snapshot: MapSet.new(),
4847
delayed_demands: MapSet.new(),

0 commit comments

Comments
 (0)