]> git.sesse.net Git - nageru/commitdiff
Add some primitive emergency card mapping. Useful for testing.
authorSteinar H. Gunderson <sgunderson@bigfoot.com>
Sun, 1 Nov 2015 19:35:36 +0000 (20:35 +0100)
committerSteinar H. Gunderson <sgunderson@bigfoot.com>
Sun, 1 Nov 2015 19:35:36 +0000 (20:35 +0100)
mixer.cpp
mixer.h
theme.cpp
theme.h

index 9158b3478a3f6db6a194f7086301ae686a57a799..cf2ed8311a001080641fabb2afc2ae077e7409cb 100644 (file)
--- 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 9f32f2ac2d79f5c6d86156bb38f0af5ea6d17564..82a3ccab8a899e9637a17a5b122b48c6c1fb6286 100644 (file)
--- 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;
 }
index 9914952948477e1a6223f23e298057b9ba34a691..2a84093cd6f37e915a5489e56ee6424d156ce70d 100644 (file)
--- 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<std::string> 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 49152637975c8d2df8a90325c8f2dbd247a5eebb..b17dbbd00de85764d866a02f22db8562636855b3 100644 (file)
--- a/theme.h
+++ b/theme.h
@@ -12,6 +12,8 @@
 #include <movit/effect_chain.h>
 #include <movit/ycbcr_input.h>
 
+#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<movit::EffectChain *, std::function<void()>>
        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 {