diff --git a/ImGuiVisitor.cpp b/ImGuiVisitor.cpp index 4858afe..ce70ff8 100644 --- a/ImGuiVisitor.cpp +++ b/ImGuiVisitor.cpp @@ -489,7 +489,7 @@ void ImGuiVisitor::visit (PatternSource& s) ImGui::SetNextItemWidth(IMGUI_RIGHT_ALIGN); if (ImGui::BeginCombo("##Patterns", Pattern::pattern_types[s.pattern()->type()].c_str()) ) { - for (int p = 0; p < Pattern::pattern_types.size(); ++p){ + for (uint p = 0; p < Pattern::pattern_types.size(); ++p){ if (ImGui::Selectable( Pattern::pattern_types[p].c_str() )) { s.setPattern(p, s.pattern()->resolution()); std::ostringstream oss; diff --git a/Mixer.cpp b/Mixer.cpp index f1f37c2..74dc3a6 100644 --- a/Mixer.cpp +++ b/Mixer.cpp @@ -278,7 +278,7 @@ Source * Mixer::createSourceStream(const std::string &gstreamerpipeline) return s; } -Source * Mixer::createSourcePattern(int pattern, glm::ivec2 res) +Source * Mixer::createSourcePattern(uint pattern, glm::ivec2 res) { // ready to create a source PatternSource *s = new PatternSource; diff --git a/Mixer.h b/Mixer.h index da08b06..7528b40 100644 --- a/Mixer.h +++ b/Mixer.h @@ -40,7 +40,7 @@ public: Source * createSourceClone (const std::string &namesource = ""); Source * createSourceRender (); Source * createSourceStream (const std::string &gstreamerpipeline); - Source * createSourcePattern(int pattern, glm::ivec2 res); + Source * createSourcePattern(uint pattern, glm::ivec2 res); Source * createSourceDevice (const std::string &namedevice); // operations on sources diff --git a/PatternSource.cpp b/PatternSource.cpp index 66f5c76..2c0641d 100644 --- a/PatternSource.cpp +++ b/PatternSource.cpp @@ -11,6 +11,8 @@ #include "Visitor.h" #include "Log.h" +#define MAX_PATTERN 23 + // smpte (0) – SMPTE 100%% color bars // snow (1) – Random (television snow) // black (2) – 100%% Black @@ -88,7 +90,7 @@ std::vector Pattern::pattern_types = { "Black", "Clock" }; -Pattern::Pattern() : Stream() +Pattern::Pattern() : Stream(), type_(MAX_PATTERN+1) // invalid pattern { } @@ -101,13 +103,13 @@ glm::ivec2 Pattern::resolution() void Pattern::open( uint pattern, glm::ivec2 res ) { - type_ = CLAMP(pattern, 0, 23); + type_ = MIN(pattern, MAX_PATTERN); std::string gstreamer_pattern = pattern_internal_[type_]; // there is always a special case... switch(type_) { - case 18: + case 18: // zone plates case 17: { std::ostringstream oss; @@ -119,7 +121,7 @@ void Pattern::open( uint pattern, glm::ivec2 res ) break; } - // all patterns before index are single frames (not animated) + // all patterns before 'SMPTE test pattern' are single frames (not animated) single_frame_ = type_ < 14; // (private) open stream @@ -136,7 +138,7 @@ PatternSource::PatternSource() : StreamSource() overlays_[View::LAYER]->attach( new Symbol(Symbol::PATTERN, glm::vec3(0.8f, 0.8f, 0.01f)) ); } -void PatternSource::setPattern(int type, glm::ivec2 resolution) +void PatternSource::setPattern(uint type, glm::ivec2 resolution) { Log::Notify("Creating Source with pattern '%s'", Pattern::pattern_types[type].c_str()); diff --git a/PatternSource.h b/PatternSource.h index da0b4fd..0a58cb0 100644 --- a/PatternSource.h +++ b/PatternSource.h @@ -33,7 +33,7 @@ public: // specific interface Pattern *pattern() const; - void setPattern(int type, glm::ivec2 resolution); + void setPattern(uint type, glm::ivec2 resolution); glm::ivec2 icon() const override { return glm::ivec2(12, 5); }