Skip to content

Commit

Permalink
Merge pull request #509 from BrandtHill/dialyzer-unmatched-return-voice
Browse files Browse the repository at this point in the history
Match against some ignored voice values
  • Loading branch information
jchristgit committed Jul 4, 2023
2 parents d78acb2 + 2508484 commit 724d031
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 14 deletions.
4 changes: 2 additions & 2 deletions lib/nostrum/voice.ex
Original file line number Diff line number Diff line change
Expand Up @@ -553,7 +553,7 @@ defmodule Nostrum.Voice do
voice = get_voice(guild_id)

if VoiceState.ready_for_rtp?(voice) do
Audio.send_frames(frames, voice)
{_voice, _done?} = Audio.send_frames(frames, voice)
:ok
else
{:error, "Must be connected to voice channel to send frames."}
Expand All @@ -573,7 +573,7 @@ defmodule Nostrum.Voice do

cond do
VoiceState.ready_for_ws?(voice) ->
VoiceSupervisor.create_session(voice)
{:ok, _pid} = VoiceSupervisor.create_session(voice)
:ok

is_nil(voice) ->
Expand Down
19 changes: 10 additions & 9 deletions lib/nostrum/voice/audio.ex
Original file line number Diff line number Diff line change
Expand Up @@ -118,15 +118,15 @@ defmodule Nostrum.Voice.Audio do
wait = if(init?, do: Application.get_env(:nostrum, :audio_timeout, 20_000), else: 500)
{:ok, watchdog} = :timer.apply_after(wait, __MODULE__, :on_stall, [voice, self()])

{voice, done} =
{voice, done?} =
voice
|> get_source()
|> Enum.take(frames_per_burst())
|> send_frames(voice)

:timer.cancel(watchdog)
{:ok, :cancel} = :timer.cancel(watchdog)

if done,
if done?,
do: on_complete(voice, init?),
else: voice
end
Expand All @@ -136,12 +136,13 @@ defmodule Nostrum.Voice.Audio do
def send_frames(frames, %VoiceState{} = voice) do
voice =
Enum.reduce(frames, voice, fn f, v ->
:gen_udp.send(
v.udp_socket,
v.ip |> ip_to_tuple(),
v.port,
encrypt_packet(v, f)
)
:ok =
:gen_udp.send(
v.udp_socket,
v.ip |> ip_to_tuple(),
v.port,
encrypt_packet(v, f)
)

%{
v
Expand Down
4 changes: 1 addition & 3 deletions lib/nostrum/voice/ports.ex
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,6 @@ defmodule Nostrum.Voice.Ports do
end
end

alias Nostrum.Voice.Ports.State

require Logger

use GenServer
Expand All @@ -41,7 +39,7 @@ defmodule Nostrum.Voice.Ports do

# Spawn process to asynchronously send input to port
unless is_nil(input) do
Task.start(fn -> send_input(port, input) end)
{:ok, _pid} = Task.start(fn -> send_input(port, input) end)
end

# Store reference if input is another process
Expand Down

0 comments on commit 724d031

Please sign in to comment.