Skip to content

Commit 06b0c97

Browse files
committed
Remove rendundant function in timestamp metrics
1 parent 4960c7c commit 06b0c97

3 files changed

Lines changed: 10 additions & 16 deletions

File tree

lib/membrane/buffer/metric/timestamp.ex

Lines changed: 8 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -65,11 +65,11 @@ for {timestamp_type, module_suffix} <- [pts: PTS, dts: DTS, dts_or_pts: DTSOrPTS
6565
when last_consumed_timestamp - first_consumed_timestamp >= demand_timestamp <-
6666
get_timestamp(last_consumed_buffer) do
6767
Membrane.Logger.warning("""
68-
Demanded #{inspected_timestamp_type()} should be greater than the elapsed #{inspected_timestamp_type()} \
68+
Demanded #{timestamp_name()} should be greater than the elapsed #{timestamp_name()} \
6969
since the first consumed buffer. Got :demand of #{demand_timestamp}, while the elapsed \
70-
#{inspected_timestamp_type()} equals #{last_consumed_timestamp - first_consumed_timestamp}. \
71-
Demanding a #{inspected_timestamp_type()} that is not greater than the elapsed one \
72-
won't result in handling any further buffers, until the element demands a #{inspected_timestamp_type()} \
70+
#{timestamp_name()} equals #{last_consumed_timestamp - first_consumed_timestamp}. \
71+
Demanding a #{timestamp_name()} that is not greater than the elapsed one \
72+
won't result in handling any further buffers, until the element demands a #{timestamp_name()} \
7373
greater than the elapsed one. \
7474
""")
7575

@@ -101,9 +101,9 @@ for {timestamp_type, module_suffix} <- [pts: PTS, dts: DTS, dts_or_pts: DTSOrPTS
101101
{:ok, prev_timestamp} when curr_timestamp < prev_timestamp <-
102102
get_timestamp(prev_buffer) do
103103
Membrane.Logger.warning("""
104-
Received buffers with non-monotonic #{inspected_timestamp_type()}s. \
105-
Current buffer's #{inspected_timestamp_type()} is #{curr_timestamp}, \
106-
while the previous buffer's #{inspected_timestamp_type()} is #{prev_timestamp}. \
104+
Received buffers with non-monotonic #{timestamp_name()}s. \
105+
Current buffer's #{timestamp_name()} is #{curr_timestamp}, \
106+
while the previous buffer's #{timestamp_name()} is #{prev_timestamp}. \
107107
This may lead to unexpected behavior in elements that have input pad with flow \
108108
control set to `:manual` and demand unit set to `:timestamp`, `{:timestamp, :dts}` \
109109
`{:timestamp, :pts}` or `{:timestamp, :dts_or_pts}`.
@@ -146,8 +146,6 @@ for {timestamp_type, module_suffix} <- [pts: PTS, dts: DTS, dts_or_pts: DTSOrPTS
146146
@impl TimestampMetric
147147
def timestamp_name(), do: "PTS"
148148

149-
defp inspected_timestamp_type(), do: "PTS"
150-
151149
:dts ->
152150
defp get_timestamp(%Buffer{dts: dts}), do: {:ok, dts}
153151

@@ -158,18 +156,14 @@ for {timestamp_type, module_suffix} <- [pts: PTS, dts: DTS, dts_or_pts: DTSOrPTS
158156
@impl TimestampMetric
159157
def timestamp_name(), do: "DTS"
160158

161-
defp inspected_timestamp_type(), do: "DTS"
162-
163159
:dts_or_pts ->
164160
defp get_timestamp(buffer), do: {:ok, Buffer.get_dts_or_pts(buffer)}
165161

166162
@impl TimestampMetric
167163
def nil_timestamp?(buffer), do: is_nil(Buffer.get_dts_or_pts(buffer))
168164

169165
@impl TimestampMetric
170-
def timestamp_name(), do: "DTS or PTS"
171-
172-
defp inspected_timestamp_type(), do: "<DTS or PTS>"
166+
def timestamp_name(), do: "<DTS || PTS>"
173167
end
174168
end
175169
end

test/membrane/buffer_metric/timestamp_test.exs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -157,7 +157,7 @@ defmodule Membrane.Buffer.Metric.TimestampTest do
157157
end)
158158

159159
assert log =~ "warning"
160-
assert log =~ "DTS or PTS"
160+
assert log =~ "<DTS || PTS>"
161161
end
162162
end
163163
end

test/membrane/core/element/input_queue_test.exs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -389,7 +389,7 @@ defmodule Membrane.Core.Element.InputQueueTest do
389389

390390
assert_receive Message.new(:atomic_demand_increased, :output_pad_ref)
391391

392-
assert_raise RuntimeError, ~r/DTS or PTS/, fn ->
392+
assert_raise RuntimeError, ~r/DTS \|\| PTS/, fn ->
393393
InputQueue.store(queue, [%Buffer{payload: <<>>, pts: nil, dts: nil}])
394394
end
395395
end

0 commit comments

Comments
 (0)