Skip to content

Commit

Permalink
Fix error messages (#49)
Browse files Browse the repository at this point in the history
* Fix error messages

* Bump version to v0.16.2

* Bump deps

* Bump cache version

* Remove usage of deprecated functions

* unlock unused deps
  • Loading branch information
FelonEkonom authored Jul 25, 2024
1 parent 6948909 commit 99e43dc
Show file tree
Hide file tree
Showing 7 changed files with 55 additions and 48 deletions.
4 changes: 4 additions & 0 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,16 +7,20 @@ workflows:
build:
jobs:
- elixir/build_test:
cache-version: 3
filters: &filters
tags:
only: /v.*/
- elixir/test:
cache-version: 3
filters:
<<: *filters
- elixir/lint:
cache-version: 3
filters:
<<: *filters
- elixir/hex_publish:
cache-version: 3
requires:
- elixir/build_test
- elixir/test
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ sudo apt-get install libmad0-dev
Then, add the following line to your `deps` in `mix.exs`:

```elixir
{:membrane_audio_mix_plugin, "~> 0.16.1"}
{:membrane_audio_mix_plugin, "~> 0.16.2"}
```

and run `mix deps.get`.
Expand Down
8 changes: 5 additions & 3 deletions lib/membrane_live_audio_mixer/live_queue.ex
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,8 @@ defmodule Membrane.LiveAudioMixer.LiveQueue do
def add_queue(lq, id, offset \\ 0)

def add_queue(lq, id, offset) when offset >= 0 do
if get_in(lq, [:queues, id]) != nil, do: raise("Queue with id: '#{id}' already exists.")
if get_in(lq, [:queues, id]) != nil,
do: raise("Queue with id: '#{inspect(id)}' already exists.")

queue = %Queue{offset: offset}
put_in(lq, [:queues, id], queue)
Expand All @@ -54,13 +55,14 @@ defmodule Membrane.LiveAudioMixer.LiveQueue do
"""
@spec remove_queue(t(), any()) :: t()
def remove_queue(lq, id) do
if not Map.has_key?(lq.queues, id), do: raise("Queue with id: '#{id}' doesn't exists")
if not Map.has_key?(lq.queues, id),
do: raise("Queue with id: '#{inspect(id)}' doesn't exists")

queue = lq.queues[id]

cond do
queue.draining? ->
raise "Queue with id: '#{id}' is already marked as draining"
raise "Queue with id: '#{inspect(id)}' is already marked as draining"

queue.buffer_duration == 0 ->
{_queue, lq} = pop_in(lq, [:queues, id])
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.AudioMix.Mixfile do
use Mix.Project

@version "0.16.1"
@version "0.16.2"
@github_url "https://github.com/membraneframework/membrane_audio_mix_plugin"

def project do
Expand Down
57 changes: 29 additions & 28 deletions mix.lock

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion test/mixer/common_mixer_test.exs
Original file line number Diff line number Diff line change
Expand Up @@ -428,7 +428,7 @@ defmodule Membrane.CommonMixerTest do
defp do_perform_test(spec, reference_path, output_path, true) do
assert pipeline = Pipeline.start_link_supervised!(spec: spec)

Pipeline.message_child(pipeline, :mixer, :schedule_eos)
Pipeline.notify_child(pipeline, :mixer, :schedule_eos)

assert_end_of_stream(pipeline, :file_sink, :input, 20_000)

Expand Down
28 changes: 14 additions & 14 deletions test/mixer/live_mixer_test.exs
Original file line number Diff line number Diff line change
Expand Up @@ -52,13 +52,13 @@ defmodule Membrane.LiveAudioMixerTest do

assert pipeline = Pipeline.start_link_supervised!(spec: spec)
assert_start_of_stream(pipeline, :mixer, Pad.ref(:input, 1))
Pipeline.message_child(pipeline, :mixer, :schedule_eos)
Pipeline.notify_child(pipeline, :mixer, :schedule_eos)

spec = add_audio_source(2)

Pipeline.execute_actions(pipeline, spec: spec)
assert_start_of_stream(pipeline, :mixer, Pad.ref(:input, 2))
Pipeline.message_child(pipeline, :mixer, :schedule_eos)
Pipeline.notify_child(pipeline, :mixer, :schedule_eos)
assert_end_of_stream(pipeline, :file_sink, :input, 20_000)

check_output_duration(output_path)
Expand All @@ -76,14 +76,14 @@ defmodule Membrane.LiveAudioMixerTest do
]

assert pipeline = Pipeline.start_link_supervised!(spec: spec)
Pipeline.message_child(pipeline, :mixer, :schedule_eos)
Pipeline.notify_child(pipeline, :mixer, :schedule_eos)

spec = add_audio_source(1) ++ add_audio_source(2)

Pipeline.execute_actions(pipeline, spec: spec)
assert_start_of_stream(pipeline, :mixer, Pad.ref(:input, 1))
assert_start_of_stream(pipeline, :mixer, Pad.ref(:input, 2))
Pipeline.message_child(pipeline, :mixer, :schedule_eos)
Pipeline.notify_child(pipeline, :mixer, :schedule_eos)
assert_end_of_stream(pipeline, :file_sink, :input, 20_000)

check_output_duration(output_path)
Expand All @@ -98,7 +98,7 @@ defmodule Membrane.LiveAudioMixerTest do
links = create_links()

assert pipeline = Pipeline.start_link_supervised!(spec: elements ++ links)
Pipeline.message_child(pipeline, :mixer, :schedule_eos)
Pipeline.notify_child(pipeline, :mixer, :schedule_eos)
assert_end_of_stream(pipeline, :file_sink, :input, 20_000)

spec = add_audio_source(3)
Expand Down Expand Up @@ -132,7 +132,7 @@ defmodule Membrane.LiveAudioMixerTest do

assert pipeline = Pipeline.start_link_supervised!(spec: spec)

Pipeline.message_child(pipeline, :mixer, {:start_mixing, 0})
Pipeline.notify_child(pipeline, :mixer, {:start_mixing, 0})

# audio duration has to be equal or longer than 15 seconds
# input audio has 10 seconds
Expand All @@ -145,7 +145,7 @@ defmodule Membrane.LiveAudioMixerTest do
assert_start_of_stream(pipeline, :mixer, Pad.ref(:input, 1))
assert_start_of_stream(pipeline, :mixer, Pad.ref(:input, 2))

Pipeline.message_child(pipeline, :mixer, :schedule_eos)
Pipeline.notify_child(pipeline, :mixer, :schedule_eos)
assert_end_of_stream(pipeline, :file_sink, :input, 20_000)

check_output_duration(output_path, 15)
Expand All @@ -170,9 +170,9 @@ defmodule Membrane.LiveAudioMixerTest do
assert_start_of_stream(pipeline, :mixer, Pad.ref(:input, 1))
assert_start_of_stream(pipeline, :mixer, Pad.ref(:input, 2))

Pipeline.message_child(pipeline, :mixer, {:start_mixing, 0})
Pipeline.notify_child(pipeline, :mixer, {:start_mixing, 0})

Pipeline.message_child(pipeline, :mixer, :schedule_eos)
Pipeline.notify_child(pipeline, :mixer, :schedule_eos)
assert_end_of_stream(pipeline, :file_sink, :input, 20_000)

check_output_duration(output_path)
Expand All @@ -194,13 +194,13 @@ defmodule Membrane.LiveAudioMixerTest do
# time for the pipeline to enter playing playback
Process.sleep(100)

Pipeline.message_child(pipeline, :mixer, {:start_mixing, 0})
Pipeline.notify_child(pipeline, :mixer, {:start_mixing, 0})

# audio duration has to be equal or longer than 5 seconds
# thats why sleep is a little longer than 5 seconds
Process.sleep(5_300)

Pipeline.message_child(pipeline, :mixer, :schedule_eos)
Pipeline.notify_child(pipeline, :mixer, :schedule_eos)

assert_end_of_stream(pipeline, :file_sink, :input, 1_000)

Expand All @@ -220,12 +220,12 @@ defmodule Membrane.LiveAudioMixerTest do

assert pipeline = Pipeline.start_link_supervised!(spec: spec)

Pipeline.message_child(pipeline, :mixer, :schedule_eos)
Pipeline.notify_child(pipeline, :mixer, :schedule_eos)

spec = add_audio_source(1) ++ add_audio_source(2)
Pipeline.execute_actions(pipeline, spec: spec)

Pipeline.message_child(pipeline, :mixer, {:start_mixing, 0})
Pipeline.notify_child(pipeline, :mixer, {:start_mixing, 0})

assert_start_of_stream(pipeline, :mixer, Pad.ref(:input, 1))
assert_start_of_stream(pipeline, :mixer, Pad.ref(:input, 2))
Expand Down Expand Up @@ -253,7 +253,7 @@ defmodule Membrane.LiveAudioMixerTest do
assert_start_of_stream(pipeline, :mixer, Pad.ref(:input, 1))
assert_start_of_stream(pipeline, :mixer, Pad.ref(:input, 2))

Pipeline.message_child(pipeline, :mixer, :schedule_eos)
Pipeline.notify_child(pipeline, :mixer, :schedule_eos)
assert_end_of_stream(pipeline, :file_sink, :input, 20_000)

check_output_duration(output_path)
Expand Down

0 comments on commit 99e43dc

Please sign in to comment.