]> git.sesse.net Git - casparcg/blobdiff - core/video_channel.cpp
2.0. stage: Changed error handling.
[casparcg] / core / video_channel.cpp
index 267a821dbd50723cbc53edddbb2e18bdb2a5c2ae..476a73eb32190af8e0f2ba8954ebe2eb1a49829e 100644 (file)
@@ -59,7 +59,7 @@ public:
        implementation(int index, const video_format_desc& format_desc, ogl_device& ogl)  \r
                : context_(index, ogl, format_desc)\r
                , diag_(diagnostics::create_graph(narrow(print())))\r
-               , output_(new caspar::core::output(context_))\r
+               , output_(new caspar::core::output(context_, [this]{restart();}))\r
                , mixer_(new caspar::core::mixer(context_))\r
                , stage_(new caspar::core::stage(context_))     \r
        {\r
@@ -118,16 +118,20 @@ public:
                {\r
                        CASPAR_LOG_CURRENT_EXCEPTION();\r
                        CASPAR_LOG(error) << context_.print() << L" Unexpected exception. Clearing stage and freeing memory";\r
-\r
-                       stage_->clear();\r
-                       context_.ogl().gc().wait();\r
-\r
-                       mixer_ = nullptr;\r
-                       mixer_.reset(new caspar::core::mixer(context_));\r
+                       restart();\r
                }\r
 \r
                context_.execution().begin_invoke([this]{tick();});\r
        }\r
+\r
+       void restart()\r
+       {\r
+               stage_->clear();\r
+               context_.ogl().gc().wait();\r
+\r
+               mixer_ = nullptr;\r
+               mixer_.reset(new caspar::core::mixer(context_));\r
+       }\r
                \r
        std::wstring print() const\r
        {\r