From e32c2557fb7e4d19fccd26456ad7efd1d6f050cd Mon Sep 17 00:00:00 2001 From: "feliks.pobiedzinski@swmansion.com" Date: Mon, 8 Jan 2024 18:59:53 +0100 Subject: [PATCH] Fix tests wip --- lib/membrane/core/element/demand_controller.ex | 17 +++++++++-------- .../core/element/effective_flow_controller.ex | 16 +++++++++++++++- .../membrane/integration/auto_demands_test.exs | 18 ++---------------- 3 files changed, 26 insertions(+), 25 deletions(-) diff --git a/lib/membrane/core/element/demand_controller.ex b/lib/membrane/core/element/demand_controller.ex index 313def01f..0d4083042 100644 --- a/lib/membrane/core/element/demand_controller.ex +++ b/lib/membrane/core/element/demand_controller.ex @@ -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, @@ -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 @@ -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 diff --git a/lib/membrane/core/element/effective_flow_controller.ex b/lib/membrane/core/element/effective_flow_controller.ex index 928c77ef7..17833c741 100644 --- a/lib/membrane/core/element/effective_flow_controller.ex +++ b/lib/membrane/core/element/effective_flow_controller.ex @@ -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} @@ -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 diff --git a/test/membrane/integration/auto_demands_test.exs b/test/membrane/integration/auto_demands_test.exs index 93ea3975b..d51581900 100644 --- a/test/membrane/integration/auto_demands_test.exs +++ b/test/membrane/integration/auto_demands_test.exs @@ -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)) @@ -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)