File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -101,6 +101,9 @@ class Plugin : public Object
101101 // ! Returns nullptr if there is no such device.
102102 std::shared_ptr<Device> GetDeviceByID (AudioObjectID deviceID) const ;
103103
104+ // ! Check if device is already added.
105+ bool HasDevice (std::shared_ptr<Device> device) const ;
106+
104107 // ! Add device to the plugin.
105108 // ! Adds device to the owned object list.
106109 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
7878 return deviceByID.at (deviceID);
7979}
8080
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+
8190void Plugin::AddDevice (std::shared_ptr<Device> device)
8291{
8392 std::lock_guard writeLock (writeMutex_);
You can’t perform that action at this time.
0 commit comments