mirror of
https://github.com/overte-org/overte.git
synced 2025-08-09 23:14:34 +02:00
add packet queue to AudioMixerClientData
This commit is contained in:
parent
442e8d68ef
commit
2f457ae891
4 changed files with 32 additions and 7 deletions
|
@ -323,6 +323,7 @@ void AudioMixer::sendStatsPacket() {
|
||||||
addTiming(_prepareTiming, "prepare");
|
addTiming(_prepareTiming, "prepare");
|
||||||
addTiming(_mixTiming, "mix");
|
addTiming(_mixTiming, "mix");
|
||||||
addTiming(_eventsTiming, "events");
|
addTiming(_eventsTiming, "events");
|
||||||
|
addTiming(_packetsTiming, "packets");
|
||||||
|
|
||||||
#ifdef HIFI_AUDIO_MIXER_DEBUG
|
#ifdef HIFI_AUDIO_MIXER_DEBUG
|
||||||
timingStats["ns_per_mix"] = (_stats.totalMixes > 0) ? (float)(_stats.mixTime / _stats.totalMixes) : 0;
|
timingStats["ns_per_mix"] = (_stats.totalMixes > 0) ? (float)(_stats.mixTime / _stats.totalMixes) : 0;
|
||||||
|
@ -452,18 +453,27 @@ void AudioMixer::start() {
|
||||||
++frame;
|
++frame;
|
||||||
++_numStatFrames;
|
++_numStatFrames;
|
||||||
|
|
||||||
// play nice with qt event-looping
|
// process queued events (networking, &c.)
|
||||||
{
|
{
|
||||||
auto eventsTimer = _eventsTiming.timer();
|
auto eventsTimer = _eventsTiming.timer();
|
||||||
|
|
||||||
// since we're a while loop we need to yield to qt's event processing
|
// since we're a while loop we need to yield to qt's event processing
|
||||||
QCoreApplication::processEvents();
|
QCoreApplication::processEvents();
|
||||||
|
}
|
||||||
|
|
||||||
if (_isFinished) {
|
// process audio packets
|
||||||
// alert qt eventing that this is finished
|
{
|
||||||
QCoreApplication::sendPostedEvents(this, QEvent::DeferredDelete);
|
auto packetsTimer = _packetsTiming.timer();
|
||||||
break;
|
nodeList->eachNode([&](SharedNodePointer& node) {
|
||||||
}
|
AudioMixerClientData* data = getOrCreateClientData(node.data());
|
||||||
|
data->processPackets();
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
if (_isFinished) {
|
||||||
|
// alert qt eventing that this is finished
|
||||||
|
QCoreApplication::sendPostedEvents(this, QEvent::DeferredDelete);
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -124,6 +124,7 @@ private:
|
||||||
Timer _prepareTiming;
|
Timer _prepareTiming;
|
||||||
Timer _mixTiming;
|
Timer _mixTiming;
|
||||||
Timer _eventsTiming;
|
Timer _eventsTiming;
|
||||||
|
Timer _packetsTiming;
|
||||||
|
|
||||||
static int _numStaticJitterFrames; // -1 denotes dynamic jitter buffering
|
static int _numStaticJitterFrames; // -1 denotes dynamic jitter buffering
|
||||||
static float _noiseMutingThreshold;
|
static float _noiseMutingThreshold;
|
||||||
|
|
|
@ -47,6 +47,14 @@ AudioMixerClientData::~AudioMixerClientData() {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void AudioMixerClientData::queuePacket(QSharedPointer<ReceivedMessage> packet) {
|
||||||
|
_queuedPackets.push(packet);
|
||||||
|
}
|
||||||
|
|
||||||
|
void AudioMixerClientData::processPackets() {
|
||||||
|
// TODO: process the queue
|
||||||
|
assert(_queuedPackets.empty());
|
||||||
|
}
|
||||||
|
|
||||||
AvatarAudioStream* AudioMixerClientData::getAvatarAudioStream() {
|
AvatarAudioStream* AudioMixerClientData::getAvatarAudioStream() {
|
||||||
QReadLocker readLocker { &_streamsLock };
|
QReadLocker readLocker { &_streamsLock };
|
||||||
|
|
|
@ -12,6 +12,8 @@
|
||||||
#ifndef hifi_AudioMixerClientData_h
|
#ifndef hifi_AudioMixerClientData_h
|
||||||
#define hifi_AudioMixerClientData_h
|
#define hifi_AudioMixerClientData_h
|
||||||
|
|
||||||
|
#include <queue>
|
||||||
|
|
||||||
#include <QtCore/QJsonObject>
|
#include <QtCore/QJsonObject>
|
||||||
|
|
||||||
#include <AABox.h>
|
#include <AABox.h>
|
||||||
|
@ -34,6 +36,9 @@ public:
|
||||||
using SharedStreamPointer = std::shared_ptr<PositionalAudioStream>;
|
using SharedStreamPointer = std::shared_ptr<PositionalAudioStream>;
|
||||||
using AudioStreamMap = std::unordered_map<QUuid, SharedStreamPointer>;
|
using AudioStreamMap = std::unordered_map<QUuid, SharedStreamPointer>;
|
||||||
|
|
||||||
|
void queuePacket(QSharedPointer<ReceivedMessage> packet);
|
||||||
|
void processPackets();
|
||||||
|
|
||||||
// locks the mutex to make a copy
|
// locks the mutex to make a copy
|
||||||
AudioStreamMap getAudioStreams() { QReadLocker readLock { &_streamsLock }; return _audioStreams; }
|
AudioStreamMap getAudioStreams() { QReadLocker readLock { &_streamsLock }; return _audioStreams; }
|
||||||
AvatarAudioStream* getAvatarAudioStream();
|
AvatarAudioStream* getAvatarAudioStream();
|
||||||
|
@ -105,11 +110,12 @@ public slots:
|
||||||
void sendSelectAudioFormat(SharedNodePointer node, const QString& selectedCodecName);
|
void sendSelectAudioFormat(SharedNodePointer node, const QString& selectedCodecName);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
using IgnoreZone = AABox;
|
std::queue<QSharedPointer<ReceivedMessage>> _queuedPackets;
|
||||||
|
|
||||||
QReadWriteLock _streamsLock;
|
QReadWriteLock _streamsLock;
|
||||||
AudioStreamMap _audioStreams; // microphone stream from avatar is stored under key of null UUID
|
AudioStreamMap _audioStreams; // microphone stream from avatar is stored under key of null UUID
|
||||||
|
|
||||||
|
using IgnoreZone = AABox;
|
||||||
class IgnoreZoneMemo {
|
class IgnoreZoneMemo {
|
||||||
public:
|
public:
|
||||||
IgnoreZoneMemo(AudioMixerClientData& data) : _data(data) {}
|
IgnoreZoneMemo(AudioMixerClientData& data) : _data(data) {}
|
||||||
|
|
Loading…
Reference in a new issue