From 24bc8fda9d2b559b8563a61c556e84db57400ef5 Mon Sep 17 00:00:00 2001 From: "michal.szwaj" Date: Sat, 24 Mar 2018 03:55:20 +0100 Subject: [PATCH] Synchronize audio buffer callback --- src/autoapp/Projection/RtAudioOutput.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/autoapp/Projection/RtAudioOutput.cpp b/src/autoapp/Projection/RtAudioOutput.cpp index ca94bfc..eb0d493 100644 --- a/src/autoapp/Projection/RtAudioOutput.cpp +++ b/src/autoapp/Projection/RtAudioOutput.cpp @@ -32,7 +32,6 @@ RtAudioOutput::RtAudioOutput(uint32_t channelCount, uint32_t sampleSize, uint32_ : channelCount_(channelCount) , sampleSize_(sampleSize) , sampleRate_(sampleRate) - , dac_() { try { @@ -146,6 +145,8 @@ int RtAudioOutput::audioBufferReadHandler(void* outputBuffer, void* inputBuffer, double streamTime, RtAudioStreamStatus status, void* userData) { RtAudioOutput* self = static_cast(userData); + std::lock_guardmutex_)> lock(self->mutex_); + const auto bufferSize = nBufferFrames * (self->sampleSize_ / 8) * self->channelCount_; self->audioBuffer_.read(reinterpret_cast(outputBuffer), bufferSize); return 0;