X-Git-Url: https://git.sesse.net/?a=blobdiff_plain;f=core%2Fvideo_channel.cpp;h=476a73eb32190af8e0f2ba8954ebe2eb1a49829e;hb=e59ee903385d31db9a4fc928f32d3be5322b3389;hp=873a9569f4ed0f870d8bacb2cb06015c0ee1c638;hpb=5593d08ae1d328bb14fe1e02a543675ed97f1974;p=casparcg diff --git a/core/video_channel.cpp b/core/video_channel.cpp index 873a9569f..476a73eb3 100644 --- a/core/video_channel.cpp +++ b/core/video_channel.cpp @@ -32,6 +32,8 @@ #include #include +#include "mixer/gpu/ogl_device.h" + #include #ifdef _MSC_VER @@ -44,9 +46,9 @@ struct video_channel::implementation : boost::noncopyable { video_channel_context context_; - safe_ptr output_; - safe_ptr mixer_; - safe_ptr stage_; + safe_ptr output_; + std::shared_ptr mixer_; + safe_ptr stage_; safe_ptr diag_; boost::timer frame_timer_; @@ -57,15 +59,15 @@ public: implementation(int index, const video_format_desc& format_desc, ogl_device& ogl) : context_(index, ogl, format_desc) , diag_(diagnostics::create_graph(narrow(print()))) - , output_(new caspar::core::output(context_)) + , output_(new caspar::core::output(context_, [this]{restart();})) , mixer_(new caspar::core::mixer(context_)) , stage_(new caspar::core::stage(context_)) { diag_->add_guide("produce-time", 0.5f); - diag_->set_color("produce-time", diagnostics::color(1.0f, 0.0f, 0.0f)); - diag_->set_color("mix-time", diagnostics::color(1.0f, 0.0f, 1.0f)); - diag_->set_color("output-time", diagnostics::color(1.0f, 1.0f, 0.0f)); - diag_->set_color("tick-time", diagnostics::color(0.1f, 0.7f, 0.8f)); + diag_->set_color("produce-time", diagnostics::color(0.0f, 1.0f, 0.0f)); + diag_->set_color("tick-time", diagnostics::color(0.0f, 0.6f, 0.9f)); + diag_->set_color("output-time", diagnostics::color(1.0f, 0.5f, 0.0f)); + diag_->set_color("mix-time", diagnostics::color(1.0f, 1.0f, 0.9f)); CASPAR_LOG(info) << print() << " Successfully Initialized."; context_.execution().begin_invoke([this]{tick();}); @@ -115,12 +117,21 @@ public: catch(...) { CASPAR_LOG_CURRENT_EXCEPTION(); - stage_->clear(); - context_.ogl().gc().wait(); + CASPAR_LOG(error) << context_.print() << L" Unexpected exception. Clearing stage and freeing memory"; + restart(); } context_.execution().begin_invoke([this]{tick();}); } + + void restart() + { + stage_->clear(); + context_.ogl().gc().wait(); + + mixer_ = nullptr; + mixer_.reset(new caspar::core::mixer(context_)); + } std::wstring print() const { @@ -132,6 +143,7 @@ public: context_.execution().begin_invoke([=] { stage_->clear(); + context_.ogl().gc().wait(); context_.set_format_desc(format_desc); }); } @@ -140,10 +152,11 @@ public: video_channel::video_channel(int index, const video_format_desc& format_desc, ogl_device& ogl) : impl_(new implementation(index, format_desc, ogl)){} video_channel::video_channel(video_channel&& other) : impl_(std::move(other.impl_)){} safe_ptr video_channel::stage() { return impl_->stage_;} -safe_ptr video_channel::mixer() { return impl_->mixer_;} +safe_ptr video_channel::mixer() { return make_safe(impl_->mixer_);} safe_ptr video_channel::output() { return impl_->output_;} video_format_desc video_channel::get_video_format_desc() const{return impl_->context_.get_format_desc();} void video_channel::set_video_format_desc(const video_format_desc& format_desc){impl_->set_video_format_desc(format_desc);} std::wstring video_channel::print() const { return impl_->print();} +video_channel_context& video_channel::context(){return impl_->context_;} }} \ No newline at end of file