mirror of
https://github.com/HifiExperiments/overte.git
synced 2025-08-05 05:34:20 +02:00
Hack in a 100hz timer
sounds crappy, more to do, just push to not lose anything. <squash this>
This commit is contained in:
parent
95aa18f66d
commit
b4c064a538
2 changed files with 12 additions and 8 deletions
|
@ -373,8 +373,13 @@ void Agent::executeScript() {
|
|||
|
||||
DependencyManager::set<AssignmentParentFinder>(_entityViewer.getTree());
|
||||
|
||||
_avatarAudioTimer = new QTimer(this);
|
||||
_avatarAudioTimer->setTimerType(Qt::PreciseTimer);
|
||||
connect(_avatarAudioTimer, SIGNAL(timeout()), this, SLOT(processAgentAvatarAndAudio()));
|
||||
_avatarAudioTimer->start(10);
|
||||
|
||||
// wire up our additional agent related processing to the update signal
|
||||
QObject::connect(_scriptEngine.get(), &ScriptEngine::update, this, &Agent::processAgentAvatarAndAudio);
|
||||
//QObject::connect(_scriptEngine.get(), &ScriptEngine::update, this, &Agent::processAgentAvatarAndAudio);
|
||||
|
||||
_scriptEngine->run();
|
||||
|
||||
|
@ -420,10 +425,10 @@ void Agent::sendAvatarIdentityPacket() {
|
|||
}
|
||||
}
|
||||
|
||||
void Agent::processAgentAvatarAndAudio(float deltaTime) {
|
||||
void Agent::processAgentAvatarAndAudio() {
|
||||
if (!_scriptEngine->isFinished() && _isAvatar) {
|
||||
auto scriptedAvatar = DependencyManager::get<ScriptableAvatar>();
|
||||
const int SCRIPT_AUDIO_BUFFER_SAMPLES = AudioConstants::SAMPLE_RATE / SCRIPT_FPS + 0.5;
|
||||
const int SCRIPT_AUDIO_BUFFER_SAMPLES = AudioConstants::SAMPLE_RATE / 100;//SCRIPT_FPS + 0.5;
|
||||
const int SCRIPT_AUDIO_BUFFER_BYTES = SCRIPT_AUDIO_BUFFER_SAMPLES * sizeof(int16_t);
|
||||
|
||||
QByteArray avatarByteArray = scriptedAvatar->toByteArray(true, randFloat() < AVATAR_SEND_FULL_UPDATE_RATIO);
|
||||
|
@ -513,10 +518,9 @@ void Agent::processAgentAvatarAndAudio(float deltaTime) {
|
|||
if (_encoder) {
|
||||
_encoder->encode(decodedBuffer, encodedBuffer);
|
||||
} else {
|
||||
encodedBuffer = decodedBuffer;
|
||||
audioPacket->write(decodedBuffer.data(), decodedBuffer.size());
|
||||
}
|
||||
|
||||
|
||||
// write the raw audio data
|
||||
audioPacket->write(encodedBuffer.data(), encodedBuffer.size());
|
||||
}
|
||||
|
|
|
@ -18,6 +18,7 @@
|
|||
#include <QtScript/QScriptEngine>
|
||||
#include <QtCore/QObject>
|
||||
#include <QtCore/QUrl>
|
||||
#include <QtCore/QTimer>
|
||||
#include <QUuid>
|
||||
|
||||
#include <EntityEditPacketSender.h>
|
||||
|
@ -70,7 +71,7 @@ private slots:
|
|||
void handleJurisdictionPacket(QSharedPointer<ReceivedMessage> message, SharedNodePointer senderNode);
|
||||
void handleSelectedAudioFormat(QSharedPointer<ReceivedMessage> message);
|
||||
|
||||
void processAgentAvatarAndAudio(float deltaTime);
|
||||
void processAgentAvatarAndAudio();
|
||||
void nodeActivated(SharedNodePointer activatedNode);
|
||||
|
||||
private:
|
||||
|
@ -101,8 +102,7 @@ private:
|
|||
CodecPluginPointer _codec;
|
||||
QString _selectedCodecName;
|
||||
Encoder* _encoder { nullptr };
|
||||
|
||||
|
||||
QTimer* _avatarAudioTimer;
|
||||
};
|
||||
|
||||
#endif // hifi_Agent_h
|
||||
|
|
Loading…
Reference in a new issue