diff --git a/lib/nostrum/voice.ex b/lib/nostrum/voice.ex index d72cd1d0f..2e813a7e0 100644 --- a/lib/nostrum/voice.ex +++ b/lib/nostrum/voice.ex @@ -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."} @@ -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) -> diff --git a/lib/nostrum/voice/audio.ex b/lib/nostrum/voice/audio.ex index ab43b147a..8ea92dc84 100644 --- a/lib/nostrum/voice/audio.ex +++ b/lib/nostrum/voice/audio.ex @@ -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 @@ -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 diff --git a/lib/nostrum/voice/ports.ex b/lib/nostrum/voice/ports.ex index 6fa280f55..fa9ca1d2a 100644 --- a/lib/nostrum/voice/ports.ex +++ b/lib/nostrum/voice/ports.ex @@ -22,8 +22,6 @@ defmodule Nostrum.Voice.Ports do end end - alias Nostrum.Voice.Ports.State - require Logger use GenServer @@ -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