From 4e7591c1c6548ace3994e7b389dc7966fcef339e Mon Sep 17 00:00:00 2001 From: David Trattnig <david.trattnig@o94.at> Date: Wed, 19 Feb 2020 14:51:21 +0100 Subject: [PATCH] Initial version for clearing fs queue. --- modules/liquidsoap/in_filesystem.liq | 55 +++++++++++++++++++++++++++- 1 file changed, 54 insertions(+), 1 deletion(-) diff --git a/modules/liquidsoap/in_filesystem.liq b/modules/liquidsoap/in_filesystem.liq index 0a6ad11c..0604f74d 100644 --- a/modules/liquidsoap/in_filesystem.liq +++ b/modules/liquidsoap/in_filesystem.liq @@ -23,4 +23,57 @@ # # a hard one -input_fs = request.equeue(id="fs") \ No newline at end of file +input_fs = request.equeue(id="fs") + + +#input_fs = cue_cut(mksafe(request.equeue(id="fs"))) + +#req = request.queue(id="req") + +# def clear_queue(s) = +# ret = server.execute("fs.queue") +# #ret = request.equeue(id="fs") +# ret = list.hd(ret) +# ret = string.split(separator=" ",ret) +# #print("input FS.list: #{ret}") +# list.iter(fun(x) -> begin +# print("IGNORE: #{x}") +# ignore(server.execute("fs.ignore #{x}")) +# end, ret) +# res = source.skip(s) +# #(0.5) +# print("SKIP RES: #{res}") +# res = source.skip(s) +# print("SKIP RES: #{res}") +# end + +# server.register(namespace="fs", +# description="Flush queue and stop request source.", +# usage="stop", +# "stop", +# fun (s) -> begin clear_queue(input_fs) "Done." end) + + +def clear_items(s) = + ret = server.execute("fs.primary_queue") + ret = list.hd(ret) + if ret == "" then + log("Queue cleared.") + (-1.) + else + log("There are still items in the queue, trying skip ...") + source.skip(s) + (0.1) + end +end + +def clear_queue(s) = + add_timeout(fast=false, 0.5, {clear_items(s)}) +end + +server.register(namespace="fs", + description="Clear all items of the filesystem queue.", + usage="clear", + "clear", + fun (s) -> begin clear_queue(input_fs) "Done." end) + -- GitLab