Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove redundant check if static pads are linked #557

Merged
merged 3 commits into from
May 22, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 0 additions & 21 deletions lib/membrane/core/child/pad_controller.ex
Original file line number Diff line number Diff line change
Expand Up @@ -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
4 changes: 1 addition & 3 deletions lib/membrane/core/element/lifecycle_controller.ex
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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}

Expand Down
4 changes: 0 additions & 4 deletions lib/membrane/core/parent/lifecycle_controller.ex
Original file line number Diff line number Diff line change
Expand Up @@ -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?}} ->
Expand Down
6 changes: 0 additions & 6 deletions test/membrane/core/element_test.exs
Original file line number Diff line number Diff line change
Expand Up @@ -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()

Expand Down