Skip to content

Commit

Permalink
Remove redundant pts integrity check. Bump to v0.20.4 (#65)
Browse files Browse the repository at this point in the history
* Remove redundant pts integrity check. Bump to v0.20.4

* Simplify encoder results handling

* Implement CR suggestion
  • Loading branch information
varsill authored Oct 14, 2024
1 parent 4ad01f5 commit f542203
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 22 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ The package can be installed by adding `membrane_opus_plugin` to your list of de
```elixir
def deps do
[
{:membrane_opus_plugin, "~> 0.20.3"}
{:membrane_opus_plugin, "~> 0.20.4"}
]
end
```
Expand Down
30 changes: 10 additions & 20 deletions lib/membrane_opus/encoder.ex
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@ defmodule Membrane.Opus.Encoder do
require Membrane.Logger

alias __MODULE__.Native
alias Membrane.Opus.Util
alias Membrane.{Buffer, Opus, RawAudio, Time}

@allowed_channels [1, 2]
Expand Down Expand Up @@ -133,25 +132,16 @@ defmodule Membrane.Opus.Encoder do

@impl true
def handle_buffer(:input, %Buffer{payload: data, pts: input_pts}, _ctx, state) do
check_pts_integrity? = state.queue != <<>>

case encode_buffer(
state.queue <> data,
set_current_pts(state, input_pts),
frame_size_in_bytes(state)
) do
{:ok, [], state} ->
# nothing was encoded
{[], state}

{:ok, encoded_buffers, state} ->
# something was encoded
if check_pts_integrity? do
Util.validate_pts_integrity(encoded_buffers, input_pts)
end

{[buffer: {:output, encoded_buffers}], state}
end
{:ok, encoded_buffers, state} =
encode_buffer(
state.queue <> data,
set_current_pts(state, input_pts),
frame_size_in_bytes(state)
)

actions = Enum.map(encoded_buffers, &{:buffer, {:output, &1}})

{actions, state}
end

@impl true
Expand Down
2 changes: 1 addition & 1 deletion mix.exs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
defmodule Membrane.Opus.Plugin.Mixfile do
use Mix.Project

@version "0.20.3"
@version "0.20.4"
@github_url "https://github.com/membraneframework/membrane_opus_plugin"

def project do
Expand Down

0 comments on commit f542203

Please sign in to comment.