local wb_effect = scene:add_effect(WhiteBalanceEffect.new())
scene:finalize()
--- API ENTRY POINT
--- Returns the number of outputs in addition to the live (0) and preview (1).
--- Called only once, at the start of the program.
-function num_channels()
- return 2
-end
-
-- Set some global state.
+Nageru.set_num_channels(2) -- Can only be called at the start of the program.
Nageru.set_channel_name(2, "First input")
Nageru.set_channel_name(3, "Second input")
if (lua_pcall(L, 0, 1, 0) != 0) {
fprintf(stderr, "error running function `num_channels': %s\n", lua_tostring(L, -1));
+ fprintf(stderr, "Try Nageru.set_num_channels(...) at the start of the script instead.\n");
abort();
}
return 0;
}
+int Nageru_set_num_channels(lua_State *L)
+{
+ // NOTE: m is already locked.
+ Theme *theme = get_theme_updata(L);
+ if (theme->startup_finished) {
+ luaL_error(L, "set_num_channels() can only be called at startup.");
+ }
+ theme->num_channels = luaL_checknumber(L, 1);
+ lua_pop(L, 1);
+ return 0;
+}
+
Theme::Theme(const string &filename, const vector<string> &search_dirs, ResourcePool *resource_pool, unsigned num_cards)
: resource_pool(resource_pool), num_cards(num_cards), signal_to_card_mapping(global_flags.default_stream_mapping)
{
}
assert(lua_gettop(L) == 0);
- // Ask it for the number of channels.
- num_channels = call_num_channels(L);
+ if (num_channels == -1) {
+ // Ask it for the number of channels.
+ num_channels = call_num_channels(L);
+ }
+ startup_finished = true;
}
Theme::~Theme()
const luaL_Reg Nageru_funcs[] = {
{ "set_channel_name", Nageru_set_channel_name },
+ { "set_num_channels", Nageru_set_num_channels },
{ NULL, NULL }
};
lua_pushlightuserdata(L, this);
lua_State *L; // Protected by <m>.
const InputState *input_state = nullptr; // Protected by <m>. Only set temporarily, during chain setup.
movit::ResourcePool *resource_pool;
- int num_channels;
+ int num_channels = -1;
unsigned num_cards;
+ bool startup_finished = false;
std::mutex map_m;
std::map<int, int> signal_to_card_mapping; // Protected by <map_m>.
friend class Scene;
friend int ThemeMenu_set(lua_State *L);
friend int Nageru_set_channel_name(lua_State *L);
+ friend int Nageru_set_num_channels(lua_State *L);
};
// LiveInputWrapper is a facade on top of an YCbCrInput, exposed to
static_scene:finalize()
-- Set some global state.
+Nageru.set_num_channels(4) -- Can only be called at the start of the program.
Nageru.set_channel_name(SBS_SIGNAL_NUM + 2, "Side-by-side")
Nageru.set_channel_name(STATIC_SIGNAL_NUM + 2, "Static picture")
--- API ENTRY POINT
--- Returns the number of outputs in addition to the live (0) and preview (1).
--- Called only once, at the start of the program.
-function num_channels()
- return 4
-end
-
function is_plain_signal(num)
return num == INPUT0_SIGNAL_NUM or num == INPUT1_SIGNAL_NUM
end