Skip to content

Commit b5b96dd

Browse files
committed
Fix credo
1 parent 3721382 commit b5b96dd

1 file changed

Lines changed: 23 additions & 20 deletions

File tree

lib/membrane/buffer/metric/timestamp.ex

Lines changed: 23 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -6,10 +6,11 @@ for {timestamp_type, module_suffix} <- [pts: PTS, dts: DTS, dts_or_pts: DTSOrPTS
66
todo
77
"""
88

9-
require Membrane.Logger
9+
@behaviour Membrane.Buffer.Metric
10+
1011
alias Membrane.Buffer
1112

12-
@behaviour Membrane.Buffer.Metric
13+
require Membrane.Logger
1314

1415
@initial_manual_demand_size_value -1
1516

@@ -65,24 +66,26 @@ for {timestamp_type, module_suffix} <- [pts: PTS, dts: DTS, dts_or_pts: DTSOrPTS
6566
def generate_metric_specific_warnings(buffers) do
6667
[first | rest] = buffers
6768

68-
Enum.reduce(rest, first, fn curr_buffer, prev_buffer ->
69-
with {:ok, curr_timestamp} <- get_timestamp(curr_buffer),
70-
{:ok, prev_timestamp} when curr_timestamp < prev_timestamp <-
71-
get_timestamp(prev_buffer) do
72-
Membrane.Logger.warning("""
73-
Received buffers with non-monotonic #{inspected_timestamp_type()}s. \
74-
Current buffer's #{inspected_timestamp_type()} is #{curr_timestamp}, \
75-
while the previous buffer's #{inspected_timestamp_type()} is #{prev_timestamp}. \
76-
This may lead to unexpected behavior in elements that have input pad with flow \
77-
control set to `:manual` and demand unit set to `:timestamp`, `{:timestamp, :dts}` \
78-
`{:timestamp, :pts}` or `{:timestamp, :dts_or_pts}`.
79-
""")
80-
81-
curr_buffer
82-
else
83-
_other -> curr_buffer
84-
end
85-
end)
69+
_last =
70+
rest
71+
|> Enum.reduce(first, fn curr_buffer, prev_buffer ->
72+
with {:ok, curr_timestamp} <- get_timestamp(curr_buffer),
73+
{:ok, prev_timestamp} when curr_timestamp < prev_timestamp <-
74+
get_timestamp(prev_buffer) do
75+
Membrane.Logger.warning("""
76+
Received buffers with non-monotonic #{inspected_timestamp_type()}s. \
77+
Current buffer's #{inspected_timestamp_type()} is #{curr_timestamp}, \
78+
while the previous buffer's #{inspected_timestamp_type()} is #{prev_timestamp}. \
79+
This may lead to unexpected behavior in elements that have input pad with flow \
80+
control set to `:manual` and demand unit set to `:timestamp`, `{:timestamp, :dts}` \
81+
`{:timestamp, :pts}` or `{:timestamp, :dts_or_pts}`.
82+
""")
83+
84+
curr_buffer
85+
else
86+
_other -> curr_buffer
87+
end
88+
end)
8689

8790
:ok
8891
end

0 commit comments

Comments
 (0)