\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
\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
\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
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
{\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
\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
\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