mirror of
https://github.com/Armored-Dragon/overte.git
synced 2025-03-11 16:13:16 +01:00
change stream HRTF map to use a vector
This commit is contained in:
parent
bcba2a1cf1
commit
c992150c10
2 changed files with 29 additions and 4 deletions
|
@ -226,11 +226,31 @@ AvatarAudioStream* AudioMixerClientData::getAvatarAudioStream() {
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
AudioHRTF& AudioMixerClientData::hrtfForStream(Node::LocalID nodeID, const QUuid& streamID) {
|
||||||
|
auto& hrtfVector = _nodeSourcesHRTFMap[nodeID];
|
||||||
|
|
||||||
|
auto streamIt = std::find_if(hrtfVector.begin(), hrtfVector.end(), [&streamID](IdentifiedHRTF& identifiedHRTF){
|
||||||
|
return identifiedHRTF.streamIdentifier == streamID;
|
||||||
|
});
|
||||||
|
|
||||||
|
if (streamIt == hrtfVector.end()) {
|
||||||
|
hrtfVector.push_back({ streamID, std::unique_ptr<AudioHRTF>(new AudioHRTF) });
|
||||||
|
|
||||||
|
return *hrtfVector.back().hrtf;
|
||||||
|
} else {
|
||||||
|
return *streamIt->hrtf;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
void AudioMixerClientData::removeHRTFForStream(Node::LocalID nodeID, const QUuid& streamID) {
|
void AudioMixerClientData::removeHRTFForStream(Node::LocalID nodeID, const QUuid& streamID) {
|
||||||
auto it = _nodeSourcesHRTFMap.find(nodeID);
|
auto it = _nodeSourcesHRTFMap.find(nodeID);
|
||||||
if (it != _nodeSourcesHRTFMap.end()) {
|
if (it != _nodeSourcesHRTFMap.end()) {
|
||||||
|
auto streamIt = std::find_if(it->second.begin(), it->second.end(), [&streamID](IdentifiedHRTF& identifiedHRTF){
|
||||||
|
return identifiedHRTF.streamIdentifier == streamID;
|
||||||
|
});
|
||||||
|
|
||||||
// erase the stream with the given ID from the given node
|
// erase the stream with the given ID from the given node
|
||||||
it->second.erase(streamID);
|
it->second.erase(streamIt);
|
||||||
|
|
||||||
// is the map for this node now empty?
|
// is the map for this node now empty?
|
||||||
// if so we can remove it
|
// if so we can remove it
|
||||||
|
|
|
@ -50,7 +50,7 @@ public:
|
||||||
// they are not thread-safe
|
// they are not thread-safe
|
||||||
|
|
||||||
// returns a new or existing HRTF object for the given stream from the given node
|
// returns a new or existing HRTF object for the given stream from the given node
|
||||||
AudioHRTF& hrtfForStream(Node::LocalID nodeID, const QUuid& streamID = QUuid()) { return _nodeSourcesHRTFMap[nodeID][streamID]; }
|
AudioHRTF& hrtfForStream(Node::LocalID nodeID, const QUuid& streamID = QUuid());
|
||||||
|
|
||||||
// removes an AudioHRTF object for a given stream
|
// removes an AudioHRTF object for a given stream
|
||||||
void removeHRTFForStream(Node::LocalID nodeID, const QUuid& streamID = QUuid());
|
void removeHRTFForStream(Node::LocalID nodeID, const QUuid& streamID = QUuid());
|
||||||
|
@ -152,8 +152,13 @@ private:
|
||||||
};
|
};
|
||||||
IgnoreZoneMemo _ignoreZone;
|
IgnoreZoneMemo _ignoreZone;
|
||||||
|
|
||||||
using HRTFMap = std::unordered_map<QUuid, AudioHRTF>;
|
struct IdentifiedHRTF {
|
||||||
using NodeSourcesHRTFMap = std::unordered_map<Node::LocalID, HRTFMap>;
|
QUuid streamIdentifier;
|
||||||
|
std::unique_ptr<AudioHRTF> hrtf;
|
||||||
|
};
|
||||||
|
|
||||||
|
using HRTFVector = std::vector<IdentifiedHRTF>;
|
||||||
|
using NodeSourcesHRTFMap = std::unordered_map<Node::LocalID, HRTFVector>;
|
||||||
NodeSourcesHRTFMap _nodeSourcesHRTFMap;
|
NodeSourcesHRTFMap _nodeSourcesHRTFMap;
|
||||||
|
|
||||||
quint16 _outgoingMixedAudioSequenceNumber;
|
quint16 _outgoingMixedAudioSequenceNumber;
|
||||||
|
|
Loading…
Reference in a new issue