Skip to content

Commit

Permalink
Merge pull request #8573 from zhykzhykzhyk/qtaudio
Browse files Browse the repository at this point in the history
Fix audio lag in Qt without SDL.
  • Loading branch information
hrydgard committed Feb 10, 2016
2 parents a258bcf + 4aa92e9 commit 8c36ae0
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 5 deletions.
5 changes: 2 additions & 3 deletions Core/HLE/__sceAudio.cpp
Expand Up @@ -370,8 +370,7 @@ void __AudioUpdate() {
// numFrames is number of stereo frames.
// This is called from *outside* the emulator thread.
int __AudioMix(short *outstereo, int numFrames, int sampleRate) {
resampler.Mix(outstereo, numFrames, false, sampleRate);
return numFrames;
return resampler.Mix(outstereo, numFrames, false, sampleRate);
}

const AudioDebugStats *__AudioGetDebugStats() {
Expand All @@ -385,4 +384,4 @@ void __PushExternalAudio(const s32 *audio, int numSamples) {
} else {
resampler.Clear();
}
}
}
9 changes: 7 additions & 2 deletions ext/native/base/QtMain.cpp
Expand Up @@ -421,8 +421,13 @@ void MainAudio::run()
output = new QAudioOutput(fmt);
output->setBufferSize(mixlen);
feed = output->start();
if (feed != NULL)
timer = startTimer((1000*AUDIO_SAMPLES) / AUDIO_FREQ);
if (feed != NULL) {
// buffering has already done in the internal mixed buffer
// use a small interval to copy mixed audio stream from
// internal buffer to audio output buffer as soon as possible
// use 1 instead of 0 to prevent CPU exhausting
timer = startTimer(1);
}
}

void MainAudio::timerEvent(QTimerEvent *)
Expand Down

0 comments on commit 8c36ae0

Please sign in to comment.