]> git.sesse.net Git - casparcg/blob - core/video_channel_context.cpp
2.0 image_mixer: Refactored, core: Fixed destruction proxy usage.
[casparcg] / core / video_channel_context.cpp
1 #include "stdAfx.h"\r
2 \r
3 #include "video_channel_context.h"\r
4 \r
5 namespace caspar { namespace core {\r
6 \r
7 struct video_channel_context::implementation\r
8 {               \r
9         mutable tbb::spin_rw_mutex      mutex_;\r
10         const int                                       index_;\r
11         video_format_desc                       format_desc_;\r
12         executor                                        execution_;\r
13         executor                                        destruction_;\r
14         ogl_device&                                     ogl_;\r
15 \r
16         implementation(int index, ogl_device& ogl, const video_format_desc& format_desc)\r
17                 : index_(index)\r
18                 , format_desc_(format_desc)\r
19                 , execution_(print() + L"/execution")\r
20                 , destruction_(print() + L"/destruction")\r
21                 , ogl_(ogl)\r
22         {\r
23                 execution_.set_priority_class(above_normal_priority_class);\r
24                 destruction_.set_priority_class(below_normal_priority_class);\r
25         }\r
26 \r
27         std::wstring print() const\r
28         {\r
29                 return L"video_channel[" + boost::lexical_cast<std::wstring>(index_+1) + L"|" +  format_desc_.name + L"]";\r
30         }\r
31 };\r
32 \r
33 video_channel_context::video_channel_context(int index, ogl_device& ogl, const video_format_desc& format_desc) \r
34         : impl_(new implementation(index, ogl, format_desc))\r
35 {\r
36 }\r
37 \r
38 const int video_channel_context::index() const {return impl_->index_;}\r
39 \r
40 video_format_desc video_channel_context::get_format_desc()\r
41 {\r
42         tbb::spin_rw_mutex::scoped_lock lock(impl_->mutex_, false);\r
43         return impl_->format_desc_;\r
44 }\r
45 \r
46 void video_channel_context::set_format_desc(const video_format_desc& format_desc)\r
47 {\r
48         tbb::spin_rw_mutex::scoped_lock lock(impl_->mutex_, true);\r
49         impl_->format_desc_ = format_desc;\r
50 }\r
51 \r
52 executor& video_channel_context::execution() {return impl_->execution_;}\r
53 executor& video_channel_context::destruction() {return impl_->destruction_;}\r
54 ogl_device& video_channel_context::ogl() { return impl_->ogl_;}\r
55 \r
56 std::wstring video_channel_context::print() const\r
57 {\r
58         return impl_->print();\r
59 }\r
60 \r
61 }}