From 01e7cb99500790861aeba8fc1a9ff7f4355aaace Mon Sep 17 00:00:00 2001 From: Michael Goddard Date: Mon, 23 Jan 2012 11:52:42 +1000 Subject: Implement QAudioDeviceInfo operator==/!= Compares some of the useful parts, but perhaps should be made more tolerant. Also refactored the auto test to properly skip if there are no (output) devices, rather than manually skip. Task-number: QTBUG-13723 Change-Id: I3b83f87a440a83f4237fa119a23009bc99e7626a Reviewed-by: Jonas Rabbe Reviewed-by: Dmytro Poplavskiy --- src/multimedia/audio/qaudiodeviceinfo.cpp | 26 +++++++++++++++++++++++++- src/multimedia/audio/qaudiodeviceinfo.h | 3 +++ 2 files changed, 28 insertions(+), 1 deletion(-) (limited to 'src') diff --git a/src/multimedia/audio/qaudiodeviceinfo.cpp b/src/multimedia/audio/qaudiodeviceinfo.cpp index f806fa5d1..a2a9f5d64 100644 --- a/src/multimedia/audio/qaudiodeviceinfo.cpp +++ b/src/multimedia/audio/qaudiodeviceinfo.cpp @@ -186,7 +186,31 @@ QAudioDeviceInfo& QAudioDeviceInfo::operator=(const QAudioDeviceInfo &other) } /*! - Returns whether this QAudioDeviceInfo object holds a device definition. + Returns true if this QAudioDeviceInfo class represents the + same audio device as \a other. +*/ +bool QAudioDeviceInfo::operator ==(const QAudioDeviceInfo &other) const +{ + if (d == other.d) + return true; + if (d->realm == other.d->realm + && d->mode == other.d->mode + && d->handle == other.d->handle + && deviceName() == other.deviceName()) + return true; +} + +/*! + Returns true if this QAudioDeviceInfo class represents a + different audio device than \a other +*/ +bool QAudioDeviceInfo::operator !=(const QAudioDeviceInfo &other) const +{ + return !operator==(other); +} + +/*! + Returns whether this QAudioDeviceInfo object holds a valid device definition. */ bool QAudioDeviceInfo::isNull() const { diff --git a/src/multimedia/audio/qaudiodeviceinfo.h b/src/multimedia/audio/qaudiodeviceinfo.h index 0e5598fb4..f21622bb7 100644 --- a/src/multimedia/audio/qaudiodeviceinfo.h +++ b/src/multimedia/audio/qaudiodeviceinfo.h @@ -76,6 +76,9 @@ public: QAudioDeviceInfo& operator=(const QAudioDeviceInfo& other); + bool operator==(const QAudioDeviceInfo &other) const; + bool operator!=(const QAudioDeviceInfo &other) const; + bool isNull() const; QString deviceName() const; -- cgit v1.2.1