Merge pull request #2059 from MerryMage/tweak-audio-latency

audio_core: Tweak audio latency
merge-requests/60/head
bunnei 2016-09-11 15:09:12 +07:00 committed by GitHub
commit 5cd3701663
2 changed files with 2 additions and 2 deletions

@ -105,7 +105,7 @@ static void OutputCurrentFrame(const StereoFrame16& frame) {
std::vector<s16> stretched_samples = time_stretcher.Process(sink->SamplesInQueue()); std::vector<s16> stretched_samples = time_stretcher.Process(sink->SamplesInQueue());
sink->EnqueueSamples(stretched_samples.data(), stretched_samples.size() / 2); sink->EnqueueSamples(stretched_samples.data(), stretched_samples.size() / 2);
} else { } else {
constexpr size_t maximum_sample_latency = 1024; // about 32 miliseconds constexpr size_t maximum_sample_latency = 2048; // about 64 miliseconds
if (sink->SamplesInQueue() > maximum_sample_latency) { if (sink->SamplesInQueue() > maximum_sample_latency) {
// This can occur if we're running too fast and samples are starting to back up. // This can occur if we're running too fast and samples are starting to back up.
// Just drop the samples. // Just drop the samples.

@ -38,7 +38,7 @@ SDL2Sink::SDL2Sink() : impl(std::make_unique<Impl>()) {
desired_audiospec.format = AUDIO_S16; desired_audiospec.format = AUDIO_S16;
desired_audiospec.channels = 2; desired_audiospec.channels = 2;
desired_audiospec.freq = native_sample_rate; desired_audiospec.freq = native_sample_rate;
desired_audiospec.samples = 1024; desired_audiospec.samples = 512;
desired_audiospec.userdata = impl.get(); desired_audiospec.userdata = impl.get();
desired_audiospec.callback = &Impl::Callback; desired_audiospec.callback = &Impl::Callback;