]> git.sesse.net Git - nageru/blobdiff - theme.lua
Delete streams when they are closed (prevents memory leak on disconnecting clients).
[nageru] / theme.lua
index 1abaae9c32e955695a986a16a0383aae835672e5..04195f28f7d58f707cba5e8ec7ab5a109c290f1e 100644 (file)
--- a/theme.lua
+++ b/theme.lua
@@ -261,10 +261,29 @@ function num_channels()
        return 4
 end
 
+-- Helper function to write e.g. “720p60”. The difference between this
+-- and get_channel_resolution_raw() is that this one also can say that
+-- there's no signal.
+function get_channel_resolution(signal_num)
+       res = last_resolution[signal_num]
+       if (not res) or res.height <= 0 then
+               return "no signal"
+       end
+       if not res.has_signal then
+               if res.height == 525 then
+                       -- Special mode for the USB3 cards.
+                       return "no signal"
+               end
+               return get_channel_resolution_raw(res) .. ", no signal"
+       else
+               return get_channel_resolution_raw(res)
+       end
+end
+
 -- Helper function to write e.g. “60” or “59.94”.
-function get_frame_rate(signal_num)
-       local nom = last_resolution[signal_num].frame_rate_nom
-       local den = last_resolution[signal_num].frame_rate_den
+function get_frame_rate(res)
+       local nom = res.frame_rate_nom
+       local den = res.frame_rate_den
        if nom % den == 0 then
                return nom / den
        else
@@ -273,17 +292,11 @@ function get_frame_rate(signal_num)
 end
 
 -- Helper function to write e.g. “720p60”.
-function get_channel_resolution(signal_num)
-       if last_resolution[signal_num] then
-               if not last_resolution[signal_num].has_signal then
-                       return "no signal"
-               elseif last_resolution[signal_num].interlaced then
-                       return last_resolution[signal_num].height .. "i" .. get_frame_rate(signal_num)
-               else
-                       return last_resolution[signal_num].height .. "p" .. get_frame_rate(signal_num)
-               end
+function get_channel_resolution_raw(res)
+       if res.interlaced then
+               return res.height .. "i" .. get_frame_rate(res)
        else
-               return "no signal"
+               return res.height .. "p" .. get_frame_rate(res)
        end
 end
 
@@ -306,6 +319,8 @@ end
 -- API ENTRY POINT
 -- Returns, given a channel number, which signal it corresponds to (starting from 0).
 -- Should return -1 if the channel does not correspond to a simple signal.
+-- (The information is used for whether right-click on the channel should bring up
+-- an input selector or not.)
 -- Called once for each channel, at the start of the program.
 -- Will never be called for live (0) or preview (1).
 function channel_signal(channel)
@@ -354,6 +369,7 @@ function get_transitions(t)
        finish_transitions(t)
 
        if live_signal_num == preview_signal_num then
+               -- No transitions possible.
                return {}
        end
 
@@ -383,6 +399,9 @@ function get_transitions(t)
        return {"Cut"}
 end
 
+-- API ENTRY POINT
+-- Called when the user clicks a transition button. For our case,
+-- we only do cuts, so we ignore the parameters; just switch live and preview.
 function transition_clicked(num, t)
        if num == 0 then
                -- Cut.