mirror of
https://github.com/juce-framework/JUCE.git
synced 2026-01-10 23:44:24 +00:00
Fixed a assertion/crash when a macOS CoreAudio device becomes unavailable during playback
This commit is contained in:
parent
c4e50b25b4
commit
728e2dbe82
1 changed files with 24 additions and 30 deletions
|
|
@ -1366,21 +1366,7 @@ public:
|
|||
}
|
||||
}
|
||||
|
||||
void stop() override
|
||||
{
|
||||
AudioIODeviceCallback* lastCallback = nullptr;
|
||||
|
||||
{
|
||||
const ScopedLock sl (callbackLock);
|
||||
std::swap (callback, lastCallback);
|
||||
}
|
||||
|
||||
for (int i = 0; i < devices.size(); ++i)
|
||||
devices.getUnchecked(i)->device->stop();
|
||||
|
||||
if (lastCallback != nullptr)
|
||||
lastCallback->audioDeviceStopped();
|
||||
}
|
||||
void stop() override { shutdown ({}); }
|
||||
|
||||
String getLastError() override
|
||||
{
|
||||
|
|
@ -1456,6 +1442,27 @@ private:
|
|||
}
|
||||
}
|
||||
|
||||
void shutdown (const String& error)
|
||||
{
|
||||
AudioIODeviceCallback* lastCallback = nullptr;
|
||||
|
||||
{
|
||||
const ScopedLock sl (callbackLock);
|
||||
std::swap (callback, lastCallback);
|
||||
}
|
||||
|
||||
for (int i = 0; i < devices.size(); ++i)
|
||||
devices.getUnchecked(i)->device->stop();
|
||||
|
||||
if (lastCallback != nullptr)
|
||||
{
|
||||
if (error.isNotEmpty())
|
||||
lastCallback->audioDeviceError (error);
|
||||
else
|
||||
lastCallback->audioDeviceStopped();
|
||||
}
|
||||
}
|
||||
|
||||
void reset()
|
||||
{
|
||||
for (int i = 0; i < devices.size(); ++i)
|
||||
|
|
@ -1584,21 +1591,8 @@ private:
|
|||
callback->audioDeviceAboutToStart (device);
|
||||
}
|
||||
|
||||
void handleAudioDeviceStopped()
|
||||
{
|
||||
const ScopedLock sl (callbackLock);
|
||||
|
||||
if (callback != nullptr)
|
||||
callback->audioDeviceStopped();
|
||||
}
|
||||
|
||||
void handleAudioDeviceError (const String& errorMessage)
|
||||
{
|
||||
const ScopedLock sl (callbackLock);
|
||||
|
||||
if (callback != nullptr)
|
||||
callback->audioDeviceError (errorMessage);
|
||||
}
|
||||
void handleAudioDeviceStopped() { shutdown ({}); }
|
||||
void handleAudioDeviceError (const String& errorMessage) { shutdown (errorMessage.isNotEmpty() ? errorMessage : String ("unknown")); }
|
||||
|
||||
//==============================================================================
|
||||
struct DeviceWrapper : private AudioIODeviceCallback
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue