1
0
Fork 0
mirror of https://github.com/juce-framework/JUCE.git synced 2026-01-10 23:44:24 +00:00

CoreAudio: Avoid race on currentSampleRate data member of AudioIODeviceCombiner

This commit is contained in:
reuk 2022-12-14 13:17:57 +00:00
parent f47041eefd
commit 6cd2ed022d
No known key found for this signature in database
GPG key ID: FCB43929F012EE5C

View file

@ -1605,8 +1605,7 @@ public:
}
}
open (inputChannelsRequested, outputChannelsRequested,
newSampleRate, newBufferSize);
open (inputChannelsRequested, outputChannelsRequested, newSampleRate, newBufferSize);
start (cb);
}
@ -1914,7 +1913,8 @@ private:
struct DeviceWrapper : public AudioIODeviceCallback
{
DeviceWrapper (AudioIODeviceCombiner& cd, std::unique_ptr<CoreAudioIODevice> d, bool shouldBeInput)
: owner (cd), device (std::move (d)),
: owner (cd),
device (std::move (d)),
input (shouldBeInput)
{
device->setAsyncRestarter (&owner);
@ -1974,7 +1974,7 @@ private:
std::uint64_t nsToSampleTime (std::uint64_t ns) const noexcept
{
return static_cast<std::uint64_t> (std::round (static_cast<double> (ns) * owner.currentSampleRate * 1e-9));
return static_cast<std::uint64_t> (std::round (static_cast<double> (ns) * device->getCurrentSampleRate() * 1e-9));
}
void updateSampleTimeFromContext (const AudioIODeviceCallbackContext& context) noexcept