Skip to content

Commit 6f20232

Browse files
committed
Allow for manual finish of reading
1 parent f9fa14d commit 6f20232

File tree

3 files changed

+12
-7
lines changed

3 files changed

+12
-7
lines changed

lib/boombox/server.ex

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -443,18 +443,22 @@ defmodule Boombox.Server do
443443
defp producing_boombox_run(boombox_opts, server_pid, communication_medium) do
444444
last_packet =
445445
Boombox.run(boombox_opts)
446-
|> Enum.reduce(nil, fn new_packet, last_produced_packet ->
446+
|> Enum.reduce_while(nil, fn new_packet, last_produced_packet ->
447447
if last_produced_packet != nil do
448448
send(server_pid, {:packet_produced, last_produced_packet, self()})
449449
end
450450

451-
if communication_medium == :calls do
452-
receive do
453-
:produce_packet -> :ok
451+
action =
452+
if communication_medium == :calls do
453+
receive do
454+
:produce_packet -> :cont
455+
:finish_producing -> :halt
456+
end
457+
else
458+
:cont
454459
end
455-
end
456460

457-
new_packet
461+
{action, new_packet}
458462
end)
459463

460464
send(server_pid, {:finished, last_packet, self()})

mix.exs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -72,6 +72,7 @@ defmodule Boombox.Mixfile do
7272
{:membrane_portaudio_plugin, "~> 0.19.2"},
7373
{:membrane_sdl_plugin, "~> 0.18.5"},
7474
{:membrane_simple_rtsp_server, "~> 0.1.5", only: :test},
75+
{:coerce, github: "ypconstante/elixir-coerce", override: true},
7576
{:image, "~> 0.54.0"},
7677
{:async_test, github: "software-mansion-labs/elixir_async_test", only: :test},
7778
{:playwright, "~> 1.49.1-alpha.2", only: :test},

mix.lock

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
"castore": {:hex, :castore, "1.0.15", "8aa930c890fe18b6fe0a0cff27b27d0d4d231867897bd23ea772dee561f032a3", [:mix], [], "hexpm", "96ce4c69d7d5d7a0761420ef743e2f4096253931a3ba69e5ff8ef1844fe446d3"},
1111
"cc_precompiler": {:hex, :cc_precompiler, "0.1.11", "8c844d0b9fb98a3edea067f94f616b3f6b29b959b6b3bf25fee94ffe34364768", [:mix], [{:elixir_make, "~> 0.7", [hex: :elixir_make, repo: "hexpm", optional: false]}], "hexpm", "3427232caf0835f94680e5bcf082408a70b48ad68a5f5c0b02a3bea9f3a075b9"},
1212
"certifi": {:hex, :certifi, "2.15.0", "0e6e882fcdaaa0a5a9f2b3db55b1394dba07e8d6d9bcad08318fb604c6839712", [:rebar3], [], "hexpm", "b147ed22ce71d72eafdad94f055165c1c182f61a2ff49df28bcc71d1d5b94a60"},
13-
"coerce": {:hex, :coerce, "1.0.1", "211c27386315dc2894ac11bc1f413a0e38505d808153367bd5c6e75a4003d096", [:mix], [], "hexpm", "b44a691700f7a1a15b4b7e2ff1fa30bebd669929ac8aa43cffe9e2f8bf051cf1"},
13+
"coerce": {:git, "https://github.com/ypconstante/elixir-coerce.git", "74533caf2fa205ccbd5193c16e058512e014a4af", []},
1414
"corsica": {:hex, :corsica, "2.1.3", "dccd094ffce38178acead9ae743180cdaffa388f35f0461ba1e8151d32e190e6", [:mix], [{:plug, "~> 1.0", [hex: :plug, repo: "hexpm", optional: false]}, {:telemetry, "~> 0.4.0 or ~> 1.0", [hex: :telemetry, repo: "hexpm", optional: false]}], "hexpm", "616c08f61a345780c2cf662ff226816f04d8868e12054e68963e95285b5be8bc"},
1515
"cowlib": {:hex, :cowlib, "2.7.3", "a7ffcd0917e6d50b4d5fb28e9e2085a0ceb3c97dea310505f7460ff5ed764ce9", [:rebar3], [], "hexpm", "1e1a3d176d52daebbecbbcdfd27c27726076567905c2a9d7398c54da9d225761"},
1616
"crc": {:hex, :crc, "0.10.5", "ee12a7c056ac498ef2ea985ecdc9fa53c1bfb4e53a484d9f17ff94803707dfd8", [:mix, :rebar3], [{:elixir_make, "~> 0.6", [hex: :elixir_make, repo: "hexpm", optional: false]}], "hexpm", "3e673b6495a9525c5c641585af1accba59a1eb33de697bedf341e247012c2c7f"},

0 commit comments

Comments
 (0)