mirror of
https://github.com/overte-org/overte.git
synced 2025-04-20 12:04:18 +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) {
|
||||
glm::vec3 position;
|
||||
float radius, distance;
|
||||
float radius;
|
||||
|
||||
int headerSize = numBytesForPacketHeaderGivenPacketType(PacketTypeMuteEnvironment);
|
||||
memcpy(&position, incomingPacket.constData() + headerSize, sizeof(glm::vec3));
|
||||
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);
|
||||
|
||||
mute = mute && (distance < radius);
|
||||
|
|
|
@ -888,13 +888,14 @@ void AudioClient::processReceivedSamples(const QByteArray& inputBuffer, QByteArr
|
|||
|
||||
void AudioClient::sendMuteEnvironmentPacket() {
|
||||
QByteArray mutePacket = byteArrayWithPopulatedHeader(PacketTypeMuteEnvironment);
|
||||
QDataStream mutePacketStream(&mutePacket, QIODevice::Append);
|
||||
int headerSize = mutePacket.size();
|
||||
|
||||
const float MUTE_RADIUS = 50;
|
||||
|
||||
glm::vec3 currentSourcePosition = _positionGetter();
|
||||
mutePacketStream.writeBytes(reinterpret_cast<const char *>(¤tSourcePosition), sizeof(glm::vec3));
|
||||
mutePacketStream.writeBytes(reinterpret_cast<const char *>(&MUTE_RADIUS), sizeof(float));
|
||||
mutePacket.resize(mutePacket.size() + sizeof(glm::vec3) + 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
|
||||
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");
|
||||
|
||||
LimitedNodeList::LimitedNodeList(unsigned short socketListenPort, unsigned short dtlsListenPort) :
|
||||
linkedDataCreateCallback(NULL),
|
||||
_sessionUUID(),
|
||||
_nodeHash(),
|
||||
_nodeMutex(QReadWriteLock::Recursive),
|
||||
|
|
|
@ -49,14 +49,32 @@ void OctreePersistThread::parseSettings(const QJsonObject& settings) {
|
|||
qDebug() << "BACKUP RULES:";
|
||||
|
||||
foreach (const QJsonValue& value, backupRules) {
|
||||
|
||||
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() << " format:" << obj["format"].toString();
|
||||
qDebug() << " interval:" << obj["backupInterval"].toInt();
|
||||
qDebug() << " count:" << obj["maxBackupVersions"].toInt();
|
||||
qDebug() << " interval:" << interval;
|
||||
qDebug() << " count:" << count;
|
||||
|
||||
BackupRule newRule = { obj["Name"].toString(), obj["backupInterval"].toInt(),
|
||||
obj["format"].toString(), obj["maxBackupVersions"].toInt(), 0};
|
||||
BackupRule newRule = { obj["Name"].toString(), interval, obj["format"].toString(), count, 0};
|
||||
|
||||
newRule.lastBackup = getMostRecentBackupTimeInUsecs(obj["format"].toString());
|
||||
|
||||
|
@ -321,29 +339,35 @@ bool OctreePersistThread::getMostRecentBackup(const QString& format,
|
|||
void OctreePersistThread::rollOldBackupVersions(const BackupRule& rule) {
|
||||
|
||||
if (rule.extensionFormat.contains("%N")) {
|
||||
qDebug() << "Rolling old backup versions for rule" << rule.name << "...";
|
||||
for(int n = rule.maxBackupVersions - 1; n > 0; n--) {
|
||||
QString backupExtensionN = rule.extensionFormat;
|
||||
QString backupExtensionNplusOne = rule.extensionFormat;
|
||||
backupExtensionN.replace(QString("%N"), QString::number(n));
|
||||
backupExtensionNplusOne.replace(QString("%N"), QString::number(n+1));
|
||||
if (rule.maxBackupVersions > 0) {
|
||||
qDebug() << "Rolling old backup versions for rule" << rule.name << "...";
|
||||
for(int n = rule.maxBackupVersions - 1; n > 0; n--) {
|
||||
QString backupExtensionN = rule.extensionFormat;
|
||||
QString backupExtensionNplusOne = rule.extensionFormat;
|
||||
backupExtensionN.replace(QString("%N"), QString::number(n));
|
||||
backupExtensionNplusOne.replace(QString("%N"), QString::number(n+1));
|
||||
|
||||
QString backupFilenameN = _filename + backupExtensionN;
|
||||
QString backupFilenameNplusOne = _filename + backupExtensionNplusOne;
|
||||
QString backupFilenameN = _filename + backupExtensionN;
|
||||
QString backupFilenameNplusOne = _filename + backupExtensionNplusOne;
|
||||
|
||||
QFile backupFileN(backupFilenameN);
|
||||
QFile backupFileN(backupFilenameN);
|
||||
|
||||
if (backupFileN.exists()) {
|
||||
qDebug() << "rolling backup file " << backupFilenameN << "to" << backupFilenameNplusOne << "...";
|
||||
int result = rename(qPrintable(backupFilenameN), qPrintable(backupFilenameNplusOne));
|
||||
if (result == 0) {
|
||||
qDebug() << "DONE rolling backup file " << backupFilenameN << "to" << backupFilenameNplusOne << "...";
|
||||
} else {
|
||||
qDebug() << "ERROR in rolling backup file " << backupFilenameN << "to" << backupFilenameNplusOne << "...";
|
||||
if (backupFileN.exists()) {
|
||||
qDebug() << "rolling backup file " << backupFilenameN << "to" << backupFilenameNplusOne << "...";
|
||||
int result = rename(qPrintable(backupFilenameN), qPrintable(backupFilenameNplusOne));
|
||||
if (result == 0) {
|
||||
qDebug() << "DONE rolling backup file " << backupFilenameN << "to" << backupFilenameNplusOne << "...";
|
||||
} else {
|
||||
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 (persistFile.exists()) {
|
||||
qDebug() << "backing up persist file " << _filename << "to" << backupFileName << "...";
|
||||
bool result = QFile::copy(_filename, backupFileName);
|
||||
if (result) {
|
||||
qDebug() << "DONE backing up persist file...";
|
||||
rule.lastBackup = now; // only record successful backup in this case.
|
||||
if (rule.maxBackupVersions > 0) {
|
||||
QFile persistFile(_filename);
|
||||
if (persistFile.exists()) {
|
||||
qDebug() << "backing up persist file " << _filename << "to" << backupFileName << "...";
|
||||
bool result = QFile::copy(_filename, backupFileName);
|
||||
if (result) {
|
||||
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 {
|
||||
qDebug() << "ERROR in backing up persist file...";
|
||||
qDebug() << "persist file " << _filename << " does not exist. " <<
|
||||
"nothing to backup for this rule ["<< rule.name << "]...";
|
||||
}
|
||||
} else {
|
||||
qDebug() << "persist file " << _filename << " does not exist. " <<
|
||||
"nothing to backup for this rule ["<< rule.name << "]...";
|
||||
qDebug() << "This backup rule" << rule.name
|
||||
<< " has Max Rolled Backup Versions less than 1 [" << rule.maxBackupVersions << "]."
|
||||
<< " There are no backups to be done...";
|
||||
}
|
||||
} else {
|
||||
qDebug() << "Backup not needed for this rule ["<< rule.name << "]...";
|
||||
|
|
|
@ -31,44 +31,41 @@ AudioScriptingInterface::AudioScriptingInterface() :
|
|||
}
|
||||
|
||||
ScriptAudioInjector* AudioScriptingInterface::playSound(Sound* sound, const AudioInjectorOptions& injectorOptions) {
|
||||
AudioInjector* injector = NULL;
|
||||
QMetaObject::invokeMethod(this, "invokedPlaySound", Qt::BlockingQueuedConnection,
|
||||
Q_RETURN_ARG(AudioInjector*, injector),
|
||||
Q_ARG(Sound*, sound), Q_ARG(const AudioInjectorOptions&, injectorOptions));
|
||||
if (injector) {
|
||||
return new ScriptAudioInjector(injector);
|
||||
} else {
|
||||
return NULL;
|
||||
if (QThread::currentThread() != thread()) {
|
||||
ScriptAudioInjector* injector = NULL;
|
||||
|
||||
QMetaObject::invokeMethod(this, "playSound", Qt::BlockingQueuedConnection,
|
||||
Q_RETURN_ARG(ScriptAudioInjector*, injector),
|
||||
Q_ARG(Sound*, sound), Q_ARG(const AudioInjectorOptions&, injectorOptions));
|
||||
return injector;
|
||||
}
|
||||
}
|
||||
|
||||
AudioInjector* AudioScriptingInterface::invokedPlaySound(Sound* sound, const AudioInjectorOptions& injectorOptions) {
|
||||
|
||||
if (sound) {
|
||||
// stereo option isn't set from script, this comes from sound metadata or filename
|
||||
AudioInjectorOptions optionsCopy = injectorOptions;
|
||||
optionsCopy.stereo = sound->isStereo();
|
||||
|
||||
|
||||
QThread* injectorThread = new QThread();
|
||||
injectorThread->setObjectName("Audio Injector Thread");
|
||||
|
||||
|
||||
AudioInjector* injector = new AudioInjector(sound, optionsCopy);
|
||||
injector->setLocalAudioInterface(_localAudioInterface);
|
||||
|
||||
|
||||
injector->moveToThread(injectorThread);
|
||||
|
||||
|
||||
// start injecting when the injector thread starts
|
||||
connect(injectorThread, &QThread::started, injector, &AudioInjector::injectAudio);
|
||||
|
||||
|
||||
// connect the right slots and signals for AudioInjector and thread cleanup
|
||||
connect(injector, &AudioInjector::destroyed, injectorThread, &QThread::quit);
|
||||
connect(injectorThread, &QThread::finished, injectorThread, &QThread::deleteLater);
|
||||
|
||||
|
||||
injectorThread->start();
|
||||
|
||||
return injector;
|
||||
|
||||
|
||||
return new ScriptAudioInjector(injector);
|
||||
|
||||
} else {
|
||||
qDebug() << "AudioScriptingInterface::playSound called with null Sound object.";
|
||||
return NULL;
|
||||
}
|
||||
}
|
||||
}
|
|
@ -32,9 +32,6 @@ protected:
|
|||
signals:
|
||||
void mutedByMixer();
|
||||
void environmentMuted();
|
||||
|
||||
private slots:
|
||||
AudioInjector* invokedPlaySound(Sound* sound, const AudioInjectorOptions& injectorOptions);
|
||||
|
||||
private:
|
||||
AudioScriptingInterface();
|
||||
|
|
|
@ -13,7 +13,9 @@
|
|||
|
||||
QScriptValue injectorToScriptValue(QScriptEngine* engine, ScriptAudioInjector* const& in) {
|
||||
// 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);
|
||||
}
|
||||
|
@ -36,5 +38,6 @@ ScriptAudioInjector::~ScriptAudioInjector() {
|
|||
}
|
||||
|
||||
void ScriptAudioInjector::stopInjectorImmediately() {
|
||||
qDebug() << "ScriptAudioInjector::stopInjectorImmediately called to stop audio injector immediately.";
|
||||
_injector->stopAndDeleteLater();
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue