Skip to content

Commit 16b07ea

Browse files
authored
Release 1.2.2: Improve conditions for generating compilation warnings (#956)
* Improve conditions for generating compilation warnings * Bump version to 1.2.2 * Fix credo
1 parent eb87a30 commit 16b07ea

File tree

3 files changed

+26
-3
lines changed

3 files changed

+26
-3
lines changed

CHANGELOG.md

+3
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,8 @@
11
# Changelog
22

3+
## 1.2.2
4+
* Improve conditions for generating compilation warnings. [#956](https://github.com/membraneframework/membrane_core/pull/956)
5+
36
## 1.2.1
47
* Improve stream format error. [#950](https://github.com/membraneframework/membrane_core/pull/950)
58
* Minor fixes in `Membrane.Connector`. [#952](https://github.com/membraneframework/membrane_core/pull/952)

lib/membrane/core/child/pads_specs.ex

+22-2
Original file line numberDiff line numberDiff line change
@@ -174,8 +174,8 @@ defmodule Membrane.Core.Child.PadsSpecs do
174174
|> Enum.filter(fn {_pad, info} -> info[:flow_control] in [:auto, :push] end)
175175
|> Enum.split_with(fn {_pad, info} -> info.flow_control == :auto end)
176176

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("""
179179
#{inspect(env.module)} defines pads with `flow_control: :auto` and pads with `flow_control: :push` \
180180
at the same time. Please, consider if this what you want to do - flow control of these pads won't be \
181181
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
221221
:ok
222222
end
223223

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+
224244
@spec parse_pad_specs!(
225245
specs :: Pad.spec(),
226246
direction :: Pad.direction(),

mix.exs

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
defmodule Membrane.Mixfile do
22
use Mix.Project
33

4-
@version "1.2.1"
4+
@version "1.2.2"
55
@source_ref "v#{@version}"
66

77
def project do

0 commit comments

Comments
 (0)