CC-4335: Timeline: Scheduling multiple webstreams, they can not be playing smoothly
-fixed
This commit is contained in:
parent
886888a958
commit
fbea75e680
3 changed files with 57 additions and 26 deletions
|
@ -420,6 +420,54 @@ def create_dynamic_source(uri) =
|
||||||
"Done!"
|
"Done!"
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
||||||
|
# A function to destroy a dynamic source
|
||||||
|
def destroy_dynamic_source_all(uri) =
|
||||||
|
# We need to find the source in the list,
|
||||||
|
# remove it and destroy it. Currently, the language
|
||||||
|
# lacks some nice operators for that so we do it
|
||||||
|
# the functional way
|
||||||
|
|
||||||
|
# This function is executed on every item in the list
|
||||||
|
# of dynamic sources
|
||||||
|
def parse_list(ret, current_element) =
|
||||||
|
# ret is of the form: (matching_sources, remaining_sources)
|
||||||
|
# We extract those two:
|
||||||
|
matching_sources = fst(ret)
|
||||||
|
remaining_sources = snd(ret)
|
||||||
|
|
||||||
|
# current_element is of the form: ("uri", source) so
|
||||||
|
# we check the first element
|
||||||
|
current_uri = fst(current_element)
|
||||||
|
# in this case, we add the source to the list of
|
||||||
|
# matched sources
|
||||||
|
(list.append( [snd(current_element)],
|
||||||
|
matching_sources),
|
||||||
|
remaining_sources)
|
||||||
|
end
|
||||||
|
|
||||||
|
# now we execute the function:
|
||||||
|
result = list.fold(parse_list, ([], []), !dyn_sources)
|
||||||
|
matching_sources = fst(result)
|
||||||
|
remaining_sources = snd(result)
|
||||||
|
|
||||||
|
# we store the remaining sources in dyn_sources
|
||||||
|
dyn_sources := remaining_sources
|
||||||
|
|
||||||
|
# if no source matched, we return an error
|
||||||
|
if list.length(matching_sources) == 0 then
|
||||||
|
"error: no matching sources!"
|
||||||
|
else
|
||||||
|
# we stop all sources
|
||||||
|
list.iter(source.shutdown, matching_sources)
|
||||||
|
# And return
|
||||||
|
"Done!"
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
# A function to destroy a dynamic source
|
# A function to destroy a dynamic source
|
||||||
def destroy_dynamic_source(uri) =
|
def destroy_dynamic_source(uri) =
|
||||||
# We need to find the source in the list,
|
# We need to find the source in the list,
|
||||||
|
@ -438,19 +486,19 @@ def destroy_dynamic_source(uri) =
|
||||||
# current_element is of the form: ("uri", source) so
|
# current_element is of the form: ("uri", source) so
|
||||||
# we check the first element
|
# we check the first element
|
||||||
current_uri = fst(current_element)
|
current_uri = fst(current_element)
|
||||||
#if current_uri == uri then
|
if current_uri == uri then
|
||||||
# In this case, we add the source to the list of
|
# In this case, we add the source to the list of
|
||||||
# matched sources
|
# matched sources
|
||||||
(list.append( [snd(current_element)],
|
(list.append( [snd(current_element)],
|
||||||
matching_sources),
|
matching_sources),
|
||||||
remaining_sources)
|
remaining_sources)
|
||||||
#else
|
else
|
||||||
# In this case, we put the element in the list of remaining
|
# In this case, we put the element in the list of remaining
|
||||||
# sources
|
# sources
|
||||||
#(matching_sources,
|
(matching_sources,
|
||||||
# list.append([current_element],
|
list.append([current_element],
|
||||||
# remaining_sources))
|
remaining_sources))
|
||||||
#end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
# Now we execute the function:
|
# Now we execute the function:
|
||||||
|
|
|
@ -103,7 +103,7 @@ server.register(namespace="dynamic_source",
|
||||||
description="Stop a dynamic source.",
|
description="Stop a dynamic source.",
|
||||||
usage="stop <uri>",
|
usage="stop <uri>",
|
||||||
"read_stop_all",
|
"read_stop_all",
|
||||||
fun (s) -> begin log("dynamic_source.read_stop") destroy_dynamic_source(s) end)
|
fun (s) -> begin log("dynamic_source.read_stop") destroy_dynamic_source_all(s) end)
|
||||||
|
|
||||||
default = amplify(id="silence_src", 0.00001, noise())
|
default = amplify(id="silence_src", 0.00001, noise())
|
||||||
default = rewrite_metadata([("artist","Airtime"), ("title", "offline")], default)
|
default = rewrite_metadata([("artist","Airtime"), ("title", "offline")], default)
|
||||||
|
|
|
@ -88,23 +88,6 @@ class PypoPush(Thread):
|
||||||
except ValueError, e:
|
except ValueError, e:
|
||||||
self.logger.error(str(e))
|
self.logger.error(str(e))
|
||||||
|
|
||||||
if len(liquidsoap_queue_approx) == 0 and not self.current_stream_info:
|
|
||||||
#Nothing is currently being playing by Liquidsoap
|
|
||||||
if current_event_chain[0]['type'] == 'file':
|
|
||||||
#Something is scheduled but Liquidsoap is not playing anything!
|
|
||||||
#Need to schedule it immediately..this might happen if Liquidsoap crashed.
|
|
||||||
self.modify_cue_point(current_event_chain[0])
|
|
||||||
next_media_item_chain = current_event_chain
|
|
||||||
time_until_next_play = 0
|
|
||||||
#sleep for 0.2 seconds to give pypo-file time to copy.
|
|
||||||
time.sleep(0.2)
|
|
||||||
continue
|
|
||||||
if current_event_chain[0]['type'] == 'stream':
|
|
||||||
#a stream is schedule but Liquidsoap is not playing it. Need to start it.
|
|
||||||
next_media_item_chain = current_event_chain
|
|
||||||
time_until_next_play = 0
|
|
||||||
continue
|
|
||||||
|
|
||||||
#At this point we know that Liquidsoap is playing something, and that something
|
#At this point we know that Liquidsoap is playing something, and that something
|
||||||
#is scheduled. We need to verify whether the schedule we just received matches
|
#is scheduled. We need to verify whether the schedule we just received matches
|
||||||
#what Liquidsoap is playing, and if not, correct it.
|
#what Liquidsoap is playing, and if not, correct it.
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue