mirror of
https://github.com/HifiExperiments/overte.git
synced 2025-08-04 17:43:09 +02:00
Merge pull request #8302 from davidkelly/dk/hotfixForAudio
Hotfix for RC-16: Audio fix for injectors and Assignment Clients
This commit is contained in:
commit
2c3b25cfa7
1 changed files with 23 additions and 24 deletions
|
@ -203,8 +203,8 @@ bool AudioInjector::injectLocally() {
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!success) {
|
if (!success) {
|
||||||
// we never started so we are finished, call our stop method
|
// we never started so we are finished with local injection
|
||||||
stop();
|
finishLocalInjection();
|
||||||
}
|
}
|
||||||
|
|
||||||
return success;
|
return success;
|
||||||
|
@ -217,8 +217,15 @@ static const int64_t NEXT_FRAME_DELTA_IMMEDIATELY = 0;
|
||||||
qint64 writeStringToStream(const QString& string, QDataStream& stream) {
|
qint64 writeStringToStream(const QString& string, QDataStream& stream) {
|
||||||
QByteArray data = string.toUtf8();
|
QByteArray data = string.toUtf8();
|
||||||
uint32_t length = data.length();
|
uint32_t length = data.length();
|
||||||
|
if (length == 0) {
|
||||||
stream << static_cast<quint32>(length);
|
stream << static_cast<quint32>(length);
|
||||||
|
} else {
|
||||||
|
// http://doc.qt.io/qt-5/datastreamformat.html
|
||||||
|
// QDataStream << QByteArray -
|
||||||
|
// If the byte array is null : 0xFFFFFFFF (quint32)
|
||||||
|
// Otherwise : the array size(quint32) followed by the array bytes, i.e.size bytes
|
||||||
stream << data;
|
stream << data;
|
||||||
|
}
|
||||||
return length + sizeof(uint32_t);
|
return length + sizeof(uint32_t);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -301,7 +308,6 @@ int64_t AudioInjector::injectNextFrame() {
|
||||||
volumeOptionOffset = _currentPacket->pos();
|
volumeOptionOffset = _currentPacket->pos();
|
||||||
quint8 volume = MAX_INJECTOR_VOLUME;
|
quint8 volume = MAX_INJECTOR_VOLUME;
|
||||||
audioPacketStream << volume;
|
audioPacketStream << volume;
|
||||||
|
|
||||||
audioPacketStream << _options.ignorePenumbra;
|
audioPacketStream << _options.ignorePenumbra;
|
||||||
|
|
||||||
audioDataOffset = _currentPacket->pos();
|
audioDataOffset = _currentPacket->pos();
|
||||||
|
@ -312,7 +318,6 @@ int64_t AudioInjector::injectNextFrame() {
|
||||||
return NEXT_FRAME_DELTA_ERROR_OR_FINISHED;
|
return NEXT_FRAME_DELTA_ERROR_OR_FINISHED;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!_frameTimer->isValid()) {
|
if (!_frameTimer->isValid()) {
|
||||||
// in the case where we have been restarted, the frame timer will be invalid and we need to start it back over here
|
// in the case where we have been restarted, the frame timer will be invalid and we need to start it back over here
|
||||||
_frameTimer->restart();
|
_frameTimer->restart();
|
||||||
|
@ -418,7 +423,7 @@ void AudioInjector::triggerDeleteAfterFinish() {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (_state == AudioInjectorState::Finished) {
|
if (stateHas(AudioInjectorState::Finished)) {
|
||||||
stopAndDeleteLater();
|
stopAndDeleteLater();
|
||||||
} else {
|
} else {
|
||||||
_state |= AudioInjectorState::PendingDelete;
|
_state |= AudioInjectorState::PendingDelete;
|
||||||
|
@ -484,23 +489,17 @@ AudioInjector* AudioInjector::playSound(const QByteArray& buffer, const AudioInj
|
||||||
// setup parameters required for injection
|
// setup parameters required for injection
|
||||||
injector->setupInjection();
|
injector->setupInjection();
|
||||||
|
|
||||||
// we always inject locally
|
// we always inject locally, except when there is no localInterface
|
||||||
//
|
injector->injectLocally();
|
||||||
if (!injector->injectLocally()) {
|
|
||||||
// failed, so don't bother sending to server
|
|
||||||
qDebug() << "AudioInjector::playSound failed to inject locally";
|
|
||||||
return nullptr;
|
|
||||||
}
|
|
||||||
// if localOnly, we are done, just return injector.
|
// if localOnly, we are done, just return injector.
|
||||||
if (options.localOnly) {
|
if (!options.localOnly) {
|
||||||
return injector;
|
|
||||||
}
|
|
||||||
|
|
||||||
// send off to server for everyone else
|
// send off to server for everyone else
|
||||||
if (!injectorManager->threadInjector(injector)) {
|
if (!injectorManager->threadInjector(injector)) {
|
||||||
// we failed to thread the new injector (we are at the max number of injector threads)
|
// we failed to thread the new injector (we are at the max number of injector threads)
|
||||||
qDebug() << "AudioInjector::playSound failed to thread injector";
|
qDebug() << "AudioInjector::playSound failed to thread injector";
|
||||||
}
|
}
|
||||||
|
}
|
||||||
return injector;
|
return injector;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue