]> git.sesse.net Git - casparcg/blob - accelerator/accelerator.cpp
Changed default log level to info and moved logging statements that we always want...
[casparcg] / accelerator / accelerator.cpp
1 #include "StdAfx.h"
2
3 #include "accelerator.h"
4
5 #ifdef _MSC_VER
6 #include "cpu/image/image_mixer.h"
7 #endif
8 #include "ogl/image/image_mixer.h"
9
10 #include "ogl/util/device.h"
11
12 #include <common/env.h>
13
14 #include <tbb/mutex.h>
15
16 namespace caspar { namespace accelerator {
17         
18 struct accelerator::impl
19 {
20         const std::wstring                              path_;
21         tbb::mutex                                              mutex_;
22         std::shared_ptr<ogl::device>    ogl_device_;
23
24         impl(const std::wstring& path)
25                 : path_(path)
26         {
27         }
28
29         std::unique_ptr<core::image_mixer> create_image_mixer(int channel_id)
30         {
31                 try
32                 {
33                         if(path_ == L"gpu" || path_ == L"ogl" || path_ == L"auto" || path_ == L"default")
34                         {
35                                 tbb::mutex::scoped_lock lock(mutex_);
36
37                                 if(!ogl_device_)
38                                         ogl_device_.reset(new ogl::device());
39
40                                 return std::unique_ptr<core::image_mixer>(new ogl::image_mixer(
41                                                 spl::make_shared_ptr(ogl_device_),
42                                                 env::properties().get(L"configuration.mixer.blend-modes", false),
43                                                 env::properties().get(L"configuration.mixer.straight-alpha", false),
44                                                 channel_id));
45                         }
46                 }
47                 catch(...)
48                 {
49                         if(path_ == L"gpu" || path_ == L"ogl")
50                                 CASPAR_LOG_CURRENT_EXCEPTION();
51                 }
52 #ifdef _MSC_VER
53                 return std::unique_ptr<core::image_mixer>(new cpu::image_mixer(channel_id));
54 #else
55                 CASPAR_THROW_EXCEPTION(not_supported());
56 #endif
57         }
58 };
59
60 accelerator::accelerator(const std::wstring& path)
61         : impl_(new impl(path))
62 {
63 }
64
65 accelerator::~accelerator()
66 {
67 }
68
69 std::unique_ptr<core::image_mixer> accelerator::create_image_mixer(int channel_id)
70 {
71         return impl_->create_image_mixer(channel_id);
72 }
73
74 }}