]> git.sesse.net Git - casparcg/blobdiff - shell/server.cpp
2.1.0: -casparcg.config: Updated.
[casparcg] / shell / server.cpp
index b66295dd287a88a7a81f6da0e31a93c8969d00c7..9fbf722ea4778fba975f2a79894ec5cf87804dac 100644 (file)
@@ -22,9 +22,7 @@
 \r
 #include "server.h"\r
 \r
-#include <accelerator/factory.h>\r
-#include <accelerator/ogl/factory.h>\r
-#include <accelerator/cpu/factory.h>\r
+#include <accelerator/accelerator.h>\r
 \r
 #include <common/env.h>\r
 #include <common/except.h>\r
@@ -67,30 +65,14 @@ using namespace protocol;
 \r
 struct server::impl : boost::noncopyable\r
 {\r
-       spl::shared_ptr<monitor::subject>                                       event_subject_;\r
-       std::unique_ptr<accelerator::factory>                           accel_factory_;\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
+               : accelerator_(env::properties().get(L"configuration.accelerator", L"auto"))\r
        {       \r
-               auto accel_str = env::properties().get(L"configuration.accelerator", L"auto");\r
-\r
-               if(accel_str == L"cpu")\r
-                       accel_factory_.reset(new accelerator::cpu::factory());\r
-               else\r
-               {\r
-                       try\r
-                       {\r
-                               accel_factory_.reset(new accelerator::ogl::factory());\r
-                       }\r
-                       catch(...)\r
-                       {\r
-                               CASPAR_LOG_CURRENT_EXCEPTION();\r
-                               accel_factory_.reset(new accelerator::cpu::factory());\r
-                               CASPAR_LOG(warning) << L"Using fallback CPU mixer.";\r
-                       }\r
-               }\r
 \r
                ffmpeg::init();\r
                CASPAR_LOG(info) << L"Initialized ffmpeg module.";\r
@@ -122,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
@@ -138,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
-                       auto channel = spl::make_shared<video_channel>(static_cast<int>(channels_.size()+1), format_desc, accel_factory_->create_image_mixer());\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
@@ -146,15 +130,15 @@ struct server::impl : boost::noncopyable
                                {\r
                                        auto name = xml_consumer.first;\r
                                        if(name == L"screen")\r
-                                               channel->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
-                                               channel->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
-                                               channel->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
-                                               channel->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
-                                               channel->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
@@ -170,7 +154,7 @@ struct server::impl : boost::noncopyable
 \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), accel_factory_->create_image_mixer()));\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
@@ -215,11 +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
+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