File tree Expand file tree Collapse file tree 2 files changed +12
-0
lines changed Expand file tree Collapse file tree 2 files changed +12
-0
lines changed Original file line number Diff line number Diff line change @@ -101,6 +101,9 @@ class Plugin : public Object
101
101
// ! Returns nullptr if there is no such device.
102
102
std::shared_ptr<Device> GetDeviceByID (AudioObjectID deviceID) const ;
103
103
104
+ // ! Check if device is already added.
105
+ bool HasDevice (std::shared_ptr<Device> device) const ;
106
+
104
107
// ! Add device to the plugin.
105
108
// ! Adds device to the owned object list.
106
109
void AddDevice (std::shared_ptr<Device> device);
Original file line number Diff line number Diff line change @@ -78,6 +78,15 @@ std::shared_ptr<Device> Plugin::GetDeviceByID(AudioObjectID deviceID) const
78
78
return deviceByID.at (deviceID);
79
79
}
80
80
81
+ bool Plugin::HasDevice (std::shared_ptr<Device> device) const
82
+ {
83
+ auto readLock = deviceByID_.GetReadLock ();
84
+
85
+ const auto & deviceByID = readLock.GetReference ();
86
+
87
+ return deviceByID.count (device->GetID ());
88
+ }
89
+
81
90
void Plugin::AddDevice (std::shared_ptr<Device> device)
82
91
{
83
92
std::lock_guard writeLock (writeMutex_);
You can’t perform that action at this time.
0 commit comments