From e12ea319ac5336c7f03cdc1fa93a425a629c2028 Mon Sep 17 00:00:00 2001 From: varsill Date: Mon, 27 Nov 2023 17:19:30 +0100 Subject: [PATCH] Move guard to element's GenServer --- lib/membrane/core/element.ex | 3 +++ lib/membrane/core/timer_controller.ex | 16 +++++----------- 2 files changed, 8 insertions(+), 11 deletions(-) diff --git a/lib/membrane/core/element.ex b/lib/membrane/core/element.ex index 5901c9048..18e231c24 100644 --- a/lib/membrane/core/element.ex +++ b/lib/membrane/core/element.ex @@ -256,7 +256,10 @@ defmodule Membrane.Core.Element do end defp do_handle_info(Message.new(:timer_tick, timer_id), state) do + state = %{state | supplying_demand?: true} state = TimerController.handle_tick(timer_id, state) + state = %{state | supplying_demand?: false} + state = Membrane.Core.Element.DemandHandler.handle_delayed_demands(state) {:noreply, state} end diff --git a/lib/membrane/core/timer_controller.ex b/lib/membrane/core/timer_controller.ex index cae1ae2c5..85e154fcb 100644 --- a/lib/membrane/core/timer_controller.ex +++ b/lib/membrane/core/timer_controller.ex @@ -58,8 +58,6 @@ defmodule Membrane.Core.TimerController do @spec handle_tick(Timer.id(), Component.state()) :: Component.state() def handle_tick(timer_id, state) when is_timer_present(timer_id, state) do - state = %{state | supplying_demand?: true} - state = CallbackHandler.exec_and_handle_callback( :handle_tick, @@ -70,15 +68,11 @@ defmodule Membrane.Core.TimerController do ) # in case the timer was removed in handle_tick - state = - if is_timer_present(timer_id, state) do - update_in(state, [:synchronization, :timers, timer_id], &Timer.tick/1) - else - state - end - - state = %{state | supplying_demand?: false} - Membrane.Core.Element.DemandHandler.handle_delayed_demands(state) + if is_timer_present(timer_id, state) do + update_in(state, [:synchronization, :timers, timer_id], &Timer.tick/1) + else + state + end end def handle_tick(_timer_id, state) do