From 6a1fb5a8deb45faa7e5f0ffab73ec39430c638d5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Feliks=20Pobiedzi=C5=84ski?= <38541925+FelonEkonom@users.noreply.github.com> Date: Mon, 22 May 2023 13:24:38 +0200 Subject: [PATCH] Remove redundant check if static pads are linked (#557) --- lib/membrane/core/child/pad_controller.ex | 21 ------------------- .../core/element/lifecycle_controller.ex | 4 +--- .../core/parent/lifecycle_controller.ex | 4 ---- test/membrane/core/element_test.exs | 6 ------ 4 files changed, 1 insertion(+), 34 deletions(-) diff --git a/lib/membrane/core/child/pad_controller.ex b/lib/membrane/core/child/pad_controller.ex index e5ac48f45..d345ab457 100644 --- a/lib/membrane/core/child/pad_controller.ex +++ b/lib/membrane/core/child/pad_controller.ex @@ -69,25 +69,4 @@ defmodule Membrane.Core.Child.PadController do "Invalid keys in options of pad #{inspect(pad_name)} - #{inspect(keys)}" end end - - @spec assert_all_static_pads_linked!(state) :: :ok - def assert_all_static_pads_linked!(state) do - linked_pads_names = state.pads_data |> Map.values() |> MapSet.new(& &1.name) - - static_unlinked_pads = - state.pads_info - |> Map.values() - |> Enum.filter( - &(Pad.availability_mode(&1.availability) == :static and &1.name not in linked_pads_names) - ) - - unless Enum.empty?(static_unlinked_pads) do - raise LinkError, """ - Some static pads remained unlinked: #{inspect(Enum.map(static_unlinked_pads, & &1.name))} - State: #{inspect(state, pretty: true)} - """ - end - - :ok - end end diff --git a/lib/membrane/core/element/lifecycle_controller.ex b/lib/membrane/core/element/lifecycle_controller.ex index c96a82977..4f7c66ba9 100644 --- a/lib/membrane/core/element/lifecycle_controller.ex +++ b/lib/membrane/core/element/lifecycle_controller.ex @@ -7,7 +7,7 @@ defmodule Membrane.Core.Element.LifecycleController do use Bunch alias Membrane.{Clock, Element, Sync} - alias Membrane.Core.{CallbackHandler, Child, Element, Message} + alias Membrane.Core.{CallbackHandler, Element, Message} alias Membrane.Core.Element.{ActionHandler, CallbackContext, PlaybackQueue, State} require Membrane.Core.Child.PadModel @@ -66,8 +66,6 @@ defmodule Membrane.Core.Element.LifecycleController do @spec handle_playing(State.t()) :: State.t() def handle_playing(state) do - Child.PadController.assert_all_static_pads_linked!(state) - Membrane.Logger.debug("Got play request") state = %State{state | playback: :playing} diff --git a/lib/membrane/core/parent/lifecycle_controller.ex b/lib/membrane/core/parent/lifecycle_controller.ex index 57ce7eb4c..c08ece522 100644 --- a/lib/membrane/core/parent/lifecycle_controller.ex +++ b/lib/membrane/core/parent/lifecycle_controller.ex @@ -41,10 +41,6 @@ defmodule Membrane.Core.Parent.LifecycleController do def handle_playing(state) do Membrane.Logger.debug("Parent play") - if state.__struct__ == Membrane.Core.Bin.State do - Core.Child.PadController.assert_all_static_pads_linked!(state) - end - activate_syncs(state.children) Enum.each(state.children, fn {_name, %{pid: pid, ready?: ready?}} -> diff --git a/test/membrane/core/element_test.exs b/test/membrane/core/element_test.exs index a4ef0ad7f..2296afba8 100644 --- a/test/membrane/core/element_test.exs +++ b/test/membrane/core/element_test.exs @@ -127,12 +127,6 @@ defmodule Membrane.Core.ElementTest do state end - test "should raise when static pads not linked when getting play request" do - assert_raise Membrane.LinkError, fn -> - assert {:noreply, _state} = Element.handle_info(Message.new(:play), get_state()) - end - end - test "should return correct clock and should not modify the state" do original_state = get_state()