mirror of
https://github.com/juce-framework/JUCE.git
synced 2026-01-10 23:44:24 +00:00
CoreAudio: Prevent racing between calls to start and stop a device
This commit is contained in:
parent
2516ad808e
commit
4808fdce30
1 changed files with 9 additions and 4 deletions
|
|
@ -1051,7 +1051,7 @@ public:
|
|||
|
||||
CoreAudioIODevice& owner;
|
||||
int bitDepth = 32;
|
||||
int xruns = 0;
|
||||
std::atomic<int> xruns = 0;
|
||||
Array<double> sampleRates;
|
||||
Array<int> bufferSizes;
|
||||
AudioDeviceID deviceID;
|
||||
|
|
@ -1159,7 +1159,7 @@ private:
|
|||
return x.mSelector == kAudioDeviceProcessorOverload;
|
||||
});
|
||||
|
||||
intern.xruns += xruns;
|
||||
intern.xruns += (int) xruns;
|
||||
|
||||
const auto detailsChanged = std::any_of (pa, pa + numAddresses, [] (const AudioObjectPropertyAddress& x)
|
||||
{
|
||||
|
|
@ -1325,6 +1325,8 @@ public:
|
|||
|
||||
void start (AudioIODeviceCallback* callback) override
|
||||
{
|
||||
const ScopedLock sl (startStopLock);
|
||||
|
||||
if (internal->start (callback))
|
||||
pendingCallback = nullptr;
|
||||
}
|
||||
|
|
@ -1332,12 +1334,14 @@ public:
|
|||
void stop() override
|
||||
{
|
||||
stopAndGetLastCallback();
|
||||
|
||||
const ScopedLock sl (startStopLock);
|
||||
pendingCallback = nullptr;
|
||||
}
|
||||
|
||||
void stopWithPendingCallback()
|
||||
{
|
||||
const ScopedLock sl (closeLock);
|
||||
const ScopedLock sl (startStopLock);
|
||||
|
||||
if (pendingCallback == nullptr)
|
||||
pendingCallback = stopAndGetLastCallback();
|
||||
|
|
@ -1399,7 +1403,7 @@ private:
|
|||
AudioIODeviceCallback* pendingCallback = nullptr;
|
||||
AsyncRestarter* restarter = nullptr;
|
||||
BigInteger inputChannelsRequested, outputChannelsRequested;
|
||||
CriticalSection closeLock;
|
||||
CriticalSection startStopLock;
|
||||
|
||||
AudioIODeviceCallback* stopAndGetLastCallback() const
|
||||
{
|
||||
|
|
@ -1424,6 +1428,7 @@ private:
|
|||
getCurrentSampleRate(),
|
||||
getCurrentBufferSizeSamples());
|
||||
|
||||
const ScopedLock sl { startStopLock };
|
||||
start (pendingCallback);
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue