refs #277, slow auio init

* fixed QHostInfo::localHostName()
* move to BlackMisc, as it can be used elsewhere
* temp. change, moved methods in body until refs #278, #277 is fixed/ resolved
This commit is contained in:
Klaus Basan
2014-06-20 00:46:34 +02:00
parent 2ecef24c91
commit 97b8ee8c32
5 changed files with 38 additions and 18 deletions

View File

@@ -18,8 +18,8 @@ namespace BlackCore
*/
CVoiceVatlib::CVoiceVatlib(QObject *parent) :
IVoice(parent),
m_voice(Cvatlib_Voice_Simple::Create()),
m_audioOutput(new QAudioOutput()),
m_voice(nullptr),
m_audioOutput(nullptr),
m_inputSquelch(-1),
m_micTestResult(Cvatlib_Voice_Simple::agc_Ok),
m_isAudioLoopbackEnabled(false),
@@ -38,6 +38,10 @@ namespace BlackCore
{
try
{
// we use reset here until issue #277 is resolved
// easier to find root cause
m_audioOutput.reset(new QAudioOutput());
m_voice.reset(Cvatlib_Voice_Simple::Create());
m_voice->Setup(true, 3290, 2, 1, onRoomStatusUpdate, this);
m_voice->GetInputDevices(onInputHardwareDeviceReceived, this);
m_voice->GetOutputDevices(onOutputHardwareDeviceReceived, this);

View File

@@ -5,7 +5,6 @@
#include "audiodevice.h"
#include "blackmisc/blackmiscfreefunctions.h"
#include <QtNetwork/QHostInfo>
#include <tuple>
namespace BlackMisc
@@ -17,7 +16,7 @@ namespace BlackMisc
*/
CAudioDevice::CAudioDevice() :
m_type(Unknown), m_deviceIndex(invalidDeviceIndex()),
m_deviceName(""), m_hostName(CAudioDevice::computerHostName())
m_deviceName(""), m_hostName(BlackMisc::localHostName())
{
// void
}
@@ -27,20 +26,11 @@ namespace BlackMisc
*/
CAudioDevice::CAudioDevice(DeviceType type, const qint16 index, const QString &name) :
m_type(type), m_deviceIndex(index),
m_deviceName(name), m_hostName(CAudioDevice::computerHostName())
m_deviceName(name), m_hostName(BlackMisc::localHostName())
{
// void
}
/*
* Host name
*/
const QString &CAudioDevice::computerHostName()
{
static const QString hostName = QHostInfo::fromName(QHostInfo::localHostName()).localHostName();
return hostName;
}
/*
* Compare
*/

View File

@@ -135,10 +135,6 @@ namespace BlackMisc
QString m_deviceName;
//! \brief We use a DBus based system. Hence an audio device can reside on a differen computers, this here is its name
QString m_hostName;
private:
//! Own host name
static const QString &computerHostName();
};
} // Audio

View File

@@ -15,6 +15,10 @@
#include "variant.h"
#include "statusmessagelist.h"
#include "audioallclasses.h"
#include <QtNetwork/QHostInfo>
#include <QProcessEnvironment>
#include <QSysInfo>
/*
* Metadata for PQs
@@ -439,3 +443,23 @@ void BlackMisc::displayAllUserMetatypesTypes()
qDebug() << "type:" << mt << "name:" << QMetaType::typeName(mt) << QMetaType::sizeOf(mt) << BlackMisc::heapSizeOf(metaType);
}
}
/*
* Local host name
*/
const QString &BlackMisc::localHostName()
{
static const QString hostName = QHostInfo::localHostName();
return hostName;
}
/*
* Local host name
*/
const QString &BlackMisc::localHostNameEnvVariable()
{
static const QString hostName =
QProcessEnvironment::systemEnvironment().value("COMPUTERNAME",
QProcessEnvironment::systemEnvironment().value("HOSTNAME"));
return hostName;
}

View File

@@ -140,6 +140,12 @@ namespace BlackMisc
//! Real heap size of an object
size_t heapSizeOf(const QMetaObject &objectType);
//! Get local host name
const QString &localHostName();
//! Get local host name env.variable
const QString &localHostNameEnvVariable();
} // BlackMisc
#endif // guard