Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix change_playback_state/2 reference. #121

Merged
merged 2 commits into from
Nov 14, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion lib/membrane/core/playback.ex
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ defmodule Membrane.Core.Playback do
This module defines available playback states and struct that is held
internally by every module having playback state.

There are three playback states: :stopped, :prepared and :playing.
There are three playback states: `:stopped`, `:prepared` and `:playing`.
"""
use Bunch.Access

Expand All @@ -22,4 +22,6 @@ defmodule Membrane.Core.Playback do
}

@type state_t :: :stopped | :prepared | :playing

defguard is_playback_state(atom) when atom in [:stopped, :prepared, :playing]
end
23 changes: 16 additions & 7 deletions lib/membrane/core/playback_requestor.ex
Original file line number Diff line number Diff line change
Expand Up @@ -10,30 +10,39 @@ defmodule Membrane.Core.PlaybackRequestor do
defmacro __using__(_args) do
quote location: :keep do
@behaviour unquote(__MODULE__)
require Membrane.Core.Playback

@doc """
Alias for `change_playback_state(pid, :playing)`.
See `c:#{__MODULE__}.change_playback_state/2`.
Changes playback state to `:playing`.

An alias for `change_playback_state/2` with proper state.
"""
@spec play(pid) :: :ok
def play(pid), do: change_playback_state(pid, :playing)

@doc """
Alias for `change_playback_state(pid, :prepared)`.
See `c:#{__MODULE__}.change_playback_state/2`.
Changes playback state to `:prepared`.

An alias for `change_playback_state/2` with proper state.
"""
@spec prepare(pid) :: :ok
def prepare(pid), do: change_playback_state(pid, :prepared)

@doc """
Alias for `change_playback_state(pid, :stopped)`.
See `c:#{__MODULE__}.change_playback_state/2`.
Changes playback state to `:stopped`.

An alias for `change_playback_state/2` with proper state.
"""
@spec stop(pid) :: :ok
def stop(pid), do: change_playback_state(pid, :stopped)

@impl unquote(__MODULE__)
def change_playback_state(pid, new_state) do
@doc """
Changes the playback state to the `new_state`.
"""
@spec change_playback_state(pid, Playback.state_t()) :: :ok
def change_playback_state(pid, new_state)
when Membrane.Core.Playback.is_playback_state(new_state) do
alias Membrane.Core.Message
require Message
Message.send(pid, :change_playback_state, new_state)
Expand Down