BUGZ-85 - audio pipeline interpolation on ring buffer starve

Kick the PLC so that it generates a more pleasing 'fade' frame
when ring buffer starves.
This commit is contained in:
Roxanne Skelly 2019-05-06 15:46:06 -07:00
parent 4ee39355f1
commit 4a4a92c009
3 changed files with 12 additions and 6 deletions

View file

@ -1491,7 +1491,7 @@ AudioSRC::~AudioSRC() {
//
int AudioSRC::render(const int16_t* input, int16_t* output, int inputFrames) {
int outputFrames = 0;
QMutexLocker lock(&_renderMutex);
while (inputFrames) {
int ni = MIN(inputFrames, _inputBlock);
@ -1516,7 +1516,7 @@ int AudioSRC::render(const int16_t* input, int16_t* output, int inputFrames) {
//
int AudioSRC::render(const float* input, float* output, int inputFrames) {
int outputFrames = 0;
QMutexLocker lock(&_renderMutex);
while (inputFrames) {
int ni = MIN(inputFrames, _inputBlock);

View file

@ -13,6 +13,7 @@
#define hifi_AudioSRC_h
#include <stdint.h>
#include <QMutex>
static const int SRC_MAX_CHANNELS = 4;
@ -55,6 +56,8 @@ public:
int getMaxInput(int outputFrames);
private:
QMutex _renderMutex;
float* _polyphaseFilter;
int* _stepTable;

View file

@ -215,7 +215,6 @@ int InboundAudioStream::parseData(ReceivedMessage& message) {
if (framesAvailable > _desiredJitterBufferFrames + MAX_FRAMES_OVER_DESIRED) {
int framesToDrop = framesAvailable - (_desiredJitterBufferFrames + DESIRED_JITTER_BUFFER_FRAMES_PADDING);
_ringBuffer.shiftReadPosition(framesToDrop * _ringBuffer.getNumFrameSamples());
_framesAvailableStat.reset();
_currentJitterBufferFrames = 0;
@ -250,7 +249,7 @@ int InboundAudioStream::lostAudioData(int numPackets) {
if (_decoder) {
_decoder->lostFrame(decodedBuffer);
} else {
decodedBuffer.resize(AudioConstants::NETWORK_FRAME_BYTES_STEREO);
decodedBuffer.resize(AudioConstants::NETWORK_FRAME_BYTES_PER_CHANNEL * _numChannels);
memset(decodedBuffer.data(), 0, decodedBuffer.size());
}
_ringBuffer.writeData(decodedBuffer.data(), decodedBuffer.size());
@ -338,10 +337,14 @@ int InboundAudioStream::popSamples(int maxSamples, bool allOrNothing) {
popSamplesNoCheck(samplesAvailable);
samplesPopped = samplesAvailable;
} else {
// we can't pop any samples, set this stream to starved
// we can't pop any samples, set this stream to starved for jitter
// buffer calculations.
setToStarved();
_consecutiveNotMixedCount++;
_lastPopSucceeded = false;
//Kick PLC to generate a filler frame, reducing 'click'
lostAudioData(allOrNothing ? (maxSamples - samplesAvailable) / _ringBuffer.getNumFrameSamples() : 1);
samplesPopped = _ringBuffer.samplesAvailable();
popSamplesNoCheck(samplesPopped);
}
}
return samplesPopped;