@@ -174,8 +174,8 @@ defmodule Membrane.Core.Child.PadsSpecs do
174
174
|> Enum . filter ( fn { _pad , info } -> info [ :flow_control ] in [ :auto , :push ] end )
175
175
|> Enum . split_with ( fn { _pad , info } -> info . flow_control == :auto end )
176
176
177
- if auto_pads != [ ] and push_pads != [ ] do
178
- IO . warn ( """
177
+ if should_warn_on_mixing_push_and_auto_pads? ( pads , auto_pads , push_pads , used_module ) do
178
+ Membrane.Logger . warning ( """
179
179
#{ inspect ( env . module ) } defines pads with `flow_control: :auto` and pads with `flow_control: :push` \
180
180
at the same time. Please, consider if this what you want to do - flow control of these pads won't be \
181
181
integrated. Setting `flow_control` to `:auto` in the places where it has been set to `:push` might be \
@@ -221,6 +221,26 @@ defmodule Membrane.Core.Child.PadsSpecs do
221
221
:ok
222
222
end
223
223
224
+ defp should_warn_on_mixing_push_and_auto_pads? ( all_pads , auto_pads , push_pads , used_module ) do
225
+ auto_pads != [ ] and push_pads != [ ] and
226
+ not endpoint_with_surely_valid_flow_control ( used_module , all_pads )
227
+ end
228
+
229
+ # returns true if e.g. Endpoint has all input pads in auto and all output pads in push
230
+ defp endpoint_with_surely_valid_flow_control ( Membrane.Endpoint , pads ) do
231
+ pads
232
+ |> Enum . group_by (
233
+ fn { _pad_name , pad_info } -> pad_info . direction end ,
234
+ fn { _pad_name , pad_info } -> pad_info end
235
+ )
236
+ |> Enum . all? ( fn { _directiom , pads_info } ->
237
+ MapSet . new ( pads_info , & & 1 . flow_control )
238
+ |> MapSet . size ( ) == 1
239
+ end )
240
+ end
241
+
242
+ defp endpoint_with_surely_valid_flow_control ( _used_module , _pads ) , do: false
243
+
224
244
@ spec parse_pad_specs! (
225
245
specs :: Pad . spec ( ) ,
226
246
direction :: Pad . direction ( ) ,
0 commit comments