mirror of https://github.com/f1xpl/openauto.git
Synchronize audio buffer callback
parent
205ed34468
commit
24bc8fda9d
|
@ -32,7 +32,6 @@ RtAudioOutput::RtAudioOutput(uint32_t channelCount, uint32_t sampleSize, uint32_
|
||||||
: channelCount_(channelCount)
|
: channelCount_(channelCount)
|
||||||
, sampleSize_(sampleSize)
|
, sampleSize_(sampleSize)
|
||||||
, sampleRate_(sampleRate)
|
, sampleRate_(sampleRate)
|
||||||
, dac_()
|
|
||||||
{
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
|
@ -146,6 +145,8 @@ int RtAudioOutput::audioBufferReadHandler(void* outputBuffer, void* inputBuffer,
|
||||||
double streamTime, RtAudioStreamStatus status, void* userData)
|
double streamTime, RtAudioStreamStatus status, void* userData)
|
||||||
{
|
{
|
||||||
RtAudioOutput* self = static_cast<RtAudioOutput*>(userData);
|
RtAudioOutput* self = static_cast<RtAudioOutput*>(userData);
|
||||||
|
std::lock_guard<decltype(self->mutex_)> lock(self->mutex_);
|
||||||
|
|
||||||
const auto bufferSize = nBufferFrames * (self->sampleSize_ / 8) * self->channelCount_;
|
const auto bufferSize = nBufferFrames * (self->sampleSize_ / 8) * self->channelCount_;
|
||||||
self->audioBuffer_.read(reinterpret_cast<char*>(outputBuffer), bufferSize);
|
self->audioBuffer_.read(reinterpret_cast<char*>(outputBuffer), bufferSize);
|
||||||
return 0;
|
return 0;
|
||||||
|
|
Loading…
Reference in New Issue