Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
aura-engine
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package registry
Container registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Lars Kruse
aura-engine
Commits
da0e198b
Commit
da0e198b
authored
5 years ago
by
David Trattnig
Browse files
Options
Downloads
Patches
Plain Diff
Run player with workaround to FFWD per schedule.
parent
474a8b6e
No related branches found
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
modules/communication/liquidsoap/initthread.py
+59
-29
59 additions, 29 deletions
modules/communication/liquidsoap/initthread.py
with
59 additions
and
29 deletions
modules/communication/liquidsoap/initthread.py
+
59
−
29
View file @
da0e198b
...
@@ -29,67 +29,92 @@ import threading
...
@@ -29,67 +29,92 @@ import threading
from
libraries.enum.auraenumerations
import
ScheduleEntryType
from
libraries.enum.auraenumerations
import
ScheduleEntryType
"""
LiquidSoapInitThread class.
Starts the LiquidSoap player including the current show.
"""
class
LiquidSoapInitThread
(
threading
.
Thread
):
class
LiquidSoapInitThread
(
threading
.
Thread
):
logger
=
None
logger
=
None
active_entry
=
None
active_entry
=
None
liquidsoapcommunicator
=
None
liquidsoapcommunicator
=
None
# ------------------------------------------------------------------------------------------ #
def
__init__
(
self
,
liquidsoapcommunicator
,
active_entry
):
def
__init__
(
self
,
liquidsoapcommunicator
,
active_entry
):
"""
Initialize the thread.
"""
threading
.
Thread
.
__init__
(
self
)
threading
.
Thread
.
__init__
(
self
)
self
.
logger
=
logging
.
getLogger
(
"
AuraEngine
"
)
self
.
logger
=
logging
.
getLogger
(
"
AuraEngine
"
)
self
.
liquidsoapcommunicator
=
liquidsoapcommunicator
self
.
liquidsoapcommunicator
=
liquidsoapcommunicator
self
.
active_entry
=
active_entry
self
.
active_entry
=
active_entry
# ------------------------------------------------------------------------------------------ #
def
run
(
self
):
def
run
(
self
):
"""
Starts the LiquidSoap player including the current show.
"""
try
:
try
:
#
s
leep needed, because the socket is created too slow by liquidsoap
#
S
leep needed, because the socket is created too slow by liquidsoap
time
.
sleep
(
1
)
time
.
sleep
(
1
)
self
.
logger
.
info
(
"
Waited 1s for liquidsoap. Jez soit a si gspian
"
)
self
.
logger
.
info
(
"
Waited 1s for liquidsoap. Jez soit a si gspian
"
)
# enable lqs transaction
self
.
liquidsoapcommunicator
.
enable_transaction
()
self
.
liquidsoapcommunicator
.
enable_transaction
()
#
w
ait another second. lqs really starts slow.. be prepared you liquidsoap you!
#
W
ait another second. lqs really starts slow.. be prepared you liquidsoap you!
time
.
sleep
(
1
)
time
.
sleep
(
1
)
# set some parameters
self
.
set_start_parameters
()
self
.
set_start_parameters
()
# set active
self
.
set_active_show
()
self
.
set_active_show
()
# disable lqs transaction again
self
.
liquidsoapcommunicator
.
disable_transaction
()
self
.
liquidsoapcommunicator
.
disable_transaction
()
# The rest of the system now can use liquidsoap connection
# the rest of the system now can use liquidsoap connection
self
.
liquidsoapcommunicator
.
is_liquidsoap_running
=
True
self
.
liquidsoapcommunicator
.
is_liquidsoap_running
=
True
except
Exception
as
e
:
except
Exception
as
e
:
self
.
logger
.
critical
(
"
Liquidsoap connection ERROR! Restart LQ Server! Reason:
"
+
str
(
e
))
self
.
logger
.
critical
(
"
Liquidsoap connection ERROR! Restart LQ Server! Reason:
"
+
str
(
e
),
e
)
def
set_active_show
(
self
):
def
set_active_show
(
self
):
"""
Sets and resumes the show which should be playing at the time of starting
the LiquidSoap player.
"""
if
self
.
active_entry
is
not
None
:
if
self
.
active_entry
is
not
None
:
self
.
logger
.
info
(
"
LiquidSoapInitThread sets activechannel:
"
+
str
(
self
.
active_entry
))
channel
=
self
.
active_entry
.
type
channel
=
self
.
active_entry
.
type
self
.
logger
.
info
(
"
LiquidSoapInitThread sets activechannel
'
%s
'
for entry
'
%s
'"
%
(
channel
,
str
(
self
.
active_entry
)))
# have to seek?
if
channel
==
ScheduleEntryType
.
FILESYSTEM
:
if
channel
==
ScheduleEntryType
.
FILESYSTEM
:
# calc how many seconds were missed
# Have to seek? Calc how many seconds were missed
now_unix
=
time
.
mktime
(
datetime
.
datetime
.
now
().
timetuple
())
now_unix
=
time
.
mktime
(
datetime
.
datetime
.
now
().
timetuple
())
seconds_to_seek
=
now_unix
-
self
.
active_entry
.
start_unix
seconds_to_seek
=
now_unix
-
self
.
active_entry
.
start_unix
# and seek these seconds forward
# TODO For some reason LiquidSoap cue-points don't work. Actually,
# this would be the ideal approach to seek. Investigate some solution!
# if seconds_to_seek < 0:
# seconds_to_seek = 0
# self.liquidsoapcommunicator.activate(self.active_entry, seconds_to_seek)
self
.
liquidsoapcommunicator
.
activate
(
self
.
active_entry
,
seconds_to_seek
)
# And seek these seconds forward
if
seconds_to_seek
>
0
:
if
seconds_to_seek
>
0
:
self
.
liquidsoapcommunicator
.
playlist_seek
(
seconds_to_seek
)
# Without plenty of timeout (10s) the seek doesn't work
seconds_to_seek
+=
10
time
.
sleep
(
10
)
response
=
self
.
liquidsoapcommunicator
.
playlist_seek
(
seconds_to_seek
)
self
.
logger
.
info
(
"
LiquidSoap seek response:
"
+
response
)
#
f
inally make something hearable :-)
#
F
inally make something hearable :-)
if
channel
!=
""
and
channel
is
not
None
:
if
channel
:
#
a
ctivate
http
stream if needed
#
A
ctivate
HTTP
stream if needed
self
.
liquidsoapcommunicator
.
http_start_stop
(
channel
==
ScheduleEntryType
.
STREAM
)
self
.
liquidsoapcommunicator
.
http_start_stop
(
channel
==
ScheduleEntryType
.
STREAM
)
#
f
inally set the volume up
#
F
inally set the volume up
self
.
liquidsoapcommunicator
.
channel_volume
(
channel
.
value
,
self
.
active_entry
.
volume
)
self
.
liquidsoapcommunicator
.
channel_volume
(
channel
.
value
,
self
.
active_entry
.
volume
)
else
:
else
:
self
.
logger
.
error
(
"
Channel is NULL or empty! Cannot set
"
)
self
.
logger
.
error
(
"
Channel is NULL or empty! Cannot set
"
)
...
@@ -97,18 +122,23 @@ class LiquidSoapInitThread(threading.Thread):
...
@@ -97,18 +122,23 @@ class LiquidSoapInitThread(threading.Thread):
else
:
else
:
self
.
logger
.
warning
(
"
No active entry in the scheduler! Is a programme loaded?
"
)
self
.
logger
.
warning
(
"
No active entry in the scheduler! Is a programme loaded?
"
)
def
set_start_parameters
(
self
):
def
set_start_parameters
(
self
):
# reset channels and reload them
"""
Set initial parameters for the LiquidSoap player startup.
"""
# Reset channels and reload them
channels
=
self
.
liquidsoapcommunicator
.
reload_channels
()
channels
=
self
.
liquidsoapcommunicator
.
reload_channels
()
#
f
or all available channels
#
F
or all available channels
for
c
in
channels
:
for
c
in
channels
:
#
s
et volume to zero
#
S
et volume to zero
self
.
liquidsoapcommunicator
.
channel_volume
(
c
,
"
0
"
)
self
.
liquidsoapcommunicator
.
channel_volume
(
c
,
"
0
"
)
#
a
nd activate this channel
#
A
nd activate this channel
self
.
liquidsoapcommunicator
.
channel_activate
(
c
,
True
)
self
.
liquidsoapcommunicator
.
channel_activate
(
c
,
True
)
#
s
etting init params like a blank file..
#
S
etting init params like a blank file..
install_dir
=
self
.
liquidsoapcommunicator
.
config
.
get
(
"
install_dir
"
)
install_dir
=
self
.
liquidsoapcommunicator
.
config
.
get
(
"
install_dir
"
)
self
.
liquidsoapcommunicator
.
playlist_push
(
install_dir
+
"
/configuration/blank.flac
"
)
self
.
liquidsoapcommunicator
.
playlist_push
(
install_dir
+
"
/configuration/blank.flac
"
)
# .. or the radio fro stream (it is overwritten as soon as one http overtake is planned)
# .. or the radio fro stream (it is overwritten as soon as one http overtake is planned)
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment