mirror of
https://github.com/HifiExperiments/overte.git
synced 2025-08-09 22:28:48 +02:00
First try
AudioMixer has same issue transitioning from silence to encoded audio and back, it seems. This makes that go away, but I don't like it. Better to support a flush function in the encoder but for now lets do this and be sure it is the entire issue.
This commit is contained in:
parent
15ee56a50f
commit
6a61762659
3 changed files with 20 additions and 0 deletions
|
@ -819,6 +819,9 @@ void AudioMixer::broadcastMixes() {
|
||||||
std::unique_ptr<NLPacket> mixPacket;
|
std::unique_ptr<NLPacket> mixPacket;
|
||||||
|
|
||||||
if (mixHasAudio) {
|
if (mixHasAudio) {
|
||||||
|
// may need to flush, this checks
|
||||||
|
nodeData->flushEncoder();
|
||||||
|
|
||||||
int mixPacketBytes = sizeof(quint16) + AudioConstants::MAX_CODEC_NAME_LENGTH_ON_WIRE
|
int mixPacketBytes = sizeof(quint16) + AudioConstants::MAX_CODEC_NAME_LENGTH_ON_WIRE
|
||||||
+ AudioConstants::NETWORK_FRAME_BYTES_STEREO;
|
+ AudioConstants::NETWORK_FRAME_BYTES_STEREO;
|
||||||
mixPacket = NLPacket::create(PacketType::MixedAudio, mixPacketBytes);
|
mixPacket = NLPacket::create(PacketType::MixedAudio, mixPacketBytes);
|
||||||
|
@ -852,6 +855,9 @@ void AudioMixer::broadcastMixes() {
|
||||||
// pack number of silent audio samples
|
// pack number of silent audio samples
|
||||||
quint16 numSilentSamples = AudioConstants::NETWORK_FRAME_SAMPLES_STEREO;
|
quint16 numSilentSamples = AudioConstants::NETWORK_FRAME_SAMPLES_STEREO;
|
||||||
mixPacket->writePrimitive(numSilentSamples);
|
mixPacket->writePrimitive(numSilentSamples);
|
||||||
|
|
||||||
|
// we will need to flush encoder since we are sending silent packets outside it
|
||||||
|
nodeData->shouldFlushEncoder();
|
||||||
}
|
}
|
||||||
|
|
||||||
// Send audio environment
|
// Send audio environment
|
||||||
|
|
|
@ -366,6 +366,16 @@ void AudioMixerClientData::sendSelectAudioFormat(SharedNodePointer node, const Q
|
||||||
nodeList->sendPacket(std::move(replyPacket), *node);
|
nodeList->sendPacket(std::move(replyPacket), *node);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void AudioMixerClientData::flushEncoder() {
|
||||||
|
static QByteArray zeros(AudioConstants::NETWORK_FRAME_BYTES_STEREO, 0);
|
||||||
|
static QByteArray encodedZeros;
|
||||||
|
if (_shouldFlushEncoder) {
|
||||||
|
_shouldFlushEncoder = false;
|
||||||
|
if (_encoder) {
|
||||||
|
_encoder->encode(zeros, encodedZeros);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
void AudioMixerClientData::setupCodec(CodecPluginPointer codec, const QString& codecName) {
|
void AudioMixerClientData::setupCodec(CodecPluginPointer codec, const QString& codecName) {
|
||||||
cleanupCodec(); // cleanup any previously allocated coders first
|
cleanupCodec(); // cleanup any previously allocated coders first
|
||||||
|
|
|
@ -77,6 +77,8 @@ public:
|
||||||
encodedBuffer = decodedBuffer;
|
encodedBuffer = decodedBuffer;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
void flushEncoder();
|
||||||
|
void shouldFlushEncoder() { _shouldFlushEncoder = true; }
|
||||||
|
|
||||||
QString getCodecName() { return _selectedCodecName; }
|
QString getCodecName() { return _selectedCodecName; }
|
||||||
|
|
||||||
|
@ -105,6 +107,8 @@ private:
|
||||||
QString _selectedCodecName;
|
QString _selectedCodecName;
|
||||||
Encoder* _encoder{ nullptr }; // for outbound mixed stream
|
Encoder* _encoder{ nullptr }; // for outbound mixed stream
|
||||||
Decoder* _decoder{ nullptr }; // for mic stream
|
Decoder* _decoder{ nullptr }; // for mic stream
|
||||||
|
|
||||||
|
bool _shouldFlushEncoder { false };
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif // hifi_AudioMixerClientData_h
|
#endif // hifi_AudioMixerClientData_h
|
||||||
|
|
Loading…
Reference in a new issue