BugFix: PatternSource pattern type is unsigned and undefined when

created
This commit is contained in:
brunoherbelin
2020-10-11 16:01:57 +02:00
parent 8297c85220
commit 34b508a8dd
5 changed files with 11 additions and 9 deletions

View File

@@ -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;

View File

@@ -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;

View File

@@ -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

View File

@@ -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<std::string> 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());

View File

@@ -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); }