X-Git-Url: https://git.sesse.net/?a=blobdiff_plain;f=core%2Fvideo_channel.cpp;h=10b4d5864b6d39810dd30e66e07f8e41b0353865;hb=refs%2Ftags%2F2.0.0.2;hp=45d3b9158ac364ccea7ce41f347fdac65d73545c;hpb=66b170e5505a74cd54088312ced4b4549e67ba87;p=casparcg diff --git a/core/video_channel.cpp b/core/video_channel.cpp index 45d3b9158..10b4d5864 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_; @@ -56,16 +58,17 @@ struct video_channel::implementation : boost::noncopyable 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)); + diag_->set_text(print()); + diagnostics::register_graph(diag_); CASPAR_LOG(info) << print() << " Successfully Initialized."; context_.execution().begin_invoke([this]{tick();}); @@ -116,12 +119,20 @@ public: { CASPAR_LOG_CURRENT_EXCEPTION(); CASPAR_LOG(error) << context_.print() << L" Unexpected exception. Clearing stage and freeing memory"; - stage_->clear(); - context_.ogl().gc().wait(); + 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 { @@ -133,6 +144,7 @@ public: context_.execution().begin_invoke([=] { stage_->clear(); + context_.ogl().gc().wait(); context_.set_format_desc(format_desc); }); } @@ -141,10 +153,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_ptr(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