Skip to content
Snippets Groups Projects
Commit db531064 authored by David Trattnig's avatar David Trattnig
Browse files

Scheduled fallback queue. #43

parent 1b89eab0
No related branches found
No related tags found
No related merge requests found
......@@ -78,21 +78,6 @@ stripped_stream = strip_blank(
mixer
)
station_playlist = playlist(
id="station_playlist",
fallback_station_playlist_path,
mode="randomize",
reload_mode="watch",
reload=10)
station_folder = mksafe(
playlist(id="station_folder",
fallback_station_dir,
mode="randomize",
reload=fallback_station_dir_reload,
reload_mode="seconds"))
# When some regular playout is happening and it is returned to the fallback,
# we don't want to resume the previous fallback track:
def on_track_change(s) =
......@@ -101,14 +86,19 @@ def on_track_change(s) =
end
stripped_stream = on_track(on_track_change, stripped_stream)
station_playlist = augment_fallback(station_playlist)
station_folder = augment_fallback( station_folder)
output_source = fallback(
id="fallback-scheduled",
track_sensitive=false,
replay_metadata=true,
[ stripped_stream, input_fallback_scheduled])
output_source = fallback(
id="fallback-station-playlist",
track_sensitive=false,
replay_metadata=true,
[ stripped_stream, station_playlist])
[ output_source, station_playlist])
output_source = fallback(
id="fallback-station-folder",
......
......@@ -17,24 +17,66 @@
# along with this program. If not, see <http://www.gnu.org/licenses/>.
# Called when some new metadata info is available
def on_metadata_notification(meta) =
filename = meta["filename"]
# artist = meta["artist"]
# title = meta["title"]
system('#{list.assoc(default="", "install_dir", ini)}/guru.py --on_play "#{filename}"')
end
#####################################
# DEFAULT SOURCES #
#####################################
# Create Filesystem Sources
input_filesystem_0 = request.equeue(id="in_filesystem_0")
input_filesystem_1 = request.equeue(id="in_filesystem_1")
#input_fs = cue_cut(mksafe(request.equeue(id="fs")))
# Apply ReplayGain Normalization
input_filesystem_0 = amplify(id="in_filesystem_0", 1., override="replay_gain", input_filesystem_0)
input_filesystem_1 = amplify(id="in_filesystem_1", 1., override="replay_gain", input_filesystem_1)
# Call engine core handler to "on_play" (e.g. to update track service)
# Add Event Handlers
input_filesystem_0 = on_metadata(id="in_filesystem_0", on_metadata_notification, input_filesystem_0)
input_filesystem_1 = on_metadata(id="in_filesystem_1", on_metadata_notification, input_filesystem_1)
def do_meta_filesystem(meta) =
filename = meta["filename"]
# artist = meta["artist"]
# title = meta["title"]
# print('CALLING GURU #{list.assoc(default="", "install_dir", ini)}/guru.py')
system('#{list.assoc(default="", "install_dir", ini)}/guru.py --on_play "#{filename}" &')
end
input_filesystem_0 = on_metadata(id="in_filesystem_0", do_meta_filesystem, input_filesystem_0)
input_filesystem_1 = on_metadata(id="in_filesystem_1", do_meta_filesystem, input_filesystem_1)
#####################################
# FALLBACK SOURCES #
#####################################
input_fallback_scheduled = request.equeue(id="in_fallback_scheduled")
station_playlist = playlist(
id="station_playlist",
fallback_station_playlist_path,
mode="randomize",
reload_mode="watch",
reload=10)
station_folder = mksafe(
playlist(id="station_folder",
fallback_station_dir,
mode="randomize",
reload=fallback_station_dir_reload,
reload_mode="seconds"))
# Apply ReplayGain Normalization
input_fallback_scheduled = amplify(id="in_fallback_scheduled", 1., override="replay_gain", input_fallback_scheduled)
station_playlist = amplify(id="station_playlist", 1., override="replay_gain", station_playlist)
station_folder = amplify(id="station_folder", 1., override="replay_gain", station_folder)
# Add Event Handlers
input_fallback_scheduled = on_metadata(id="in_fallback_scheduled", on_metadata_notification, input_fallback_scheduled)
station_playlist = on_metadata(id="station_playlist", on_metadata_notification, station_playlist)
station_folder = on_metadata(id="station_folder", on_metadata_notification, station_folder)
#####################################
# SERVER FUNCTIONS #
#####################################
def clear_items(ns) =
ret = server.execute("#{source.id(ns)}.primary_queue")
......@@ -53,11 +95,11 @@ def clear_queue(ns) =
add_timeout(fast=false, 0.5, {clear_items(ns)})
end
# Clear Queue 0
# Clear Filesystem Queue A
server.register(namespace=source.id(input_filesystem_0),
description="Clear all items of the filesystem Queue A.",
description="Clear all items of the filesystem queue A.",
usage="clear",
"clear_filesystem_0",
"clear",
fun (s) ->
begin
......@@ -66,11 +108,11 @@ server.register(namespace=source.id(input_filesystem_0),
end
)
# Clear Queue 1
# Clear Filesystem Queue B
server.register(namespace=source.id(input_filesystem_1),
description="Clear all items of the filesystem Queue B.",
description="Clear all items of the filesystem queue B.",
usage="clear",
"clear_filesystem_1",
"clear",
fun (s) ->
begin
......@@ -78,3 +120,42 @@ server.register(namespace=source.id(input_filesystem_1),
"Clearing done."
end
)
# Clear Scheduled Fallback Queue
server.register(namespace=source.id(input_fallback_scheduled),
description="Clear all items of the scheduled fallback queue.",
usage="clear",
"clear",
fun (s) ->
begin
clear_queue(input_fallback_scheduled)
"Clearing done."
end
)
# Seek Filesystem Queue A
server.register(namespace = source.id(input_filesystem_0),
description="seek to relative position in #{source.id(input_filesystem_0)}",
usage = "seek <duration in seconds>",
"seek",
fun(t) -> begin
log("Seeking #{t} sec")
t = float_of_string(default=0.,t)
ret = source.seek(input_filesystem_0, t)
"Seeked #{ret} seconds."
end
)
# Seek Filesystem Queue B
server.register(namespace = source.id(input_filesystem_1),
description="seek to relative position in #{source.id(input_filesystem_1)}",
usage = "seek <duration in seconds>",
"seek",
fun(t) -> begin
log("Seeking #{t} sec")
t = float_of_string(default=0.,t)
ret = source.seek(input_filesystem_1, t)
"Seeked #{ret} seconds."
end
)
\ No newline at end of file
......@@ -17,29 +17,6 @@
# along with this program. If not, see <http://www.gnu.org/licenses/>.
#####################
# basics #
#####################
# Called when some new metadata info is available
def on_metadata_notification(meta) =
filename = meta["filename"]
# artist = meta["artist"]
# title = meta["title"]
system('#{list.assoc(default="", "install_dir", ini)}/guru.py --on_play "#{filename}"')
end
def augment_fallback(source) =
# Apply normalization using ReplayGain information
source = amplify(1., override="replay_gain", source)
# Watch metadata change
source = on_metadata(on_metadata_notification, source)
source
end
#####################
# stream to icecast #
#####################
......
......@@ -186,66 +186,6 @@ server.register(namespace = "auraengine",
end
)
# enable the seek function for the input from the filesystem
server.register(namespace = source.id(input_filesystem_0),
description="seek to relative position in #{source.id(input_filesystem_0)}",
usage = "seek <duration in seconds>",
"seek",
fun(t) -> begin
log("Seeking #{t} sec")
t = float_of_string(default=0.,t)
ret = source.seek(input_filesystem_0, t)
"Seeked #{ret} seconds."
end
)
server.register(namespace = source.id(input_filesystem_1),
description="seek to relative position in #{source.id(input_filesystem_1)}",
usage = "seek <duration in seconds>",
"seek",
fun(t) -> begin
log("Seeking #{t} sec")
t = float_of_string(default=0.,t)
ret = source.seek(input_filesystem_1, t)
"Seeked #{ret} seconds."
end
)
# server.register(namespace = source.id(input_filesystem_2),
# description="seek to relative position in #{source.id(input_filesystem_2)}",
# usage = "seek <duration in seconds>",
# "seek",
# fun(t) -> begin
# log("Seeking #{t} sec")
# t = float_of_string(default=0.,t)
# ret = source.seek(input_filesystem_2, t)
# "Seeked #{ret} seconds."
# end
# )
# server.register(namespace = source.id(input_filesystem_3),
# description="seek to relative position in #{source.id(input_filesystem_3)}",
# usage = "seek <duration in seconds>",
# "seek",
# fun(t) -> begin
# log("Seeking #{t} sec")
# t = float_of_string(default=0.,t)
# ret = source.seek(input_filesystem_3, t)
# "Seeked #{ret} seconds."
# end
# )
# server.register(namespace = source.id(input_filesystem_4),
# description="seek to relative position in #{source.id(input_filesystem_4)}",
# usage = "seek <duration in seconds>",
# "seek",
# fun(t) -> begin
# log("Seeking #{t} sec")
# t = float_of_string(default=0.,t)
# ret = source.seek(input_filesystem_4, t)
# "Seeked #{ret} seconds."
# end
# )
def fadeTo(source_number) =
if source_number == "" then
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment