mirror of
https://github.com/overte-org/overte.git
synced 2025-04-20 04:44:11 +02:00
Set a minimum mute intervalle in the mixer
This commit is contained in:
parent
125ef0e3e2
commit
02b401701f
4 changed files with 27 additions and 17 deletions
|
@ -719,20 +719,25 @@ void AudioMixer::run() {
|
|||
|
||||
// if the stream should be muted, send mute packet
|
||||
if (shouldMute(nodeData->getAvatarAudioStream()->getQuietestFrameLoudness())) {
|
||||
int headerSize = numBytesForPacketHeaderGivenPacketType(PacketTypeMuteEnvironment);
|
||||
int packetSize = headerSize + sizeof(glm::vec3) + sizeof(float);
|
||||
|
||||
// Fake data to force mute
|
||||
glm::vec3 position = nodeData->getAvatarAudioStream()->getPosition();
|
||||
float radius = 1.0f;
|
||||
|
||||
char* packet = (char*)malloc(packetSize);
|
||||
populatePacketHeader(packet, PacketTypeMuteEnvironment);
|
||||
memcpy(packet + headerSize, &position, sizeof(glm::vec3));
|
||||
memcpy(packet + headerSize + sizeof(glm::vec3), &radius, sizeof(float));
|
||||
|
||||
nodeList->writeDatagram(packet, packetSize, node);
|
||||
free(packet);
|
||||
static const int TIME_BETWEEN_MUTES = 5; // in secs
|
||||
if (usecTimestampNow() - nodeData->getAvatarAudioStream()->getLastMuted() >
|
||||
TIME_BETWEEN_MUTES * USECS_PER_SECOND) {
|
||||
int headerSize = numBytesForPacketHeaderGivenPacketType(PacketTypeMuteEnvironment);
|
||||
int packetSize = headerSize + sizeof(glm::vec3) + sizeof(float);
|
||||
|
||||
// Fake data to force mute
|
||||
glm::vec3 position = nodeData->getAvatarAudioStream()->getPosition();
|
||||
float radius = 1.0f;
|
||||
|
||||
char* packet = (char*)malloc(packetSize);
|
||||
populatePacketHeader(packet, PacketTypeMuteEnvironment);
|
||||
memcpy(packet + headerSize, &position, sizeof(glm::vec3));
|
||||
memcpy(packet + headerSize + sizeof(glm::vec3), &radius, sizeof(float));
|
||||
|
||||
nodeList->writeDatagram(packet, packetSize, node);
|
||||
nodeData->getAvatarAudioStream()->setLastMutedNow();
|
||||
free(packet);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -14,7 +14,8 @@
|
|||
#include "AvatarAudioStream.h"
|
||||
|
||||
AvatarAudioStream::AvatarAudioStream(bool isStereo, const InboundAudioStream::Settings& settings) :
|
||||
PositionalAudioStream(PositionalAudioStream::Microphone, isStereo, settings)
|
||||
PositionalAudioStream(PositionalAudioStream::Microphone, isStereo, settings),
|
||||
_lastMuted(usecTimestampNow())
|
||||
{
|
||||
}
|
||||
|
||||
|
|
|
@ -19,13 +19,18 @@
|
|||
class AvatarAudioStream : public PositionalAudioStream {
|
||||
public:
|
||||
AvatarAudioStream(bool isStereo, const InboundAudioStream::Settings& settings);
|
||||
|
||||
|
||||
qint64 getLastMuted() const { return _lastMuted; }
|
||||
void setLastMutedNow() { _lastMuted = usecTimestampNow(); }
|
||||
|
||||
private:
|
||||
// disallow copying of AvatarAudioStream objects
|
||||
AvatarAudioStream(const AvatarAudioStream&);
|
||||
AvatarAudioStream& operator= (const AvatarAudioStream&);
|
||||
|
||||
int parseStreamProperties(PacketType type, const QByteArray& packetAfterSeqNum, int& numAudioSamples);
|
||||
|
||||
qint64 _lastMuted;
|
||||
};
|
||||
|
||||
#endif // hifi_AvatarAudioStream_h
|
||||
|
|
|
@ -1409,7 +1409,6 @@ void Audio::renderToolBox(int x, int y, bool boxed) {
|
|||
float t = (float)(now - _iconPulseTimeReference) / (float)USECS_PER_SECOND;
|
||||
float pulseFactor = (glm::cos(t * PULSE_FREQUENCY * 2.0f * PI) + 1.0f) / 2.0f;
|
||||
_iconColor = PULSE_MIN + (PULSE_MAX - PULSE_MIN) * pulseFactor;
|
||||
|
||||
}
|
||||
|
||||
glColor3f(_iconColor, _iconColor, _iconColor);
|
||||
|
|
Loading…
Reference in a new issue