Skip to content

Commit

Permalink
perf: add segment buffer
Browse files Browse the repository at this point in the history
attempting to account for aac priming sample as defined in HLS spec
  • Loading branch information
trueChazza committed Apr 29, 2024
1 parent 65b4721 commit db26024
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 14 deletions.
3 changes: 1 addition & 2 deletions lib/hls_playlist_segments.ex
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,7 @@ defmodule HlsPlaylist.Segments do
end

defp spread_duration(duration, _segment_length, acc) when duration <= 0 do
Enum.map(acc, fn x -> Float.round((x * 1.0), 2) end)
|> Enum.reverse()
Enum.reverse(acc)
end

defp spread_duration(duration, segment_length, acc) do
Expand Down
24 changes: 12 additions & 12 deletions test/hls_playlist_segments_test.exs
Original file line number Diff line number Diff line change
Expand Up @@ -2,18 +2,18 @@ defmodule HlsPlaylist.Segments.Test do
use ExUnit.Case

test "it should generate" do
assert HlsPlaylist.Segments.generate(32.21, 3) == [
3.0,
3.0,
3.0,
3.0,
3.0,
3.0,
3.0,
3.0,
3.0,
3.0,
2.21
assert HlsPlaylist.Segments.generate(32.21, 3.003) == [
3.003,
3.003,
3.003,
3.003,
3.003,
3.003,
3.003,
3.003,
3.003,
3.003,
2.1799999999999997
]
end
end

0 comments on commit db26024

Please sign in to comment.