aboutsummaryrefslogtreecommitdiffhomepage
path: root/applause.lua
diff options
context:
space:
mode:
authorRobin Haberkorn <robin.haberkorn@googlemail.com>2016-01-03 15:19:17 +0100
committerRobin Haberkorn <robin.haberkorn@googlemail.com>2016-01-03 15:19:17 +0100
commitf8318d9d52dc136eecbae52d047f9ad9325dce76 (patch)
tree97e45c04c3d59f288b86346158a7eaeb20ee25a0 /applause.lua
parent856c775316dbcdba36acfab1a3c300b0372d8ecf (diff)
downloadapplause2-f8318d9d52dc136eecbae52d047f9ad9325dce76.tar.gz
preliminary (broken) client forking support
Diffstat (limited to 'applause.lua')
-rw-r--r--applause.lua34
1 files changed, 33 insertions, 1 deletions
diff --git a/applause.lua b/applause.lua
index 644c23d..ee75701 100644
--- a/applause.lua
+++ b/applause.lua
@@ -66,7 +66,7 @@ function DeriveClass(base, ctor)
for _, m in pairs{"len", "call", "tostring",
"add", "sub", "mul", "div",
"mod", "pow", "unm",
- "concat", "lt", "le"} do
+ "concat", "lt", "le", "gc"} do
class["__"..m] = base["__"..m]
end
end
@@ -310,6 +310,11 @@ function Stream:play()
error("C function not registered!")
end
+-- implemented in applause.c
+function Stream:fork()
+ error("C function not registered!")
+end
+
function Stream:save(filename, format)
if self:len() == math.huge then
error("Cannot save infinite stream")
@@ -1352,3 +1357,30 @@ end
function BRFStream:len()
return self.stream:len()
end
+
+--
+-- Jack client abstractions. This passes low level signals
+-- and works only with clients created via Stream.fork()
+--
+
+ffi.cdef[[
+int kill(int pid, int sig);
+]]
+
+Client = DeriveClass(null, function(self, pid)
+ self.pid = pid
+end)
+
+function Client:play()
+ ffi.C.kill(self.pid, 10); -- SIGUSR1
+end
+
+function Client:stop()
+ ffi.C.kill(self.pid, 12); -- SIGUSR2
+end
+
+function Client:kill()
+ ffi.C.kill(self.pid, 15); -- SIGTERM
+end
+
+Client.__gc = Client.kill