fighting the crash everywhere: random crash at random location. Changing

computer might be better idea than changing the code indefinitely...
This commit is contained in:
brunoherbelin
2020-08-15 18:05:18 +02:00
parent 44b9169cdc
commit 0e2af5b04f
10 changed files with 80 additions and 34 deletions

View File

@@ -96,7 +96,7 @@ set(PNG_LIBRARY PNG::PNG)
# NB: set glfw3_PATH to /usr/local/Cellar/glfw/3.3.2/lib/cmake/glfw3
#
find_package(glfw3 3.2 REQUIRED)
macro_log_feature(glfw3_FOUND "GLFW3" "Open Source, multi-platform library for OpenGL" "http://www.glfw.org/" TRUE)
macro_log_feature(glfw3_FOUND "GLFW3" "Open Source multi-platform library for OpenGL" "http://www.glfw.org/" TRUE)
set(GLFW_LIBRARY glfw)
#find_package(OpenGL REQUIRED)
@@ -108,14 +108,14 @@ set(BUILD_STATIC_LIBS ON)
# GLM
#
add_subdirectory(${CMAKE_CURRENT_SOURCE_DIR}/ext/glm)
message(STATUS "Compiling 'GLM' OpenGL Mathematics https://glm.g-truc.net.")
message(STATUS "Compiling 'GLM' OpenGL mathematics https://glm.g-truc.net.")
#
# GLAD
#
set(GLAD_INCLUDE_DIR ${CMAKE_CURRENT_SOURCE_DIR}/ext/glad/include)
add_library(GLAD "${CMAKE_CURRENT_SOURCE_DIR}/ext/glad/src/glad.c")
message(STATUS "Compiling 'GLAD' generated at https://glad.dav1d.de/ -- ${GLAD_INCLUDE_DIR}.")
message(STATUS "Compiling 'GLAD' Open source multi-language OpenGL loader https://glad.dav1d.de/ -- ${GLAD_INCLUDE_DIR}.")
#
# DEAR IMGUI
@@ -357,8 +357,8 @@ message(STATUS "Using 'CMakeRC ' from https://github.com/vector-of-bool/cmrc.git
target_link_libraries(${VMIX_BINARY} LINK_PRIVATE
${GLFW_LIBRARY}
# ${OPENGL_LIBRARY}
GLAD
glm::glm
${CMAKE_DL_LIBS}
${GOBJECT_LIBRARIES}
${GSTREAMER_LIBRARY}
@@ -375,7 +375,6 @@ target_link_libraries(${VMIX_BINARY} LINK_PRIVATE
TINYXML2
TINYFD
IMGUI
glm::glm
vmix::rc
)

View File

@@ -21,13 +21,17 @@ glm::vec3 FrameBuffer::getResolutionFromParameters(int ar, int h)
return res;
}
FrameBuffer::FrameBuffer(glm::vec3 resolution, bool useAlpha, bool multiSampling): textureid_(0), intermediate_textureid_(0), framebufferid_(0), intermediate_framebufferid_(0), use_alpha_(useAlpha), use_multi_sampling_(multiSampling)
FrameBuffer::FrameBuffer(glm::vec3 resolution, bool useAlpha, bool multiSampling):
textureid_(0), intermediate_textureid_(0), framebufferid_(0), intermediate_framebufferid_(0),
use_alpha_(useAlpha), use_multi_sampling_(multiSampling)
{
attrib_.viewport = glm::ivec2(resolution);
attrib_.clear_color = glm::vec4(0.f, 0.f, 0.f, use_alpha_ ? 0.f : 1.f);
}
FrameBuffer::FrameBuffer(uint width, uint height, bool useAlpha, bool multiSampling): textureid_(0), intermediate_textureid_(0), framebufferid_(0), intermediate_framebufferid_(0), use_alpha_(useAlpha), use_multi_sampling_(multiSampling)
FrameBuffer::FrameBuffer(uint width, uint height, bool useAlpha, bool multiSampling):
textureid_(0), intermediate_textureid_(0), framebufferid_(0), intermediate_framebufferid_(0),
use_alpha_(useAlpha), use_multi_sampling_(multiSampling)
{
attrib_.viewport = glm::ivec2(width, height);
attrib_.clear_color = glm::vec4(0.f, 0.f, 0.f, use_alpha_ ? 0.f : 1.f);
@@ -63,14 +67,14 @@ void FrameBuffer::init()
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
glBindTexture(GL_TEXTURE_2D_MULTISAMPLE, 0);
// attach the multisampled texture to FBO (currently binded)
// attach the multisampled texture to FBO (framebufferid_ currently binded)
glFramebufferTexture2D(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_TEXTURE_2D_MULTISAMPLE, intermediate_textureid_, 0);
// create an intermediate FBO
// create an intermediate FBO : this is the FBO to use for reading
glGenFramebuffers(1, &intermediate_framebufferid_);
glBindFramebuffer(GL_FRAMEBUFFER, intermediate_framebufferid_);
// attach the 2D texture to intermediate FBO
// attach the 2D texture to intermediate FBO (intermediate_framebufferid_)
glFramebufferTexture2D(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_TEXTURE_2D, textureid_, 0);
// Log::Info("New FBO %d Multi Sampling ", framebufferid_);

View File

@@ -77,6 +77,8 @@ static MediaInfo UriDiscoverer_(std::string uri)
#endif
MediaInfo video_stream_info;
// assume it will fail
video_stream_info.failed = true;
/* Instantiate the Discoverer */
GError *err = NULL;
@@ -123,6 +125,8 @@ static MediaInfo UriDiscoverer_(std::string uri)
GstDiscovererStreamInfo *tmpinf = (GstDiscovererStreamInfo *) tmp->data;
if ( GST_IS_DISCOVERER_VIDEO_INFO(tmpinf) )
{
// inform that it succeeded
video_stream_info.failed = false;
// found a video / image stream : fill-in information
GstDiscovererVideoInfo* vinfo = GST_DISCOVERER_VIDEO_INFO(tmpinf);
video_stream_info.width = gst_discoverer_video_info_get_width(vinfo);
@@ -167,8 +171,6 @@ static MediaInfo UriDiscoverer_(std::string uri)
gst_discoverer_stream_info_list_free(streams);
if (!foundvideostream) {
// inform that it failed
video_stream_info.failed = true;
Log::Warning("Warning: No video stream in '%s'", uri.c_str());
}
}

View File

@@ -26,7 +26,7 @@ using namespace tinyxml2;
#include "Mixer.h"
#define THREADED_LOADING
//#define THREADED_LOADING
// static semaphore to prevent multiple threads for load / save
static std::atomic<bool> sessionThreadActive_ = false;
@@ -40,6 +40,7 @@ static Session *loadSession_(const std::string& filename)
{
Session *s = new Session;
if (s) {
// actual loading of xml file
SessionCreator creator( s );
@@ -52,6 +53,7 @@ static Session *loadSession_(const std::string& filename)
delete s;
s = nullptr;
}
}
return s;
}
@@ -148,6 +150,14 @@ Mixer::Mixer() : session_(nullptr), back_session_(nullptr), current_view_(nullpt
void Mixer::update()
{
if (garbage_.size()>0) {
delete garbage_.back();
garbage_.pop_back();
}
#ifdef THREADED_LOADING
// if there is a session importer pending
if (!sessionImporters_.empty()) {
// check status of loader: did it finish ?
@@ -169,6 +179,7 @@ void Mixer::update()
sessionLoaders_.pop_back();
}
}
#endif
// if a change of session is requested
if (sessionSwapRequested_) {
@@ -588,10 +599,32 @@ void Mixer::saveas(const std::string& filename)
void Mixer::load(const std::string& filename)
{
#ifdef THREADED_LOADING
// load only one at a time
if (sessionLoaders_.empty()) {
// Start async thread for loading the session
// Will be obtained in the future in update()
sessionLoaders_.emplace_back( std::async(std::launch::async, loadSession_, filename) );
// Session *se = new Session;
// sessionLoaders_.emplace_back(std::async(std::launch::async,
// [](Session *s, const std::string& filename){
// // actual loading of xml file
// SessionCreator creator( s );
// if (creator.load(filename)) {
// // loaded ok
// s->setFilename(filename);
// }
// return s;
// }, se, filename));
}
#else
set( loadSession_(filename) );
#endif
}
void Mixer::open(const std::string& filename)
@@ -622,9 +655,10 @@ void Mixer::import(const std::string& filename)
{
// import only one at a time
if (sessionImporters_.empty()) {
// Start async thread for loading the session
// Will be obtained in the future in update()
sessionImporters_.emplace_back( std::async(std::launch::async, loadSession_, filename) );
}
}
void Mixer::merge(Session *session)
@@ -695,8 +729,9 @@ void Mixer::swap()
// reset timer
update_time_ = GST_CLOCK_TIME_NONE;
// delete back
delete back_session_;
// delete back (former front session)
// delete back_session_;
garbage_.push_back(back_session_);
back_session_ = nullptr;
// notification
@@ -724,7 +759,8 @@ void Mixer::clear()
{
// delete previous back session if needed
if (back_session_)
delete back_session_;
garbage_.push_back(back_session_);
// delete back_session_;
// create empty session
back_session_ = new Session;
@@ -744,7 +780,8 @@ void Mixer::set(Session *s)
// delete previous back session if needed
if (back_session_)
delete back_session_;
garbage_.push_back(back_session_);
// delete back_session_;
// set to new given session
back_session_ = s;

View File

@@ -82,6 +82,7 @@ protected:
Session *session_;
Session *back_session_;
std::list<Session *> garbage_;
bool sessionSwapRequested_;
void swap();

View File

@@ -438,6 +438,7 @@ Scene::Scene()
Scene::~Scene()
{
clear();
// bg and fg are deleted as children of root
delete root_;
}

View File

@@ -9,10 +9,12 @@
#include "Log.h"
Session::Session() : filename_(""), failedSource_(nullptr), active_(true), fading_target_(0.f)
Session::Session() : failedSource_(nullptr), active_(true), fading_target_(0.f)
{
filename_ = "";
config_[View::RENDERING] = new Group;
config_[View::RENDERING]->scale_ = render_.resolution();
config_[View::RENDERING]->scale_ = FrameBuffer::getResolutionFromParameters(Settings::application.render.ratio, Settings::application.render.res);
config_[View::GEOMETRY] = new Group;
config_[View::GEOMETRY]->scale_ = Settings::application.views[View::GEOMETRY].default_scale;

View File

@@ -193,7 +193,7 @@ void SessionCreator::visit(MediaPlayer &n)
GstClockTime b = GST_CLOCK_TIME_NONE;
gap->QueryUnsigned64Attribute("begin", &a);
gap->QueryUnsigned64Attribute("end", &b);
n.timeline().addGap( a, b ); // TODO ref access to timeline of source
n.timeline().addGap( a, b );
}
}
// playing properties

View File

@@ -541,7 +541,7 @@ uint MixingView::textureMixingQuadratic()
RenderView::RenderView() : View(RENDERING), frame_buffer_(nullptr), fading_overlay_(nullptr)
{
// set resolution to settings or default
// set resolution to settings default
setResolution();
}
@@ -571,7 +571,8 @@ float RenderView::fading() const
void RenderView::setResolution(glm::vec3 resolution)
{
if (resolution.x < 128.f || resolution.y < 128.f)
// use default resolution if invalid resolution is given (default behavior)
if (resolution.x < 2.f || resolution.y < 2.f)
resolution = FrameBuffer::getResolutionFromParameters(Settings::application.render.ratio, Settings::application.render.res);
// do we need to change resolution ?

1
View.h
View File

@@ -113,7 +113,6 @@ private:
class RenderView : public View
{
FrameBuffer *intermediate_buffer_;
FrameBuffer *frame_buffer_;
Surface *fading_overlay_;