mirror of
https://github.com/overte-org/overte.git
synced 2025-04-15 06:08:22 +02:00
Warn mixer about stopped injectors
This commit is contained in:
parent
b9c81a3899
commit
5102702910
8 changed files with 50 additions and 9 deletions
|
@ -98,7 +98,8 @@ AudioMixer::AudioMixer(ReceivedMessage& message) :
|
||||||
PacketType::RequestsDomainListData,
|
PacketType::RequestsDomainListData,
|
||||||
PacketType::PerAvatarGainSet,
|
PacketType::PerAvatarGainSet,
|
||||||
PacketType::InjectorGainSet,
|
PacketType::InjectorGainSet,
|
||||||
PacketType::AudioSoloRequest },
|
PacketType::AudioSoloRequest,
|
||||||
|
PacketType::StopInjector },
|
||||||
this, "queueAudioPacket");
|
this, "queueAudioPacket");
|
||||||
|
|
||||||
// packets whose consequences are global should be processed on the main thread
|
// packets whose consequences are global should be processed on the main thread
|
||||||
|
@ -246,7 +247,8 @@ void AudioMixer::removeHRTFsForFinishedInjector(const QUuid& streamID) {
|
||||||
|
|
||||||
if (injectorClientData) {
|
if (injectorClientData) {
|
||||||
// stage the removal of this stream, workers handle when preparing mixes for listeners
|
// stage the removal of this stream, workers handle when preparing mixes for listeners
|
||||||
_workerSharedData.removedStreams.emplace_back(injectorClientData->getNodeID(), injectorClientData->getNodeLocalID(),
|
_workerSharedData.removedStreams.emplace_back(injectorClientData->getNodeID(),
|
||||||
|
injectorClientData->getNodeLocalID(),
|
||||||
streamID);
|
streamID);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -104,6 +104,9 @@ int AudioMixerClientData::processPackets(ConcurrentAddedStreams& addedStreams) {
|
||||||
case PacketType::AudioSoloRequest:
|
case PacketType::AudioSoloRequest:
|
||||||
parseSoloRequest(packet, node);
|
parseSoloRequest(packet, node);
|
||||||
break;
|
break;
|
||||||
|
case PacketType::StopInjector:
|
||||||
|
parseStopInjectorPacket(packet);
|
||||||
|
break;
|
||||||
default:
|
default:
|
||||||
Q_UNREACHABLE();
|
Q_UNREACHABLE();
|
||||||
}
|
}
|
||||||
|
@ -574,6 +577,19 @@ int AudioMixerClientData::checkBuffersBeforeFrameSend() {
|
||||||
return (int)_audioStreams.size();
|
return (int)_audioStreams.size();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void AudioMixerClientData::parseStopInjectorPacket(QSharedPointer<ReceivedMessage> packet) {
|
||||||
|
auto streamID = QUuid::fromRfc4122(packet->readWithoutCopy(NUM_BYTES_RFC4122_UUID));
|
||||||
|
|
||||||
|
auto it = std::find_if(std::begin(_audioStreams), std::end(_audioStreams), [&](auto stream) {
|
||||||
|
return streamID == stream->getStreamIdentifier();
|
||||||
|
});
|
||||||
|
|
||||||
|
if (it != std::end(_audioStreams)) {
|
||||||
|
_audioStreams.erase(it);
|
||||||
|
emit injectorStreamFinished(streamID);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
bool AudioMixerClientData::shouldSendStats(int frameNumber) {
|
bool AudioMixerClientData::shouldSendStats(int frameNumber) {
|
||||||
return frameNumber == _frameToSendStats;
|
return frameNumber == _frameToSendStats;
|
||||||
}
|
}
|
||||||
|
|
|
@ -67,12 +67,11 @@ public:
|
||||||
void parseNodeIgnoreRequest(QSharedPointer<ReceivedMessage> message, const SharedNodePointer& node);
|
void parseNodeIgnoreRequest(QSharedPointer<ReceivedMessage> message, const SharedNodePointer& node);
|
||||||
void parseRadiusIgnoreRequest(QSharedPointer<ReceivedMessage> message, const SharedNodePointer& node);
|
void parseRadiusIgnoreRequest(QSharedPointer<ReceivedMessage> message, const SharedNodePointer& node);
|
||||||
void parseSoloRequest(QSharedPointer<ReceivedMessage> message, const SharedNodePointer& node);
|
void parseSoloRequest(QSharedPointer<ReceivedMessage> message, const SharedNodePointer& node);
|
||||||
|
void parseStopInjectorPacket(QSharedPointer<ReceivedMessage> packet);
|
||||||
|
|
||||||
// attempt to pop a frame from each audio stream, and return the number of streams from this client
|
// attempt to pop a frame from each audio stream, and return the number of streams from this client
|
||||||
int checkBuffersBeforeFrameSend();
|
int checkBuffersBeforeFrameSend();
|
||||||
|
|
||||||
void removeDeadInjectedStreams();
|
|
||||||
|
|
||||||
QJsonObject getAudioStreamStats();
|
QJsonObject getAudioStreamStats();
|
||||||
|
|
||||||
void sendAudioStreamStatsPackets(const SharedNodePointer& destinationNode);
|
void sendAudioStreamStatsPackets(const SharedNodePointer& destinationNode);
|
||||||
|
@ -163,7 +162,7 @@ public:
|
||||||
// end of methods called non-concurrently from single AudioMixerSlave
|
// end of methods called non-concurrently from single AudioMixerSlave
|
||||||
|
|
||||||
signals:
|
signals:
|
||||||
void injectorStreamFinished(const QUuid& streamIdentifier);
|
void injectorStreamFinished(const QUuid& streamID);
|
||||||
|
|
||||||
public slots:
|
public slots:
|
||||||
void handleMismatchAudioFormat(SharedNodePointer node, const QString& currentCodec, const QString& recievedCodec);
|
void handleMismatchAudioFormat(SharedNodePointer node, const QString& currentCodec, const QString& recievedCodec);
|
||||||
|
|
|
@ -103,6 +103,8 @@ void AudioInjector::finishLocalInjection() {
|
||||||
|
|
||||||
void AudioInjector::finish() {
|
void AudioInjector::finish() {
|
||||||
withWriteLock([&] {
|
withWriteLock([&] {
|
||||||
|
_state |= AudioInjectorState::LocalInjectionFinished;
|
||||||
|
_state |= AudioInjectorState::NetworkInjectionFinished;
|
||||||
_state |= AudioInjectorState::Finished;
|
_state |= AudioInjectorState::Finished;
|
||||||
});
|
});
|
||||||
emit finished();
|
emit finished();
|
||||||
|
@ -252,7 +254,7 @@ int64_t AudioInjector::injectNextFrame() {
|
||||||
writeStringToStream(noCodecForInjectors, audioPacketStream);
|
writeStringToStream(noCodecForInjectors, audioPacketStream);
|
||||||
|
|
||||||
// pack stream identifier (a generated UUID)
|
// pack stream identifier (a generated UUID)
|
||||||
audioPacketStream << QUuid::createUuid();
|
audioPacketStream << _streamID;
|
||||||
|
|
||||||
// pack the stereo/mono type of the stream
|
// pack the stereo/mono type of the stream
|
||||||
audioPacketStream << options.stereo;
|
audioPacketStream << options.stereo;
|
||||||
|
@ -402,4 +404,17 @@ int64_t AudioInjector::injectNextFrame() {
|
||||||
int64_t playNextFrameAt = ++_nextFrame * AudioConstants::NETWORK_FRAME_USECS;
|
int64_t playNextFrameAt = ++_nextFrame * AudioConstants::NETWORK_FRAME_USECS;
|
||||||
|
|
||||||
return std::max(INT64_C(0), playNextFrameAt - currentTime);
|
return std::max(INT64_C(0), playNextFrameAt - currentTime);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void AudioInjector::sendStopInjectorPacket() {
|
||||||
|
auto nodeList = DependencyManager::get<NodeList>();
|
||||||
|
if (auto audioMixer = nodeList->soloNodeOfType(NodeType::AudioMixer)) {
|
||||||
|
// Build packet
|
||||||
|
auto stopInjectorPacket = NLPacket::create(PacketType::StopInjector);
|
||||||
|
stopInjectorPacket->write(_streamID.toRfc4122());
|
||||||
|
|
||||||
|
// Send packet
|
||||||
|
nodeList->sendUnreliablePacket(*stopInjectorPacket, *audioMixer);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
|
@ -100,6 +100,7 @@ private:
|
||||||
int64_t injectNextFrame();
|
int64_t injectNextFrame();
|
||||||
bool inject(bool(AudioInjectorManager::*injection)(const AudioInjectorPointer&));
|
bool inject(bool(AudioInjectorManager::*injection)(const AudioInjectorPointer&));
|
||||||
bool injectLocally();
|
bool injectLocally();
|
||||||
|
void sendStopInjectorPacket();
|
||||||
|
|
||||||
static AbstractAudioInterface* _localAudioInterface;
|
static AbstractAudioInterface* _localAudioInterface;
|
||||||
|
|
||||||
|
@ -120,6 +121,9 @@ private:
|
||||||
// when the injector is local, we need this
|
// when the injector is local, we need this
|
||||||
AudioHRTF _localHRTF;
|
AudioHRTF _localHRTF;
|
||||||
AudioFOA _localFOA;
|
AudioFOA _localFOA;
|
||||||
|
|
||||||
|
QUuid _streamID { QUuid::createUuid() };
|
||||||
|
|
||||||
friend class AudioInjectorManager;
|
friend class AudioInjectorManager;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
@ -105,6 +105,8 @@ void AudioInjectorManager::run() {
|
||||||
if (nextCallDelta >= 0 && !injector->isFinished()) {
|
if (nextCallDelta >= 0 && !injector->isFinished()) {
|
||||||
// enqueue the injector with the correct timing in our holding queue
|
// enqueue the injector with the correct timing in our holding queue
|
||||||
heldInjectors.emplace(heldInjectors.end(), usecTimestampNow() + nextCallDelta, injector);
|
heldInjectors.emplace(heldInjectors.end(), usecTimestampNow() + nextCallDelta, injector);
|
||||||
|
} else {
|
||||||
|
injector->sendStopInjectorPacket();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -354,4 +356,4 @@ void AudioInjectorManager::stop(const AudioInjectorPointer& injector) {
|
||||||
size_t AudioInjectorManager::getNumInjectors() {
|
size_t AudioInjectorManager::getNumInjectors() {
|
||||||
Lock lock(_injectorsMutex);
|
Lock lock(_injectorsMutex);
|
||||||
return _injectors.size();
|
return _injectors.size();
|
||||||
}
|
}
|
||||||
|
|
|
@ -86,7 +86,8 @@ PacketVersion versionForPacketType(PacketType packetType) {
|
||||||
case PacketType::MicrophoneAudioNoEcho:
|
case PacketType::MicrophoneAudioNoEcho:
|
||||||
case PacketType::MicrophoneAudioWithEcho:
|
case PacketType::MicrophoneAudioWithEcho:
|
||||||
case PacketType::AudioStreamStats:
|
case PacketType::AudioStreamStats:
|
||||||
return static_cast<PacketVersion>(AudioVersion::HighDynamicRangeVolume);
|
case PacketType::StopInjector:
|
||||||
|
return static_cast<PacketVersion>(AudioVersion::StopInjectors);
|
||||||
case PacketType::DomainSettings:
|
case PacketType::DomainSettings:
|
||||||
return 18; // replace min_avatar_scale and max_avatar_scale with min_avatar_height and max_avatar_height
|
return 18; // replace min_avatar_scale and max_avatar_scale with min_avatar_height and max_avatar_height
|
||||||
case PacketType::Ping:
|
case PacketType::Ping:
|
||||||
|
|
|
@ -134,6 +134,7 @@ public:
|
||||||
BulkAvatarTraits,
|
BulkAvatarTraits,
|
||||||
AudioSoloRequest,
|
AudioSoloRequest,
|
||||||
BulkAvatarTraitsAck,
|
BulkAvatarTraitsAck,
|
||||||
|
StopInjector,
|
||||||
NUM_PACKET_TYPE
|
NUM_PACKET_TYPE
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -369,6 +370,7 @@ enum class AudioVersion : PacketVersion {
|
||||||
SpaceBubbleChanges,
|
SpaceBubbleChanges,
|
||||||
HasPersonalMute,
|
HasPersonalMute,
|
||||||
HighDynamicRangeVolume,
|
HighDynamicRangeVolume,
|
||||||
|
StopInjectors
|
||||||
};
|
};
|
||||||
|
|
||||||
enum class MessageDataVersion : PacketVersion {
|
enum class MessageDataVersion : PacketVersion {
|
||||||
|
|
Loading…
Reference in a new issue