mirror of
https://github.com/swift-project/pilotclient.git
synced 2026-04-02 15:15:50 +08:00
committed by
Mathew Sutcliffe
parent
51cbd2a394
commit
1c1fdabd2e
@@ -9,22 +9,48 @@
|
||||
|
||||
#include "vaudiodevice.h"
|
||||
#include "blackmisc/blackmiscfreefunctions.h"
|
||||
#include <QtNetwork/QHostInfo>
|
||||
|
||||
namespace BlackMisc
|
||||
{
|
||||
namespace Voice
|
||||
{
|
||||
/*
|
||||
* Constructor
|
||||
*/
|
||||
CAudioDevice::CAudioDevice() :
|
||||
m_type(Unknown), m_deviceIndex(invalidDevice()),
|
||||
m_deviceName(""), m_hostName(CAudioDevice::hostName())
|
||||
{
|
||||
// void
|
||||
}
|
||||
|
||||
/*
|
||||
* Constructor
|
||||
*/
|
||||
CAudioDevice::CAudioDevice(DeviceType type, const int16_t index, const QString &name) :
|
||||
m_type(type), m_deviceIndex(index),
|
||||
m_deviceName(name), m_hostName(CAudioDevice::hostName())
|
||||
{
|
||||
// void
|
||||
}
|
||||
|
||||
/*
|
||||
* Host name
|
||||
*/
|
||||
QString CAudioDevice::hostName()
|
||||
{
|
||||
QHostInfo hostInfo = QHostInfo::fromName(QHostInfo::localHostName());
|
||||
return hostInfo.localHostName();
|
||||
}
|
||||
|
||||
/*
|
||||
* Same device?
|
||||
*/
|
||||
bool CAudioDevice::operator ==(const CAudioDevice &other) const
|
||||
{
|
||||
if (&other == this)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
if (m_deviceIndex == other.m_deviceIndex)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
if (&other == this) return true;
|
||||
if (m_deviceIndex == other.m_deviceIndex && m_type == other.m_type) return true;
|
||||
|
||||
// otherwise
|
||||
return false;
|
||||
@@ -38,23 +64,30 @@ namespace BlackMisc
|
||||
return !((*this) == other);
|
||||
}
|
||||
|
||||
/*
|
||||
* Hash
|
||||
*/
|
||||
uint CAudioDevice::getValueHash() const
|
||||
{
|
||||
QList<uint> hashs;
|
||||
hashs << qHash(static_cast<uint>(m_type));
|
||||
hashs << qHash(m_deviceIndex);
|
||||
hashs << qHash(m_deviceName);
|
||||
hashs << qHash(m_hostName);
|
||||
return BlackMisc::calculateHash(hashs, "CAudioDevice");
|
||||
}
|
||||
|
||||
void CAudioDevice::registerMetadata()
|
||||
{
|
||||
qRegisterMetaType<CAudioDevice>();
|
||||
qDBusRegisterMetaType<CAudioDevice>();
|
||||
}
|
||||
|
||||
/*
|
||||
* As String
|
||||
*/
|
||||
QString CAudioDevice::convertToQString(bool /* i18n */) const
|
||||
{
|
||||
return m_deviceName;
|
||||
if (this->m_hostName.isEmpty()) return m_deviceName;
|
||||
QString s(this->m_deviceName);
|
||||
s.append(" [");
|
||||
s.append(this->hostName());
|
||||
s.append("]");
|
||||
return s;
|
||||
}
|
||||
|
||||
/*
|
||||
@@ -62,8 +95,10 @@ namespace BlackMisc
|
||||
*/
|
||||
void CAudioDevice::marshallToDbus(QDBusArgument &argument) const
|
||||
{
|
||||
argument << static_cast<uint>(m_type);
|
||||
argument << m_deviceIndex;
|
||||
argument << m_deviceName;
|
||||
argument << m_hostName;
|
||||
}
|
||||
|
||||
/*
|
||||
@@ -71,20 +106,21 @@ namespace BlackMisc
|
||||
*/
|
||||
void CAudioDevice::unmarshallFromDbus(const QDBusArgument &argument)
|
||||
{
|
||||
uint t;
|
||||
argument >> t;
|
||||
this->m_type = static_cast<DeviceType>(t);
|
||||
argument >> m_deviceIndex;
|
||||
argument >> m_deviceName;
|
||||
argument >> m_hostName;
|
||||
}
|
||||
|
||||
void CInputAudioDevice::registerMetadata()
|
||||
/*
|
||||
* Register
|
||||
*/
|
||||
void CAudioDevice::registerMetadata()
|
||||
{
|
||||
qRegisterMetaType<CInputAudioDevice>();
|
||||
qDBusRegisterMetaType<CInputAudioDevice>();
|
||||
}
|
||||
|
||||
void COutputAudioDevice::registerMetadata()
|
||||
{
|
||||
qRegisterMetaType<COutputAudioDevice>();
|
||||
qDBusRegisterMetaType<COutputAudioDevice>();
|
||||
qRegisterMetaType<CAudioDevice>();
|
||||
qDBusRegisterMetaType<CAudioDevice>();
|
||||
}
|
||||
|
||||
} // Voice
|
||||
|
||||
Reference in New Issue
Block a user