From c7969079ddaa7ac4aced304f039420435933715e Mon Sep 17 00:00:00 2001 From: "Steinar H. Gunderson" Date: Sun, 1 Nov 2015 20:35:36 +0100 Subject: [PATCH] Add some primitive emergency card mapping. Useful for testing. --- mixer.cpp | 2 +- mixer.h | 2 -- theme.cpp | 9 +++++++-- theme.h | 7 +++++-- 4 files changed, 13 insertions(+), 7 deletions(-) diff --git a/mixer.cpp b/mixer.cpp index 9158b34..cf2ed83 100644 --- a/mixer.cpp +++ b/mixer.cpp @@ -86,7 +86,7 @@ Mixer::Mixer(const QSurfaceFormat &format, unsigned num_cards) movit_texel_subpixel_precision /= 2.0; resource_pool.reset(new ResourcePool); - theme.reset(new Theme("theme.lua", resource_pool.get())); + theme.reset(new Theme("theme.lua", resource_pool.get(), num_cards)); output_channel[OUTPUT_LIVE].parent = this; output_channel[OUTPUT_PREVIEW].parent = this; output_channel[OUTPUT_INPUT0].parent = this; diff --git a/mixer.h b/mixer.h index 9f32f2a..82a3cca 100644 --- a/mixer.h +++ b/mixer.h @@ -20,8 +20,6 @@ #include "httpd.h" #include "ebu_r128_proc.h" -#define MAX_CARDS 16 - namespace movit { class YCbCrInput; } diff --git a/theme.cpp b/theme.cpp index 9914952..2a84093 100644 --- a/theme.cpp +++ b/theme.cpp @@ -372,8 +372,8 @@ void LiveInputWrapper::connect_signal(int signal_num) theme->connect_signal(input, signal_num); } -Theme::Theme(const char *filename, ResourcePool *resource_pool) - : resource_pool(resource_pool) +Theme::Theme(const char *filename, ResourcePool *resource_pool, unsigned num_cards) + : resource_pool(resource_pool), num_cards(num_cards) { L = luaL_newstate(); luaL_openlibs(L); @@ -483,6 +483,11 @@ std::vector Theme::get_transition_names(float t) void Theme::connect_signal(YCbCrInput *input, int signal_num) { + if (signal_num >= int(num_cards)) { + fprintf(stderr, "WARNING: Theme asked for input %d, but we only have %u card(s).\n", signal_num, num_cards); + fprintf(stderr, "Mapping to card %d instead.\n", signal_num % num_cards); + signal_num %= num_cards; + } input->set_texture_num(0, input_textures[signal_num].tex_y); input->set_texture_num(1, input_textures[signal_num].tex_cbcr); } diff --git a/theme.h b/theme.h index 4915263..b17dbbd 100644 --- a/theme.h +++ b/theme.h @@ -12,6 +12,8 @@ #include #include +#define MAX_CARDS 16 + class NonBouncingYCbCrInput : public movit::YCbCrInput { public: NonBouncingYCbCrInput(const movit::ImageFormat &image_format, @@ -25,7 +27,7 @@ public: class Theme { public: - Theme(const char *filename, movit::ResourcePool *resource_pool); + Theme(const char *filename, movit::ResourcePool *resource_pool, unsigned num_cards); std::pair> get_chain(unsigned num, float t, unsigned width, unsigned height); @@ -50,8 +52,9 @@ private: movit::ResourcePool *resource_pool; struct { GLuint tex_y = 0, tex_cbcr = 0; - } input_textures[16]; // FIXME + } input_textures[MAX_CARDS]; int num_channels; + unsigned num_cards; }; class LiveInputWrapper { -- 2.39.2