HikoGUI
A low latency retained GUI
Loading...
Searching...
No Matches
audio_system_aggregate.hpp
1// Copyright Take Vos 2020.
2// Distributed under the Boost Software License, Version 1.0.
3// (See accompanying file LICENSE_1_0.txt or copy at https://www.boost.org/LICENSE_1_0.txt)
4
5#include "audio_system.hpp"
6#include "../algorithm.hpp"
7#include <algorithm>
8
9namespace tt {
10
12 public std::enable_shared_from_this<audio_system_aggregate>,
13 public audio_system,
15public:
16 using super = audio_system;
17
19
20 [[nodiscard]] std::vector<std::shared_ptr<audio_device>> devices() noexcept override
21 {
22 ttlet lock = std::scoped_lock(audio_system::mutex);
23
25 for (auto &child: _children) {
26 auto tmp = child->devices();
27 std::move(tmp.begin(), tmp.end(), std::back_inserter(r));
28 }
29 return r;
30 }
31
32 void add_audio_system(std::shared_ptr<audio_system> const &new_audio_system) noexcept
33 {
34 ttlet lock = std::scoped_lock(audio_system::mutex);
35 _children.push_back(new_audio_system);
36 }
37
38 template<typename T, typename... Args>
39 std::shared_ptr<audio_system> make_audio_system(Args &&... args)
40 {
41 ttlet lock = std::scoped_lock(audio_system::mutex);
42
43 auto new_audio_system = std::make_shared<T>(weak_from_this(), std::forward<Args>(args)...);
44 new_audio_system->init();
45 add_audio_system(new_audio_system);
47 return new_audio_system;
48 }
49
51 {
52 if (auto delegate_ = this->_delegate.lock()) {
53 delegate_->audio_device_list_changed(*this);
54 }
55 }
56
57private:
59};
60
61}
Definition audio_system.hpp:17
Definition audio_system_aggregate.hpp:14
void audio_device_list_changed(tt::audio_system &self) override
Definition audio_system_aggregate.hpp:50
Definition audio_system_delegate.hpp:12
T back_inserter(T... args)
T move(T... args)