<ClInclude Include="mixer\image\image_mixer.h" />\r
<ClInclude Include="mixer\read_frame.h" />\r
<ClInclude Include="mixer\write_frame.h" />\r
+ <ClInclude Include="producer\destroy_producer_proxy.h" />\r
<ClInclude Include="producer\color\color_producer.h" />\r
<ClInclude Include="producer\frame\audio_transform.h" />\r
<ClInclude Include="producer\frame\basic_frame.h" />\r
<PrecompiledHeaderFile Condition="'$(Configuration)|$(Platform)'=='Develop|Win32'">../StdAfx.h</PrecompiledHeaderFile>\r
<PrecompiledHeaderFile Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">../StdAfx.h</PrecompiledHeaderFile>\r
</ClCompile>\r
+ <ClCompile Include="producer\destroy_producer_proxy.cpp">\r
+ <PrecompiledHeaderFile Condition="'$(Configuration)|$(Platform)'=='Profile|Win32'">../StdAfx.h</PrecompiledHeaderFile>\r
+ <PrecompiledHeaderFile Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">../StdAfx.h</PrecompiledHeaderFile>\r
+ <PrecompiledHeaderFile Condition="'$(Configuration)|$(Platform)'=='Develop|Win32'">../StdAfx.h</PrecompiledHeaderFile>\r
+ <PrecompiledHeaderFile Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">../StdAfx.h</PrecompiledHeaderFile>\r
+ </ClCompile>\r
<ClCompile Include="producer\color\color_producer.cpp">\r
<PrecompiledHeaderFile Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">../../StdAfx.h</PrecompiledHeaderFile>\r
<PrecompiledHeaderFile Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">../../StdAfx.h</PrecompiledHeaderFile>\r
<ClInclude Include="mixer\frame_mixer_device.h">\r
<Filter>mixer</Filter>\r
</ClInclude>\r
+ <ClInclude Include="producer\destroy_producer_proxy.h">\r
+ <Filter>producer</Filter>\r
+ </ClInclude>\r
</ItemGroup>\r
<ItemGroup>\r
<ClCompile Include="producer\transition\transition_producer.cpp">\r
<ClCompile Include="mixer\write_frame.cpp">\r
<Filter>mixer</Filter>\r
</ClCompile>\r
+ <ClCompile Include="producer\destroy_producer_proxy.cpp">\r
+ <Filter>producer</Filter>\r
+ </ClCompile>\r
</ItemGroup>\r
</Project>
\ No newline at end of file
--- /dev/null
+/*\r
+* copyright (c) 2010 Sveriges Television AB <info@casparcg.com>\r
+*\r
+* This file is part of CasparCG.\r
+*\r
+* CasparCG is free software: you can redistribute it and/or modify\r
+* it under the terms of the GNU General Public License as published by\r
+* the Free Software Foundation, either version 3 of the License, or\r
+* (at your option) any later version.\r
+*\r
+* CasparCG is distributed in the hope that it will be useful,\r
+* but WITHOUT ANY WARRANTY; without even the implied warranty of\r
+* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\r
+* GNU General Public License for more details.\r
+\r
+* You should have received a copy of the GNU General Public License\r
+* along with CasparCG. If not, see <http://www.gnu.org/licenses/>.\r
+*\r
+*/\r
+#include "../StdAfx.h"\r
+\r
+#include "destroy_producer_proxy.h"\r
+\r
+#include <common/concurrency/executor.h>\r
+#include <common/utility/assert.h>\r
+\r
+namespace caspar { namespace core {\r
+ \r
+struct destroyer\r
+{\r
+ executor executor_;\r
+\r
+ destroyer() : executor_(L"destroyer", true){}\r
+ \r
+ void destroy(safe_ptr<frame_producer>&& producer)\r
+ {\r
+ executor_.begin_invoke(std::bind(&destroyer::do_destroy, this, std::move(producer)));\r
+ }\r
+\r
+ void do_destroy(safe_ptr<frame_producer>& producer)\r
+ {\r
+ if(!producer.unique())\r
+ CASPAR_LOG(warning) << producer->print() << L" Not destroyed on safe asynchronous destruction thread.";\r
+ \r
+ if(executor_.size() > 4)\r
+ CASPAR_LOG(error) << L" Potential destroyer deadlock.";\r
+\r
+ producer = frame_producer::empty();\r
+ }\r
+\r
+} g_destroyer;\r
+\r
+destroy_producer_proxy::destroy_producer_proxy(const safe_ptr<frame_producer>& producer) : producer_(producer){}\r
+destroy_producer_proxy::~destroy_producer_proxy()\r
+{\r
+ g_destroyer.destroy(std::move(producer_));\r
+}\r
+\r
+safe_ptr<basic_frame> destroy_producer_proxy::receive(){return producer_->receive();} \r
+std::wstring destroy_producer_proxy::print() const {return producer_->print();} \r
+\r
+void destroy_producer_proxy::param(const std::wstring& param){producer_->param(param);} \r
+\r
+safe_ptr<frame_producer> destroy_producer_proxy::get_following_producer() const {return producer_->get_following_producer();} \r
+void destroy_producer_proxy::set_leading_producer(const safe_ptr<frame_producer>& producer) {producer_->set_leading_producer(producer);} \r
+ \r
+}}\r
--- /dev/null
+/*\r
+* copyright (c) 2010 Sveriges Television AB <info@casparcg.com>\r
+*\r
+* This file is part of CasparCG.\r
+*\r
+* CasparCG is free software: you can redistribute it and/or modify\r
+* it under the terms of the GNU General Public License as published by\r
+* the Free Software Foundation, either version 3 of the License, or\r
+* (at your option) any later version.\r
+*\r
+* CasparCG is distributed in the hope that it will be useful,\r
+* but WITHOUT ANY WARRANTY; without even the implied warranty of\r
+* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\r
+* GNU General Public License for more details.\r
+\r
+* You should have received a copy of the GNU General Public License\r
+* along with CasparCG. If not, see <http://www.gnu.org/licenses/>.\r
+*\r
+*/\r
+#pragma once\r
+\r
+#include "frame_producer.h"\r
+\r
+namespace caspar { namespace core {\r
+ \r
+class destroy_producer_proxy : public frame_producer\r
+{\r
+public:\r
+ destroy_producer_proxy(const safe_ptr<frame_producer>& producer);\r
+ ~destroy_producer_proxy();\r
+\r
+ virtual safe_ptr<basic_frame> receive();\r
+ virtual std::wstring print() const; // nothrow\r
+\r
+ virtual void param(const std::wstring&);\r
+\r
+ virtual safe_ptr<frame_producer> get_following_producer() const; // nothrow\r
+ virtual void set_leading_producer(const safe_ptr<frame_producer>&); // nothrow\r
+private:\r
+ safe_ptr<frame_producer> producer_;\r
+};\r
+\r
+\r
+}}\r
#include "../StdAfx.h"\r
\r
#include "frame_producer_device.h"\r
+#include "destroy_producer_proxy.h"\r
\r
#include <core/producer/frame/basic_frame.h>\r
#include <core/producer/frame/frame_factory.h>\r
\r
void load(int index, const safe_ptr<frame_producer>& producer, bool preview)\r
{\r
- executor_.invoke([&]{layers_[index].load(producer, preview);});\r
+ executor_.invoke([&]{layers_[index].load(make_safe<destroy_producer_proxy>(producer), preview);});\r
}\r
\r
void pause(int index)\r
\r
\r
/* File created by MIDL compiler version 7.00.0555 */\r
-/* at Fri May 20 15:23:50 2011\r
+/* at Sun May 22 21:42:51 2011\r
*/\r
/* Compiler settings for interop\DeckLinkAPI.idl:\r
Oicf, W1, Zp8, env=Win32 (32b run), target_arch=X86 7.00.0555 \r
\r
\r
/* File created by MIDL compiler version 7.00.0555 */\r
-/* at Fri May 20 15:23:50 2011\r
+/* at Sun May 22 21:42:51 2011\r
*/\r
/* Compiler settings for interop\DeckLinkAPI.idl:\r
Oicf, W1, Zp8, env=Win32 (32b run), target_arch=X86 7.00.0555 \r
\r
struct cg_producer::implementation : boost::noncopyable\r
{\r
- safe_ptr<core::frame_factory> frame_factory_;\r
safe_ptr<core::frame_producer> flash_producer_;\r
public:\r
- implementation(const safe_ptr<core::frame_factory>& frame_factory) \r
- : frame_factory_(frame_factory)\r
- , flash_producer_(create_flash_producer(frame_factory_, boost::assign::list_of(env::template_host())))\r
+ implementation(const safe_ptr<core::frame_producer>& frame_producer) \r
+ : flash_producer_(frame_producer)\r
{}\r
\r
void add(int layer, const std::wstring& filename, bool play_on_load, const std::wstring& label, const std::wstring& data)\r
\r
safe_ptr<cg_producer> get_default_cg_producer(const safe_ptr<core::channel>& channel, int render_layer)\r
{ \r
- try\r
- {\r
- return dynamic_pointer_cast<cg_producer>(channel->producer()->foreground(render_layer).get());\r
- }\r
- catch(std::bad_cast&)\r
+ auto flash_producer = channel->producer()->foreground(render_layer).get();\r
+\r
+ if(flash_producer->print().find(L"flash") == std::string::npos)\r
{\r
- safe_ptr<core::frame_factory> factory = channel->mixer();\r
- auto producer = make_safe<cg_producer>(factory); \r
- channel->producer()->load(render_layer, producer, true); \r
+ flash_producer = create_flash_producer(channel->mixer(), boost::assign::list_of(env::template_host())); \r
+ channel->producer()->load(render_layer, flash_producer, true); \r
channel->producer()->play(render_layer);\r
- return producer;\r
}\r
+\r
+ return make_safe<cg_producer>(flash_producer);\r
}\r
\r
safe_ptr<core::frame_producer> create_ct_producer(const safe_ptr<core::frame_factory> frame_factory, const std::vector<std::wstring>& params) \r
std::wstring filename = env::media_folder() + L"\\" + params[0] + L".ct";\r
if(!boost::filesystem::exists(filename))\r
return core::frame_producer::empty();\r
-\r
- auto producer = make_safe<cg_producer>(frame_factory);\r
+ \r
+ auto flash_producer = create_flash_producer(frame_factory, boost::assign::list_of(env::template_host())); \r
+ auto producer = make_safe<cg_producer>(flash_producer);\r
producer->add(0, filename, 1);\r
\r
return producer;\r
}\r
\r
-cg_producer::cg_producer(const safe_ptr<core::frame_factory>& frame_factory) : impl_(new implementation(frame_factory)){}\r
+cg_producer::cg_producer(const safe_ptr<core::frame_producer>& frame_producer) : impl_(new implementation(frame_producer)){}\r
cg_producer::cg_producer(cg_producer&& other) : impl_(std::move(other.impl_)){}\r
safe_ptr<core::basic_frame> cg_producer::receive(){return impl_->receive();}\r
void cg_producer::add(int layer, const std::wstring& template_name, bool play_on_load, const std::wstring& startFromLabel, const std::wstring& data){impl_->add(layer, template_name, play_on_load, startFromLabel, data);}\r
public:\r
static const unsigned int DEFAULT_LAYER = 9999;\r
\r
- explicit cg_producer(const safe_ptr<core::frame_factory>& frame_factory);\r
+ explicit cg_producer(const safe_ptr<core::frame_producer>& producer);\r
cg_producer(cg_producer&& other);\r
\r
// frame_producer\r