Skip to content
Permalink
Browse files

Windows: Fixed a potential crash when closing and re-opening WASAPI a…

…udio devices
  • Loading branch information
ed95 committed Feb 13, 2020
1 parent 9fda031 commit 0ff16ddadb387a8751902c850f7af68e027a59da
Showing with 9 additions and 6 deletions.
  1. +9 −6 modules/juce_audio_devices/native/juce_win32_WASAPI.cpp
@@ -1244,14 +1244,14 @@ class WASAPIAudioIODevice : public AudioIODevice,

while (! threadShouldExit())
{
if (outputDevice != nullptr && outputDevice->shouldClose)
if ((outputDevice != nullptr && outputDevice->shouldClose)
|| (inputDevice != nullptr && inputDevice->shouldClose))
{
deviceBecameInactive = true;
}

if (inputDevice != nullptr && ! deviceBecameInactive)
{
if (inputDevice->shouldClose)
deviceBecameInactive = true;

if (outputDevice == nullptr)
{
if (WaitForSingleObject (inputDevice->clientEvent, 1000) == WAIT_TIMEOUT)
@@ -1372,8 +1372,11 @@ class WASAPIAudioIODevice : public AudioIODevice,
{
if (deviceBecameInactive)
{
deviceBecameInactive = false;
MessageManager::callAsync ([this] { reopenDevices(); });
MessageManager::callAsync ([this]
{
close();
reopenDevices();
});
}
};

0 comments on commit 0ff16dd

Please sign in to comment.
You can’t perform that action at this time.