require that buffers be above min loudness to be mixed in

This commit is contained in:
Stephen Birarda 2014-03-20 13:01:52 -07:00
parent a8ef64e0ce
commit 64f946b640

View file

@ -379,13 +379,15 @@ void AudioMixer::run() {
float percentageSleep = (usecToSleep / (float) BUFFER_SEND_INTERVAL_USECS);
float lastCutoffRatio = _loudnessCutoffRatio;
bool hasRatioChanged = false;
if (percentageSleep <= STRUGGLE_TRIGGER_SLEEP_PERCENTAGE_THRESHOLD || usecToSleep < 0) {
// we're struggling - change our min required loudness to reduce some load
_loudnessCutoffRatio += (1 - _loudnessCutoffRatio) / 2;
qDebug() << "Mixer is struggling, sleeping" << percentageSleep * 100 << "% of frame time. Old cutoff was"
<< lastCutoffRatio << "and is now" << _loudnessCutoffRatio;
<< lastCutoffRatio << "and is now" << _loudnessCutoffRatio;
hasRatioChanged = true;
} else if (percentageSleep >= BACK_OFF_TRIGGER_SLEEP_PERCENTAGE_THRESHOLD && _loudnessCutoffRatio != 0) {
// we've recovered and can back off the required loudness
_loudnessCutoffRatio -= _loudnessCutoffRatio / 2;
@ -396,10 +398,17 @@ void AudioMixer::run() {
qDebug() << "Mixer is recovering, sleeping" << percentageSleep * 100 << "% of frame time. Old cutoff was"
<< lastCutoffRatio << "and is now" << _loudnessCutoffRatio;
hasRatioChanged = true;
}
// set out min required loudness from the new ratio
_minRequiredLoudness = _loudnessCutoffRatio * (_maxSourceLoudnessInFrame - _minSourceLoudnessInFrame);
if (hasRatioChanged) {
// set out min required loudness from the new ratio
_minRequiredLoudness = _loudnessCutoffRatio * (_maxSourceLoudnessInFrame - _minSourceLoudnessInFrame);
qDebug() << "Minimum loudness required to be mixed is now" << _minRequiredLoudness;
}
} else {
isFirstRun = false;
}