fixes to silent audio frame sending

This commit is contained in:
Stephen Birarda 2014-03-17 16:27:49 -07:00
parent 9f24bd9c47
commit 61594b9a1e
5 changed files with 12 additions and 9 deletions

View file

@ -322,7 +322,8 @@ void AudioMixer::readPendingDatagrams() {
PacketType mixerPacketType = packetTypeForPacket(receivedPacket);
if (mixerPacketType == PacketTypeMicrophoneAudioNoEcho
|| mixerPacketType == PacketTypeMicrophoneAudioWithEcho
|| mixerPacketType == PacketTypeInjectAudio) {
|| mixerPacketType == PacketTypeInjectAudio
|| mixerPacketType == PacketTypeSilentAudioFrame) {
nodeList->findNodeAndUpdateWithDataFromPacket(receivedPacket);
} else {

View file

@ -41,7 +41,8 @@ AvatarAudioRingBuffer* AudioMixerClientData::getAvatarAudioRingBuffer() const {
int AudioMixerClientData::parseData(const QByteArray& packet) {
PacketType packetType = packetTypeForPacket(packet);
if (packetType == PacketTypeMicrophoneAudioWithEcho
|| packetType == PacketTypeMicrophoneAudioNoEcho) {
|| packetType == PacketTypeMicrophoneAudioNoEcho
|| packetType == PacketTypeSilentAudioFrame) {
// grab the AvatarAudioRingBuffer from the vector (or create it if it doesn't exist)
AvatarAudioRingBuffer* avatarRingBuffer = getAvatarAudioRingBuffer();

View file

@ -436,7 +436,7 @@ void Audio::handleAudioInput() {
}
}
if (!_noiseGateOpen) {
memset(monoAudioSamples, 0, NETWORK_BUFFER_LENGTH_SAMPLES_PER_CHANNEL);
memset(monoAudioSamples, 0, NETWORK_BUFFER_LENGTH_BYTES_PER_CHANNEL);
_lastInputLoudness = 0;
}
}
@ -450,7 +450,7 @@ void Audio::handleAudioInput() {
// our input loudness is 0, since we're muted
_lastInputLoudness = 0;
}
// add procedural effects to the appropriate input samples
addProceduralSounds(monoAudioSamples,
NETWORK_BUFFER_LENGTH_SAMPLES_PER_CHANNEL);
@ -486,7 +486,7 @@ void Audio::handleAudioInput() {
PacketType packetType;
if (_lastInputLoudness == 0) {
packetType = PacketTypeSilentAudioListener;
packetType = PacketTypeSilentAudioFrame;
// we need to indicate how many silent samples this is to the audio mixer
monoAudioSamples[0] = NETWORK_BUFFER_LENGTH_SAMPLES_PER_CHANNEL;
@ -515,7 +515,7 @@ void Audio::handleAudioInput() {
nodeList->writeDatagram(monoAudioDataPacket, numAudioBytes + leadingBytes, audioMixer);
Application::getInstance()->getBandwidthMeter()->outputStream(BandwidthMeter::AUDIO)
.updateValue(NETWORK_BUFFER_LENGTH_BYTES_PER_CHANNEL + leadingBytes);
.updateValue(numAudioBytes + leadingBytes);
}
delete[] inputAudioSamples;
}

View file

@ -45,11 +45,12 @@ int PositionalAudioRingBuffer::parseData(const QByteArray& packet) {
packetStream.skipRawData(parsePositionalData(packet.mid(packetStream.device()->pos())));
if (packetTypeForPacket(packet) == PacketTypeSilentAudioListener) {
if (packetTypeForPacket(packet) == PacketTypeSilentAudioFrame) {
// this source had no audio to send us, but this counts as a packet
// write silence equivalent to the number of silent samples they just sent us
int16_t numSilentSamples;
packetStream >> numSilentSamples;
packetStream.readRawData(reinterpret_cast<char*>(&numSilentSamples), sizeof(int16_t));
addSilentFrame(numSilentSamples);
} else {
// there is audio data to read

View file

@ -32,7 +32,7 @@ enum PacketType {
PacketTypeMicrophoneAudioNoEcho,
PacketTypeMicrophoneAudioWithEcho,
PacketTypeBulkAvatarData,
PacketTypeSilentAudioListener,
PacketTypeSilentAudioFrame,
PacketTypeEnvironmentData,
PacketTypeDomainListRequest,
PacketTypeRequestAssignment,