struct InputStateInfo {
InputStateInfo(const InputState& input_state);
- unsigned last_width[MAX_CARDS], last_height[MAX_CARDS];
- bool last_interlaced[MAX_CARDS], last_has_signal[MAX_CARDS], last_is_connected[MAX_CARDS];
- unsigned last_frame_rate_nom[MAX_CARDS], last_frame_rate_den[MAX_CARDS];
+ unsigned last_width[MAX_VIDEO_CARDS], last_height[MAX_VIDEO_CARDS];
+ bool last_interlaced[MAX_VIDEO_CARDS], last_has_signal[MAX_VIDEO_CARDS], last_is_connected[MAX_VIDEO_CARDS];
+ unsigned last_frame_rate_nom[MAX_VIDEO_CARDS], last_frame_rate_den[MAX_VIDEO_CARDS];
};
InputStateInfo::InputStateInfo(const InputState &input_state)
{
- for (unsigned signal_num = 0; signal_num < MAX_CARDS; ++signal_num) {
+ for (unsigned signal_num = 0; signal_num < MAX_VIDEO_CARDS; ++signal_num) {
BufferedFrame frame = input_state.buffered_frames[signal_num][0];
if (frame.frame == nullptr) {
last_width[signal_num] = last_height[signal_num] = 0;
} // namespace
-Theme::Theme(const char *filename, ResourcePool *resource_pool, unsigned num_cards)
+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)
{
L = luaL_newstate();
register_class("MixEffect", MixEffect_funcs);
register_class("InputStateInfo", InputStateInfo_funcs);
- // Run script.
+ // Run script. Search through all directories until we find a file that will load
+ // (as in, does not return LUA_ERRFILE); then run it. We store load errors
+ // from all the attempts, and show them once we know we can't find any of them.
lua_settop(L, 0);
- if (luaL_dofile(L, filename)) {
- fprintf(stderr, "error: %s\n", lua_tostring(L, -1));
+ vector<string> errors;
+ bool success = false;
+ for (size_t i = 0; i < search_dirs.size(); ++i) {
+ string path = search_dirs[i] + "/" + filename;
+ int err = luaL_loadfile(L, path.c_str());
+ if (err == 0) {
+ // Success; actually call the code.
+ if (lua_pcall(L, 0, LUA_MULTRET, 0)) {
+ fprintf(stderr, "Error when running %s: %s\n", path.c_str(), lua_tostring(L, -1));
+ exit(1);
+ }
+ success = true;
+ break;
+ }
+ errors.push_back(lua_tostring(L, -1));
lua_pop(L, 1);
+ if (err != LUA_ERRFILE) {
+ // The file actually loaded, but failed to parse somehow. Abort; don't try the next one.
+ break;
+ }
+ }
+
+ if (!success) {
+ for (const string &error : errors) {
+ fprintf(stderr, "%s\n", error.c_str());
+ }
exit(1);
}
assert(lua_gettop(L) == 0);