]> git.sesse.net Git - casparcg/blob - accelerator/accelerator.cpp
[streaming_consumer] Default to pcm_s24le for containers supporting it instead of...
[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 #include "ogl/util/device.h"
10
11 #include <common/env.h>
12
13 #include <core/mixer/image/image_mixer.h>
14
15 #include <tbb/mutex.h>
16
17 namespace caspar { namespace accelerator {
18         
19 struct accelerator::impl
20 {
21         const std::wstring                              path_;
22         tbb::mutex                                              mutex_;
23         std::shared_ptr<ogl::device>    ogl_device_;
24
25         impl(const std::wstring& path)
26                 : path_(path)
27         {
28         }
29
30         std::unique_ptr<core::image_mixer> create_image_mixer(int channel_id)
31         {
32                 try
33                 {
34                         if(path_ == L"gpu" || path_ == L"ogl" || path_ == L"auto" || path_ == L"default")
35                         {
36                                 tbb::mutex::scoped_lock lock(mutex_);
37
38                                 if(!ogl_device_)
39                                         ogl_device_.reset(new ogl::device());
40
41                                 return std::unique_ptr<core::image_mixer>(new ogl::image_mixer(
42                                                 spl::make_shared_ptr(ogl_device_),
43                                                 env::properties().get(L"configuration.mixer.blend-modes", false),
44                                                 env::properties().get(L"configuration.mixer.straight-alpha", false),
45                                                 channel_id));
46                         }
47                 }
48                 catch(...)
49                 {
50                         if(path_ == L"gpu" || path_ == L"ogl")
51                                 CASPAR_LOG_CURRENT_EXCEPTION();
52                 }
53 #ifdef _MSC_VER
54                 return std::unique_ptr<core::image_mixer>(new cpu::image_mixer(channel_id));
55 #else
56                 CASPAR_THROW_EXCEPTION(not_supported());
57 #endif
58         }
59 };
60
61 accelerator::accelerator(const std::wstring& path)
62         : impl_(new impl(path))
63 {
64 }
65
66 accelerator::~accelerator()
67 {
68 }
69
70 std::unique_ptr<core::image_mixer> accelerator::create_image_mixer(int channel_id)
71 {
72         return impl_->create_image_mixer(channel_id);
73 }
74
75 std::shared_ptr<ogl::device> accelerator::get_ogl_device() const
76 {
77         return impl_->ogl_device_;
78 }
79
80 }}