]> git.sesse.net Git - casparcg/blobdiff - shell/server.cpp
2.1.0: -casparcg.config: Updated.
[casparcg] / shell / server.cpp
index 6bddb2528807f096e075933131323e6f99192ae1..9fbf722ea4778fba975f2a79894ec5cf87804dac 100644 (file)
@@ -22,8 +22,7 @@
 \r
 #include "server.h"\r
 \r
-#include <accelerator/ogl/util/context.h>\r
-#include <accelerator/ogl/image/image_mixer.h>\r
+#include <accelerator/accelerator.h>\r
 \r
 #include <common/env.h>\r
 #include <common/except.h>\r
@@ -66,12 +65,15 @@ using namespace protocol;
 \r
 struct server::impl : boost::noncopyable\r
 {\r
-       spl::shared_ptr<accelerator::ogl::context>                      ogl_;\r
+       monitor::basic_subject                                                          event_subject_;\r
+       accelerator::accelerator                                                        accelerator_;\r
        std::vector<spl::shared_ptr<IO::AsyncEventServer>>      async_servers_; \r
        std::vector<spl::shared_ptr<video_channel>>                     channels_;\r
 \r
        impl()          \r
-       {                       \r
+               : accelerator_(env::properties().get(L"configuration.accelerator", L"auto"))\r
+       {       \r
+\r
                ffmpeg::init();\r
                CASPAR_LOG(info) << L"Initialized ffmpeg module.";\r
                                                          \r
@@ -102,11 +104,13 @@ struct server::impl : boost::noncopyable
 \r
        ~impl()\r
        {               \r
-               image::uninit();\r
-               ffmpeg::uninit();\r
-\r
                async_servers_.clear();\r
                channels_.clear();\r
+\r
+               Sleep(500); // HACK: Wait for asynchronous destruction of producers and consumers.\r
+\r
+               image::uninit();\r
+               ffmpeg::uninit();\r
        }\r
                                \r
        void setup_channels(const boost::property_tree::wptree& pt)\r
@@ -118,7 +122,7 @@ struct server::impl : boost::noncopyable
                        if(format_desc.format == video_format::invalid)\r
                                BOOST_THROW_EXCEPTION(caspar_exception() << msg_info("Invalid video-mode."));\r
                        \r
-                       channels_.push_back(spl::make_shared<video_channel>(static_cast<int>(channels_.size()+1), format_desc, spl::make_shared<accelerator::ogl::image_mixer>(ogl_)));\r
+                       auto channel = spl::make_shared<video_channel>(static_cast<int>(channels_.size()+1), format_desc, accelerator_.create_image_mixer());\r
                        \r
                        BOOST_FOREACH(auto& xml_consumer, xml_channel.second.get_child(L"consumers"))\r
                        {\r
@@ -126,15 +130,15 @@ struct server::impl : boost::noncopyable
                                {\r
                                        auto name = xml_consumer.first;\r
                                        if(name == L"screen")\r
-                                               channels_.back()->output()->add(caspar::screen::create_consumer(xml_consumer.second));                                  \r
+                                               channel->output().add(caspar::screen::create_consumer(xml_consumer.second));                                    \r
                                        else if(name == L"bluefish")                                    \r
-                                               channels_.back()->output()->add(bluefish::create_consumer(xml_consumer.second));                                        \r
+                                               channel->output().add(bluefish::create_consumer(xml_consumer.second));                                  \r
                                        else if(name == L"decklink")                                    \r
-                                               channels_.back()->output()->add(decklink::create_consumer(xml_consumer.second));                                \r
+                                               channel->output().add(decklink::create_consumer(xml_consumer.second));                          \r
                                        else if(name == L"file")                                        \r
-                                               channels_.back()->output()->add(ffmpeg::create_consumer(xml_consumer.second));                                          \r
+                                               channel->output().add(ffmpeg::create_consumer(xml_consumer.second));                                            \r
                                        else if(name == L"system-audio")\r
-                                               channels_.back()->output()->add(oal::create_consumer());                \r
+                                               channel->output().add(oal::create_consumer());          \r
                                        else if(name != L"<xmlcomment>")\r
                                                CASPAR_LOG(warning) << "Invalid consumer: " << name;    \r
                                }\r
@@ -142,12 +146,15 @@ struct server::impl : boost::noncopyable
                                {\r
                                        CASPAR_LOG_CURRENT_EXCEPTION();\r
                                }\r
-                       }                                                       \r
+                       }               \r
+\r
+                   channel->subscribe(monitor::observable::observer_ptr(event_subject_));\r
+                       channels_.push_back(channel);\r
                }\r
 \r
                // Dummy diagnostics channel\r
                if(env::properties().get(L"configuration.channel-grid", false))\r
-                       channels_.push_back(spl::make_shared<video_channel>(static_cast<int>(channels_.size()+1), core::video_format_desc(core::video_format::x576p2500), spl::make_shared<accelerator::ogl::image_mixer>(ogl_)));\r
+                       channels_.push_back(spl::make_shared<video_channel>(static_cast<int>(channels_.size()+1), core::video_format_desc(core::video_format::x576p2500), accelerator_.create_image_mixer()));\r
        }\r
                \r
        void setup_controllers(const boost::property_tree::wptree& pt)\r
@@ -192,9 +199,11 @@ struct server::impl : boost::noncopyable
 \r
 server::server() : impl_(new impl()){}\r
 \r
-const std::vector<spl::shared_ptr<video_channel>> server::get_channels() const\r
+const std::vector<spl::shared_ptr<video_channel>> server::channels() const\r
 {\r
        return impl_->channels_;\r
 }\r
+void server::subscribe(const monitor::observable::observer_ptr& o){impl_->event_subject_.subscribe(o);}\r
+void server::unsubscribe(const monitor::observable::observer_ptr& o){impl_->event_subject_.unsubscribe(o);}\r
 \r
 }
\ No newline at end of file