Add equals functions for classes in libaudiofoundation.
Add equals functions that can be used to check if current object is the
same as the given object by checking if all members are the same.
Bug: 135621476
Test: make
Change-Id: Idcf09587f629e6719e9dcf2f0fb7d68a01eafef9
diff --git a/media/libaudiofoundation/DeviceDescriptorBase.cpp b/media/libaudiofoundation/DeviceDescriptorBase.cpp
index 672d06c..18fd184 100644
--- a/media/libaudiofoundation/DeviceDescriptorBase.cpp
+++ b/media/libaudiofoundation/DeviceDescriptorBase.cpp
@@ -110,6 +110,15 @@
AudioPort::log(" ");
}
+bool DeviceDescriptorBase::equals(const sp<DeviceDescriptorBase> &other) const
+{
+ return other != nullptr &&
+ static_cast<const AudioPort*>(this)->equals(other) &&
+ static_cast<const AudioPortConfig*>(this)->equals(other) &&
+ mAddress.compare(other->address()) == 0 &&
+ mDeviceType == other->type();
+}
+
status_t DeviceDescriptorBase::writeToParcel(Parcel *parcel) const
{
status_t status = NO_ERROR;