mirror of
https://github.com/overte-org/overte.git
synced 2025-08-10 06:53:01 +02:00
Merge branch 'master' of https://github.com/highfidelity/hifi into temp0
This commit is contained in:
commit
11247734d4
7 changed files with 90 additions and 61 deletions
|
@ -129,12 +129,12 @@ void DatagramProcessor::processDatagrams() {
|
||||||
|
|
||||||
if (incomingType == PacketTypeMuteEnvironment) {
|
if (incomingType == PacketTypeMuteEnvironment) {
|
||||||
glm::vec3 position;
|
glm::vec3 position;
|
||||||
float radius, distance;
|
float radius;
|
||||||
|
|
||||||
int headerSize = numBytesForPacketHeaderGivenPacketType(PacketTypeMuteEnvironment);
|
int headerSize = numBytesForPacketHeaderGivenPacketType(PacketTypeMuteEnvironment);
|
||||||
memcpy(&position, incomingPacket.constData() + headerSize, sizeof(glm::vec3));
|
memcpy(&position, incomingPacket.constData() + headerSize, sizeof(glm::vec3));
|
||||||
memcpy(&radius, incomingPacket.constData() + headerSize + sizeof(glm::vec3), sizeof(float));
|
memcpy(&radius, incomingPacket.constData() + headerSize + sizeof(glm::vec3), sizeof(float));
|
||||||
distance = glm::distance(DependencyManager::get<AvatarManager>()->getMyAvatar()->getPosition(),
|
float distance = glm::distance(DependencyManager::get<AvatarManager>()->getMyAvatar()->getPosition(),
|
||||||
position);
|
position);
|
||||||
|
|
||||||
mute = mute && (distance < radius);
|
mute = mute && (distance < radius);
|
||||||
|
|
|
@ -888,13 +888,14 @@ void AudioClient::processReceivedSamples(const QByteArray& inputBuffer, QByteArr
|
||||||
|
|
||||||
void AudioClient::sendMuteEnvironmentPacket() {
|
void AudioClient::sendMuteEnvironmentPacket() {
|
||||||
QByteArray mutePacket = byteArrayWithPopulatedHeader(PacketTypeMuteEnvironment);
|
QByteArray mutePacket = byteArrayWithPopulatedHeader(PacketTypeMuteEnvironment);
|
||||||
QDataStream mutePacketStream(&mutePacket, QIODevice::Append);
|
int headerSize = mutePacket.size();
|
||||||
|
|
||||||
const float MUTE_RADIUS = 50;
|
const float MUTE_RADIUS = 50;
|
||||||
|
|
||||||
glm::vec3 currentSourcePosition = _positionGetter();
|
glm::vec3 currentSourcePosition = _positionGetter();
|
||||||
mutePacketStream.writeBytes(reinterpret_cast<const char *>(¤tSourcePosition), sizeof(glm::vec3));
|
mutePacket.resize(mutePacket.size() + sizeof(glm::vec3) + sizeof(float));
|
||||||
mutePacketStream.writeBytes(reinterpret_cast<const char *>(&MUTE_RADIUS), sizeof(float));
|
memcpy(mutePacket.data() + headerSize, ¤tSourcePosition, sizeof(glm::vec3));
|
||||||
|
memcpy(mutePacket.data() + headerSize + sizeof(glm::vec3), &MUTE_RADIUS, sizeof(float));
|
||||||
|
|
||||||
// grab our audio mixer from the NodeList, if it exists
|
// grab our audio mixer from the NodeList, if it exists
|
||||||
auto nodelist = DependencyManager::get<NodeList>();
|
auto nodelist = DependencyManager::get<NodeList>();
|
||||||
|
|
|
@ -39,6 +39,7 @@ const char SOLO_NODE_TYPES[2] = {
|
||||||
const QUrl DEFAULT_NODE_AUTH_URL = QUrl("https://metaverse.highfidelity.io");
|
const QUrl DEFAULT_NODE_AUTH_URL = QUrl("https://metaverse.highfidelity.io");
|
||||||
|
|
||||||
LimitedNodeList::LimitedNodeList(unsigned short socketListenPort, unsigned short dtlsListenPort) :
|
LimitedNodeList::LimitedNodeList(unsigned short socketListenPort, unsigned short dtlsListenPort) :
|
||||||
|
linkedDataCreateCallback(NULL),
|
||||||
_sessionUUID(),
|
_sessionUUID(),
|
||||||
_nodeHash(),
|
_nodeHash(),
|
||||||
_nodeMutex(QReadWriteLock::Recursive),
|
_nodeMutex(QReadWriteLock::Recursive),
|
||||||
|
|
|
@ -49,14 +49,32 @@ void OctreePersistThread::parseSettings(const QJsonObject& settings) {
|
||||||
qDebug() << "BACKUP RULES:";
|
qDebug() << "BACKUP RULES:";
|
||||||
|
|
||||||
foreach (const QJsonValue& value, backupRules) {
|
foreach (const QJsonValue& value, backupRules) {
|
||||||
|
|
||||||
QJsonObject obj = value.toObject();
|
QJsonObject obj = value.toObject();
|
||||||
|
|
||||||
|
int interval = 0;
|
||||||
|
int count = 0;
|
||||||
|
|
||||||
|
QJsonValue intervalVal = obj["backupInterval"];
|
||||||
|
if (intervalVal.isString()) {
|
||||||
|
interval = intervalVal.toString().toInt();
|
||||||
|
} else {
|
||||||
|
interval = intervalVal.toInt();
|
||||||
|
}
|
||||||
|
|
||||||
|
QJsonValue countVal = obj["maxBackupVersions"];
|
||||||
|
if (countVal.isString()) {
|
||||||
|
count = countVal.toString().toInt();
|
||||||
|
} else {
|
||||||
|
count = countVal.toInt();
|
||||||
|
}
|
||||||
|
|
||||||
qDebug() << " Name:" << obj["Name"].toString();
|
qDebug() << " Name:" << obj["Name"].toString();
|
||||||
qDebug() << " format:" << obj["format"].toString();
|
qDebug() << " format:" << obj["format"].toString();
|
||||||
qDebug() << " interval:" << obj["backupInterval"].toInt();
|
qDebug() << " interval:" << interval;
|
||||||
qDebug() << " count:" << obj["maxBackupVersions"].toInt();
|
qDebug() << " count:" << count;
|
||||||
|
|
||||||
BackupRule newRule = { obj["Name"].toString(), obj["backupInterval"].toInt(),
|
BackupRule newRule = { obj["Name"].toString(), interval, obj["format"].toString(), count, 0};
|
||||||
obj["format"].toString(), obj["maxBackupVersions"].toInt(), 0};
|
|
||||||
|
|
||||||
newRule.lastBackup = getMostRecentBackupTimeInUsecs(obj["format"].toString());
|
newRule.lastBackup = getMostRecentBackupTimeInUsecs(obj["format"].toString());
|
||||||
|
|
||||||
|
@ -321,29 +339,35 @@ bool OctreePersistThread::getMostRecentBackup(const QString& format,
|
||||||
void OctreePersistThread::rollOldBackupVersions(const BackupRule& rule) {
|
void OctreePersistThread::rollOldBackupVersions(const BackupRule& rule) {
|
||||||
|
|
||||||
if (rule.extensionFormat.contains("%N")) {
|
if (rule.extensionFormat.contains("%N")) {
|
||||||
qDebug() << "Rolling old backup versions for rule" << rule.name << "...";
|
if (rule.maxBackupVersions > 0) {
|
||||||
for(int n = rule.maxBackupVersions - 1; n > 0; n--) {
|
qDebug() << "Rolling old backup versions for rule" << rule.name << "...";
|
||||||
QString backupExtensionN = rule.extensionFormat;
|
for(int n = rule.maxBackupVersions - 1; n > 0; n--) {
|
||||||
QString backupExtensionNplusOne = rule.extensionFormat;
|
QString backupExtensionN = rule.extensionFormat;
|
||||||
backupExtensionN.replace(QString("%N"), QString::number(n));
|
QString backupExtensionNplusOne = rule.extensionFormat;
|
||||||
backupExtensionNplusOne.replace(QString("%N"), QString::number(n+1));
|
backupExtensionN.replace(QString("%N"), QString::number(n));
|
||||||
|
backupExtensionNplusOne.replace(QString("%N"), QString::number(n+1));
|
||||||
|
|
||||||
QString backupFilenameN = _filename + backupExtensionN;
|
QString backupFilenameN = _filename + backupExtensionN;
|
||||||
QString backupFilenameNplusOne = _filename + backupExtensionNplusOne;
|
QString backupFilenameNplusOne = _filename + backupExtensionNplusOne;
|
||||||
|
|
||||||
QFile backupFileN(backupFilenameN);
|
QFile backupFileN(backupFilenameN);
|
||||||
|
|
||||||
if (backupFileN.exists()) {
|
if (backupFileN.exists()) {
|
||||||
qDebug() << "rolling backup file " << backupFilenameN << "to" << backupFilenameNplusOne << "...";
|
qDebug() << "rolling backup file " << backupFilenameN << "to" << backupFilenameNplusOne << "...";
|
||||||
int result = rename(qPrintable(backupFilenameN), qPrintable(backupFilenameNplusOne));
|
int result = rename(qPrintable(backupFilenameN), qPrintable(backupFilenameNplusOne));
|
||||||
if (result == 0) {
|
if (result == 0) {
|
||||||
qDebug() << "DONE rolling backup file " << backupFilenameN << "to" << backupFilenameNplusOne << "...";
|
qDebug() << "DONE rolling backup file " << backupFilenameN << "to" << backupFilenameNplusOne << "...";
|
||||||
} else {
|
} else {
|
||||||
qDebug() << "ERROR in rolling backup file " << backupFilenameN << "to" << backupFilenameNplusOne << "...";
|
qDebug() << "ERROR in rolling backup file " << backupFilenameN << "to" << backupFilenameNplusOne << "...";
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
qDebug() << "Done rolling old backup versions...";
|
||||||
|
} else {
|
||||||
|
qDebug() << "Rolling backups for rule" << rule.name << "."
|
||||||
|
<< " Max Rolled Backup Versions less than 1 [" << rule.maxBackupVersions << "]."
|
||||||
|
<< " No need to roll backups...";
|
||||||
}
|
}
|
||||||
qDebug() << "Done rolling old backup versions...";
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -384,19 +408,25 @@ void OctreePersistThread::backup() {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
QFile persistFile(_filename);
|
if (rule.maxBackupVersions > 0) {
|
||||||
if (persistFile.exists()) {
|
QFile persistFile(_filename);
|
||||||
qDebug() << "backing up persist file " << _filename << "to" << backupFileName << "...";
|
if (persistFile.exists()) {
|
||||||
bool result = QFile::copy(_filename, backupFileName);
|
qDebug() << "backing up persist file " << _filename << "to" << backupFileName << "...";
|
||||||
if (result) {
|
bool result = QFile::copy(_filename, backupFileName);
|
||||||
qDebug() << "DONE backing up persist file...";
|
if (result) {
|
||||||
rule.lastBackup = now; // only record successful backup in this case.
|
qDebug() << "DONE backing up persist file...";
|
||||||
|
rule.lastBackup = now; // only record successful backup in this case.
|
||||||
|
} else {
|
||||||
|
qDebug() << "ERROR in backing up persist file...";
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
qDebug() << "ERROR in backing up persist file...";
|
qDebug() << "persist file " << _filename << " does not exist. " <<
|
||||||
|
"nothing to backup for this rule ["<< rule.name << "]...";
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
qDebug() << "persist file " << _filename << " does not exist. " <<
|
qDebug() << "This backup rule" << rule.name
|
||||||
"nothing to backup for this rule ["<< rule.name << "]...";
|
<< " has Max Rolled Backup Versions less than 1 [" << rule.maxBackupVersions << "]."
|
||||||
|
<< " There are no backups to be done...";
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
qDebug() << "Backup not needed for this rule ["<< rule.name << "]...";
|
qDebug() << "Backup not needed for this rule ["<< rule.name << "]...";
|
||||||
|
|
|
@ -31,44 +31,41 @@ AudioScriptingInterface::AudioScriptingInterface() :
|
||||||
}
|
}
|
||||||
|
|
||||||
ScriptAudioInjector* AudioScriptingInterface::playSound(Sound* sound, const AudioInjectorOptions& injectorOptions) {
|
ScriptAudioInjector* AudioScriptingInterface::playSound(Sound* sound, const AudioInjectorOptions& injectorOptions) {
|
||||||
AudioInjector* injector = NULL;
|
if (QThread::currentThread() != thread()) {
|
||||||
QMetaObject::invokeMethod(this, "invokedPlaySound", Qt::BlockingQueuedConnection,
|
ScriptAudioInjector* injector = NULL;
|
||||||
Q_RETURN_ARG(AudioInjector*, injector),
|
|
||||||
Q_ARG(Sound*, sound), Q_ARG(const AudioInjectorOptions&, injectorOptions));
|
QMetaObject::invokeMethod(this, "playSound", Qt::BlockingQueuedConnection,
|
||||||
if (injector) {
|
Q_RETURN_ARG(ScriptAudioInjector*, injector),
|
||||||
return new ScriptAudioInjector(injector);
|
Q_ARG(Sound*, sound), Q_ARG(const AudioInjectorOptions&, injectorOptions));
|
||||||
} else {
|
return injector;
|
||||||
return NULL;
|
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
AudioInjector* AudioScriptingInterface::invokedPlaySound(Sound* sound, const AudioInjectorOptions& injectorOptions) {
|
|
||||||
if (sound) {
|
if (sound) {
|
||||||
// stereo option isn't set from script, this comes from sound metadata or filename
|
// stereo option isn't set from script, this comes from sound metadata or filename
|
||||||
AudioInjectorOptions optionsCopy = injectorOptions;
|
AudioInjectorOptions optionsCopy = injectorOptions;
|
||||||
optionsCopy.stereo = sound->isStereo();
|
optionsCopy.stereo = sound->isStereo();
|
||||||
|
|
||||||
QThread* injectorThread = new QThread();
|
QThread* injectorThread = new QThread();
|
||||||
injectorThread->setObjectName("Audio Injector Thread");
|
injectorThread->setObjectName("Audio Injector Thread");
|
||||||
|
|
||||||
AudioInjector* injector = new AudioInjector(sound, optionsCopy);
|
AudioInjector* injector = new AudioInjector(sound, optionsCopy);
|
||||||
injector->setLocalAudioInterface(_localAudioInterface);
|
injector->setLocalAudioInterface(_localAudioInterface);
|
||||||
|
|
||||||
injector->moveToThread(injectorThread);
|
injector->moveToThread(injectorThread);
|
||||||
|
|
||||||
// start injecting when the injector thread starts
|
// start injecting when the injector thread starts
|
||||||
connect(injectorThread, &QThread::started, injector, &AudioInjector::injectAudio);
|
connect(injectorThread, &QThread::started, injector, &AudioInjector::injectAudio);
|
||||||
|
|
||||||
// connect the right slots and signals for AudioInjector and thread cleanup
|
// connect the right slots and signals for AudioInjector and thread cleanup
|
||||||
connect(injector, &AudioInjector::destroyed, injectorThread, &QThread::quit);
|
connect(injector, &AudioInjector::destroyed, injectorThread, &QThread::quit);
|
||||||
connect(injectorThread, &QThread::finished, injectorThread, &QThread::deleteLater);
|
connect(injectorThread, &QThread::finished, injectorThread, &QThread::deleteLater);
|
||||||
|
|
||||||
injectorThread->start();
|
injectorThread->start();
|
||||||
|
|
||||||
return injector;
|
return new ScriptAudioInjector(injector);
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
qDebug() << "AudioScriptingInterface::playSound called with null Sound object.";
|
qDebug() << "AudioScriptingInterface::playSound called with null Sound object.";
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
}
|
}
|
|
@ -32,9 +32,6 @@ protected:
|
||||||
signals:
|
signals:
|
||||||
void mutedByMixer();
|
void mutedByMixer();
|
||||||
void environmentMuted();
|
void environmentMuted();
|
||||||
|
|
||||||
private slots:
|
|
||||||
AudioInjector* invokedPlaySound(Sound* sound, const AudioInjectorOptions& injectorOptions);
|
|
||||||
|
|
||||||
private:
|
private:
|
||||||
AudioScriptingInterface();
|
AudioScriptingInterface();
|
||||||
|
|
|
@ -13,7 +13,9 @@
|
||||||
|
|
||||||
QScriptValue injectorToScriptValue(QScriptEngine* engine, ScriptAudioInjector* const& in) {
|
QScriptValue injectorToScriptValue(QScriptEngine* engine, ScriptAudioInjector* const& in) {
|
||||||
// when the script goes down we want to cleanup the injector
|
// when the script goes down we want to cleanup the injector
|
||||||
QObject::connect(engine, &QScriptEngine::destroyed, in, &ScriptAudioInjector::stopInjectorImmediately);
|
|
||||||
|
QObject::connect(engine, &QScriptEngine::destroyed, in, &ScriptAudioInjector::stopInjectorImmediately,
|
||||||
|
Qt::DirectConnection);
|
||||||
|
|
||||||
return engine->newQObject(in, QScriptEngine::ScriptOwnership);
|
return engine->newQObject(in, QScriptEngine::ScriptOwnership);
|
||||||
}
|
}
|
||||||
|
@ -36,5 +38,6 @@ ScriptAudioInjector::~ScriptAudioInjector() {
|
||||||
}
|
}
|
||||||
|
|
||||||
void ScriptAudioInjector::stopInjectorImmediately() {
|
void ScriptAudioInjector::stopInjectorImmediately() {
|
||||||
|
qDebug() << "ScriptAudioInjector::stopInjectorImmediately called to stop audio injector immediately.";
|
||||||
_injector->stopAndDeleteLater();
|
_injector->stopAndDeleteLater();
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue