Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
Lars Kruse
aura-engine
Commits
a1a97d34
Commit
a1a97d34
authored
May 05, 2021
by
david
Browse files
Fixed timer init and cmd chaining. #72
parent
113b3ff0
Changes
2
Show whitespace changes
Inline
Side-by-side
src/control.py
View file @
a1a97d34
...
...
@@ -186,6 +186,7 @@ class EngineExecutor(Timer):
"""
_lock
=
None
logger
=
logging
.
getLogger
(
"AuraEngine"
)
initialized
=
None
timer_store
=
{}
parent_timer
=
None
child_timer
=
None
...
...
@@ -208,6 +209,7 @@ class EngineExecutor(Timer):
func (function): The function to be called
param (object): Parameter passt to the function
"""
self
.
initialized
=
False
self
.
_lock
=
Lock
()
from
src.engine
import
Engine
now_unix
=
Engine
.
engine_time
()
...
...
@@ -252,6 +254,11 @@ class EngineExecutor(Timer):
"""
Calls the passed function `func` when the timer is ready.
"""
while
self
.
initialized
==
False
:
timer
.
sleep
(
0.001
)
self
.
logger
.
info
(
SU
.
orange
(
"Waiting until the EngineExecutor is done with initialization..."
))
if
not
self
.
direct_exec
:
#TODO Evaluate if we should join for direct exec too
self
.
join
()
func
()
...
...
@@ -276,6 +283,7 @@ class EngineExecutor(Timer):
self
.
wait_for_parent
()
thread
=
Thread
(
name
=
self
.
timer_id
,
target
=
self
.
func
,
args
=
(
self
.
param
,))
thread
.
start
()
self
.
initialized
=
True
def
exec_timed
(
self
):
...
...
@@ -290,6 +298,7 @@ class EngineExecutor(Timer):
else
:
self
.
func
()
super
().
__init__
(
self
.
diff
,
wrapper_func
,
(
self
.
param
,))
self
.
_name
=
self
.
timer_id
self
.
initialized
=
True
def
update_store
(
self
):
...
...
src/scheduling/scheduler.py
View file @
a1a97d34
...
...
@@ -296,7 +296,7 @@ class AuraScheduler(threading.Thread):
Since each scheduled playlist can consist of multiple entry types such as *file*, *live*,
and *stream*, the play-out of the timeslot is actually a bit more complex. Before any playlist
entries of the timeslot can be turned into sound, they need to be
group
ed, queued and pre-loaded.
entries of the timeslot can be turned into sound, they need to be
aggregat
ed, queued and pre-loaded.
1. First, all entries are aggregated when they hold filesystem entries.
Given you have a playlist with 10 entries, the first 4 are consisting of files, the next two
...
...
@@ -424,8 +424,9 @@ class TimeslotCommand(EngineExecutor):
fade_out_time
=
float
(
self
.
config
.
get
(
"fade_out_time"
))
start_fade_out
=
timeslot
.
end_unix
-
fade_out_time
self
.
logger
.
info
(
f
"Fading out timeslot in
{
start_fade_out
}
seconds at
{
timeslot
.
timeslot_end
}
| Timeslot:
{
timeslot
}
"
)
# Initialize the "fade in" EngineExecuter and instatiate a connected child EngineExecuter for "fade out" when the parent is ready
super
().
__init__
(
"TIMESLOT"
,
None
,
timeslot
.
start_unix
,
self
.
do_start_timeslot
,
timeslot
)
EngineExecutor
(
"TIMESLOT"
,
self
,
start_fade_out
,
self
.
do_end_timeslot
,
timeslot
)
self
.
on_ready
(
lambda
:
EngineExecutor
(
"TIMESLOT"
,
self
,
start_fade_out
,
self
.
do_end_timeslot
,
timeslot
)
)
def
do_start_timeslot
(
self
,
timeslot
):
...
...
@@ -453,7 +454,7 @@ class TimeslotCommand(EngineExecutor):
class
PlayCommand
(
EngineExecutor
):
"""
Command for triggering
start and end of timeslot events
.
Command for triggering
timed preloading and playing as a child command
.
"""
engine
=
None
config
=
None
...
...
@@ -471,7 +472,8 @@ class PlayCommand(EngineExecutor):
start_preload
=
entries
[
0
].
start_unix
-
self
.
config
.
get
(
"preload_offset"
)
start_play
=
entries
[
0
].
start_unix
preload_timer
=
super
().
__init__
(
"PLAY"
,
None
,
start_preload
,
self
.
do_preload
,
entries
)
# Initialize the "preload" EngineExecuter and attach a child `PlayCommand` to the "on_ready" event handler
preload_timer
=
super
().
__init__
(
"PRELOAD"
,
None
,
start_preload
,
self
.
do_preload
,
entries
)
self
.
on_ready
(
lambda
:
EngineExecutor
(
"PLAY"
,
self
,
start_play
,
self
.
do_play
,
entries
))
...
...
@@ -509,5 +511,3 @@ class PlayCommand(EngineExecutor):
self
.
logger
.
info
(
self
.
engine
.
scheduler
.
timeslot_renderer
.
get_ascii_timeslots
())
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment