Anklang 0.3.0-460-gc4ef46ba
ASE — Anklang Sound Engine (C++)

« « « Anklang Documentation
Loading...
Searching...
No Matches
device.cc
Go to the documentation of this file.
1 // This Source Code Form is licensed MPL-2.0: http://mozilla.org/MPL/2.0
2#include "device.hh"
3#include "internal.hh"
4
5namespace Ase {
6
7// == Device ==
8Device::Device() :
9 devices (this, "devices")
10{}
11
12// == DeviceImpl ==
13void
14DeviceImpl::_set_parent (GadgetImpl *parent)
15{
16 assert_warn (!is_active());
17 GadgetImpl::_set_parent (parent);
18}
19
20void
21DeviceImpl::_activate()
22{
23 assert_return (!activated_);
24 activated_ = true;
25}
26
27void
28DeviceImpl::_deactivate()
29{
30 assert_return (activated_);
31 activated_ = false;
32}
33
34template<typename E> std::pair<std::shared_ptr<E>,ssize_t>
35find_shared_by_ref (const std::vector<std::shared_ptr<E> > &v, const E &e)
36{
37 for (ssize_t i = 0; i < v.size(); i++)
38 if (&e == &*v[i])
39 return std::make_pair (v[i], i);
41}
42
43void
44DeviceImpl::_disconnect_remove ()
45{
46 AudioProcessorP proc = _audio_processor();
47 return_unless (proc);
48 AudioEngine *engine = &proc->engine();
49 auto job = [proc] () {
50 proc->enable_engine_output (false);
51 proc->disconnect_ibuses();
52 proc->disconnect_obuses();
53 proc->disconnect_event_input();
54 // TODO: do we need to remove this from parent container (combo)?
55 };
56 engine->async_jobs += job;
57}
58
60DeviceImpl::extract_info (const String &aseid, const AudioProcessor::StaticInfo &static_info)
61{
63 static_info (pinfo);
64 DeviceInfo info = {
65 .uri = aseid,
66 .name = pinfo.label,
67 .category = pinfo.category,
68 .description = pinfo.description,
69 .website_url = pinfo.website_url,
70 .creator_name = pinfo.creator_name,
71 .creator_url = pinfo.creator_url,
72 };
73 return info;
74}
75
76// == Device ==
77void
78Device::remove_self ()
79{
80 Gadget *parent = _parent();
81 NativeDevice *device = dynamic_cast<NativeDevice*> (parent);
82 if (device)
83 device->remove_device (*this);
84}
85
86Track*
87Device::_track () const
88{
89 for (Gadget *parent = _parent(); parent; parent = parent->_parent())
90 {
91 Track *track = dynamic_cast<Track*> (parent);
92 if (track)
93 return track;
94 }
95 return nullptr;
96}
97
98} // Ase
JobQueue async_jobs
Executed asynchronously, may modify AudioProcessor objects.
Definition engine.hh:65
Base type for classes that have a Property.
Definition gadget.hh:12
Base type for classes that have a Property.
Definition api.hh:177
virtual GadgetImpl * _parent() const =0
Retrieve parent container.
Interface to access NativeDevice instances.
Definition api.hh:239
virtual void remove_device(Device &sub)=0
Remove a directly contained device.
Container for Clip objects and sequencing information.
Definition api.hh:285
#define assert_return(expr,...)
Return from the current function if expr is unmet and issue an assertion warning.
Definition internal.hh:29
#define return_unless(cond,...)
Return silently if cond does not evaluate to true with return value ...
Definition internal.hh:71
#define assert_warn(expr)
Issue an assertion warning if expr evaluates to false.
Definition internal.hh:33
T make_pair(T... args)
The Anklang C++ API namespace.
Definition api.hh:9
CString website_url
Website of/about this AudioProcessor.
Definition processor.hh:35
String uri
Unique identifier for de-/serialization.
Definition api.hh:204
CString description
Elaborate description for help dialogs.
Definition processor.hh:34
CString creator_url
Internet contact of the creator.
Definition processor.hh:37
CString creator_name
Name of the creator.
Definition processor.hh:36
CString label
Preferred user interface name.
Definition processor.hh:30
CString category
Category to allow grouping for processors of similar function.
Definition processor.hh:32
Detailed information and common properties of AudioProcessor subclasses.
Definition processor.hh:29
Info for device types.
Definition api.hh:203
typedef ssize_t