mirror of
https://github.com/overte-org/overte.git
synced 2025-08-09 10:07:58 +02:00
Merge pull request #4322 from AndrewMeadows/thermonuclear
workaround for scratchy audio on Windows
This commit is contained in:
commit
c6b1375863
3 changed files with 16 additions and 15 deletions
|
@ -75,4 +75,4 @@ private:
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif // hifi_AudioScope_h
|
#endif // hifi_AudioScope_h
|
||||||
|
|
|
@ -85,16 +85,9 @@ AudioClient::AudioClient() :
|
||||||
_isStereoInput(false),
|
_isStereoInput(false),
|
||||||
_outputStarveDetectionStartTimeMsec(0),
|
_outputStarveDetectionStartTimeMsec(0),
|
||||||
_outputStarveDetectionCount(0),
|
_outputStarveDetectionCount(0),
|
||||||
_outputBufferSizeFrames("audioOutputBufferSize",
|
_outputBufferSizeFrames("audioOutputBufferSize", DEFAULT_AUDIO_OUTPUT_BUFFER_SIZE_FRAMES),
|
||||||
DEFAULT_MAX_FRAMES_OVER_DESIRED),
|
|
||||||
#ifdef Q_OS_ANDROID
|
|
||||||
_outputStarveDetectionEnabled("audioOutputStarveDetectionEnabled",
|
|
||||||
false),
|
|
||||||
#else
|
|
||||||
_outputStarveDetectionEnabled("audioOutputStarveDetectionEnabled",
|
_outputStarveDetectionEnabled("audioOutputStarveDetectionEnabled",
|
||||||
DEFAULT_AUDIO_OUTPUT_STARVE_DETECTION_ENABLED),
|
DEFAULT_AUDIO_OUTPUT_STARVE_DETECTION_ENABLED),
|
||||||
#endif
|
|
||||||
|
|
||||||
_outputStarveDetectionPeriodMsec("audioOutputStarveDetectionPeriod",
|
_outputStarveDetectionPeriodMsec("audioOutputStarveDetectionPeriod",
|
||||||
DEFAULT_AUDIO_OUTPUT_STARVE_DETECTION_PERIOD),
|
DEFAULT_AUDIO_OUTPUT_STARVE_DETECTION_PERIOD),
|
||||||
_outputStarveDetectionThreshold("audioOutputStarveDetectionThreshold",
|
_outputStarveDetectionThreshold("audioOutputStarveDetectionThreshold",
|
||||||
|
@ -1090,19 +1083,23 @@ void AudioClient::outputNotify() {
|
||||||
if (recentUnfulfilled > 0) {
|
if (recentUnfulfilled > 0) {
|
||||||
if (_outputStarveDetectionEnabled.get()) {
|
if (_outputStarveDetectionEnabled.get()) {
|
||||||
quint64 now = usecTimestampNow() / 1000;
|
quint64 now = usecTimestampNow() / 1000;
|
||||||
quint64 dt = now - _outputStarveDetectionStartTimeMsec;
|
int dt = (int)(now - _outputStarveDetectionStartTimeMsec);
|
||||||
if (dt > _outputStarveDetectionPeriodMsec.get()) {
|
if (dt > _outputStarveDetectionPeriodMsec.get()) {
|
||||||
_outputStarveDetectionStartTimeMsec = now;
|
_outputStarveDetectionStartTimeMsec = now;
|
||||||
_outputStarveDetectionCount = 0;
|
_outputStarveDetectionCount = 0;
|
||||||
} else {
|
} else {
|
||||||
_outputStarveDetectionCount += recentUnfulfilled;
|
_outputStarveDetectionCount += recentUnfulfilled;
|
||||||
if (_outputStarveDetectionCount > _outputStarveDetectionThreshold.get()) {
|
if (_outputStarveDetectionCount > _outputStarveDetectionThreshold.get()) {
|
||||||
int newOutputBufferSizeFrames = _outputBufferSizeFrames.get() + 1;
|
|
||||||
qDebug() << "Starve detection threshold met, increasing buffer size to " << newOutputBufferSizeFrames;
|
|
||||||
setOutputBufferSize(newOutputBufferSizeFrames);
|
|
||||||
|
|
||||||
_outputStarveDetectionStartTimeMsec = now;
|
_outputStarveDetectionStartTimeMsec = now;
|
||||||
_outputStarveDetectionCount = 0;
|
_outputStarveDetectionCount = 0;
|
||||||
|
|
||||||
|
int oldOutputBufferSizeFrames = _outputBufferSizeFrames.get();
|
||||||
|
int newOutputBufferSizeFrames = oldOutputBufferSizeFrames + 1;
|
||||||
|
setOutputBufferSize(newOutputBufferSizeFrames);
|
||||||
|
newOutputBufferSizeFrames = _outputBufferSizeFrames.get();
|
||||||
|
if (newOutputBufferSizeFrames > oldOutputBufferSizeFrames) {
|
||||||
|
qDebug() << "Starve detection threshold met, increasing buffer size to " << newOutputBufferSizeFrames;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -57,7 +57,11 @@ static const int NUM_AUDIO_CHANNELS = 2;
|
||||||
static const int DEFAULT_AUDIO_OUTPUT_BUFFER_SIZE_FRAMES = 3;
|
static const int DEFAULT_AUDIO_OUTPUT_BUFFER_SIZE_FRAMES = 3;
|
||||||
static const int MIN_AUDIO_OUTPUT_BUFFER_SIZE_FRAMES = 1;
|
static const int MIN_AUDIO_OUTPUT_BUFFER_SIZE_FRAMES = 1;
|
||||||
static const int MAX_AUDIO_OUTPUT_BUFFER_SIZE_FRAMES = 20;
|
static const int MAX_AUDIO_OUTPUT_BUFFER_SIZE_FRAMES = 20;
|
||||||
static const int DEFAULT_AUDIO_OUTPUT_STARVE_DETECTION_ENABLED = true;
|
#if defined(Q_OS_ANDROID) || defined(Q_OS_WIN)
|
||||||
|
static const int DEFAULT_AUDIO_OUTPUT_STARVE_DETECTION_ENABLED = false;
|
||||||
|
#else
|
||||||
|
static const int DEFAULT_AUDIO_OUTPUT_STARVE_DETECTION_ENABLED = true;
|
||||||
|
#endif
|
||||||
static const int DEFAULT_AUDIO_OUTPUT_STARVE_DETECTION_THRESHOLD = 3;
|
static const int DEFAULT_AUDIO_OUTPUT_STARVE_DETECTION_THRESHOLD = 3;
|
||||||
static const quint64 DEFAULT_AUDIO_OUTPUT_STARVE_DETECTION_PERIOD = 10 * 1000; // 10 Seconds
|
static const quint64 DEFAULT_AUDIO_OUTPUT_STARVE_DETECTION_PERIOD = 10 * 1000; // 10 Seconds
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue