Skip to content

Commit

Permalink
Fix tests wip
Browse files Browse the repository at this point in the history
  • Loading branch information
FelonEkonom committed Jan 8, 2024
1 parent 6d56f0c commit e32c255
Show file tree
Hide file tree
Showing 3 changed files with 26 additions and 25 deletions.
17 changes: 9 additions & 8 deletions lib/membrane/core/element/demand_controller.ex
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ defmodule Membrane.Core.Element.DemandController do
do: raise("cannot snapshot atomic counter in input pad")

if state.name == {:filter, 10}, do: IO.puts("snapshot_atomic_demand")
IO.inspect(state)
# IO.inspect(state)


# aktualnie bug polega na tym, ze w tescie z tagiem :dupa,
Expand All @@ -52,12 +52,13 @@ defmodule Membrane.Core.Element.DemandController do
%{effective_flow_control: :pull} = state
) do

if state.name == {:filter, 10} do
IO.puts("ALA MA KOTA")
AtomicDemand.get(pad_data.atomic_demand)
|> IO.inspect()
IO.inspect(state.satisfied_auto_output_pads)
end
# last comment
# if state.name == {:filter, 10} do
# IO.puts("ALA MA KOTA")
# AtomicDemand.get(pad_data.atomic_demand)
# |> IO.inspect()
# IO.inspect(state.satisfied_auto_output_pads)
# end


if AtomicDemand.get(pad_data.atomic_demand) > 0 do
Expand All @@ -70,7 +71,7 @@ defmodule Membrane.Core.Element.DemandController do


state = Map.update!(state, :satisfied_auto_output_pads, &MapSet.delete(&1, pad_data.ref))
IO.inspect(state.satisfied_auto_output_pads)
# IO.inspect(state.satisfied_auto_output_pads)


# dobra, wyglada git
Expand Down
16 changes: 15 additions & 1 deletion lib/membrane/core/element/effective_flow_controller.ex
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ defmodule Membrane.Core.Element.EffectiveFlowController do

# Effective flow control of a single element can switch between :push and :pull many times during the element's lifetime.

alias Membrane.Core.Element.DemandController
alias Membrane.Core.Element.DemandController.AutoFlowUtils
alias Membrane.Core.Element.{AtomicDemand, State}

Expand Down Expand Up @@ -131,7 +132,20 @@ defmodule Membrane.Core.Element.EffectiveFlowController do
end
end)

AutoFlowUtils.pop_queues_and_bump_demand(state)
# no to tak, albo mozna przy efc push zawsze sprawdzac output demand przy wyslaniu bufora lub otrzymaniu notifa ze
# demand wzrol na dodania wartosc
# albo mozna sprawdzac wszystko przy wejsciu na pull
# tutaj zaimplementuje to 2 opcje

with %{effective_flow_control: :pull} <- state do
state.pads_data
|> Map.values()
|> Enum.filter(& &1.direction == :output and &1.flow_control == :auto)
|> Enum.reduce(state, fn pad_data, state ->
DemandController.snapshot_atomic_demand(pad_data.ref, state)
end)
end
|> AutoFlowUtils.pop_queues_and_bump_demand()

# state.pads_data
# |> Enum.flat_map(fn
Expand Down
18 changes: 2 additions & 16 deletions test/membrane/integration/auto_demands_test.exs
Original file line number Diff line number Diff line change
Expand Up @@ -76,12 +76,10 @@ defmodule Membrane.Integration.AutoDemandsTest do

[
%{payloads: 1..100_000, factor: 1, direction: :up, filters: 10},
# %{payloads: 1..4, factor: 10, direction: :up, filters: 5},
# %{payloads: 1..4, factor: 10, direction: :down, filters: 5}
%{payloads: 1..4, factor: 10, direction: :up, filters: 5},
%{payloads: 1..4, factor: 10, direction: :down, filters: 5}
]
|> Enum.map(fn opts ->
# @tag :skip
@tag :dupa
test "buffers pass through auto-demand filters; setup: #{inspect(opts)}" do
%{payloads: payloads, factor: factor, direction: direction, filters: filters} =
unquote(Macro.escape(opts))
Expand All @@ -105,19 +103,7 @@ defmodule Membrane.Integration.AutoDemandsTest do
|> child(:sink, Sink)
)

Process.sleep(1000)

:sys.get_state(pipeline)
|> Map.get(:children)
|> Map.keys()
|> Enum.each(fn child_name ->
Pipeline.get_child_pid!(pipeline, child_name)
|> :sys.get_state()
|> IO.inspect(limit: :infinity, label: "CHILD STATE #{inspect(child_name)}")
end)

Enum.each(out_payloads, fn payload ->
IO.inspect(payload, label: "EXPECTING")
assert_sink_buffer(pipeline, :sink, buffer)
assert buffer.payload == payload
end)
Expand Down

0 comments on commit e32c255

Please sign in to comment.