Merge branch 'master' of https://github.com/highfidelity/hifi into temp0

This commit is contained in:
Sam Gateau 2015-02-16 22:08:51 -08:00
commit 11247734d4
7 changed files with 90 additions and 61 deletions

View file

@ -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);

View file

@ -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 *>(&currentSourcePosition), 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, &currentSourcePosition, 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>();

View file

@ -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),

View file

@ -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,6 +339,7 @@ bool OctreePersistThread::getMostRecentBackup(const QString& format,
void OctreePersistThread::rollOldBackupVersions(const BackupRule& rule) {
if (rule.extensionFormat.contains("%N")) {
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;
@ -344,6 +363,11 @@ void OctreePersistThread::rollOldBackupVersions(const BackupRule& rule) {
}
}
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...";
}
}
}
@ -384,6 +408,7 @@ void OctreePersistThread::backup() {
}
if (rule.maxBackupVersions > 0) {
QFile persistFile(_filename);
if (persistFile.exists()) {
qDebug() << "backing up persist file " << _filename << "to" << backupFileName << "...";
@ -398,6 +423,11 @@ void OctreePersistThread::backup() {
qDebug() << "persist file " << _filename << " does not exist. " <<
"nothing to backup for this rule ["<< rule.name << "]...";
}
} else {
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 << "]...";
}

View file

@ -31,18 +31,15 @@ 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;
@ -65,7 +62,7 @@ AudioInjector* AudioScriptingInterface::invokedPlaySound(Sound* sound, const Aud
injectorThread->start();
return injector;
return new ScriptAudioInjector(injector);
} else {
qDebug() << "AudioScriptingInterface::playSound called with null Sound object.";

View file

@ -33,9 +33,6 @@ signals:
void mutedByMixer();
void environmentMuted();
private slots:
AudioInjector* invokedPlaySound(Sound* sound, const AudioInjectorOptions& injectorOptions);
private:
AudioScriptingInterface();
AbstractAudioInterface* _localAudioInterface;

View file

@ -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();
}