Error when using AudioDeviceManagerSingleton::deleteInstance

Happy new year all. I’m receiving a confusing error when I shut down my application. I am experimenting by using the AudioDeviceManager as a singleton using the following source . . .

AudioDeviceManagerSingleton.h

[code]#ifndef ADUDIODEVICEMANAGERSINGLETON_H_254D233A
#define ADUDIODEVICEMANAGERSINGLETON_H_254D233A

#include “…/JuceLibraryCode/JuceHeader.h”

class AudioDeviceManagerSingleton : public AudioDeviceManager
{
public:
~AudioDeviceManagerSingleton();
juce_DeclareSingleton (AudioDeviceManagerSingleton, true)

};

#endif // ADUDIODEVICEMANAGERSINGLETON_H_254D233A[/code]

AudioDeviceManagerSingleton.cpp

[code]#include “AudioDeviceManagerSingleton.h”

juce_ImplementSingleton (AudioDeviceManagerSingleton);

AudioDeviceManagerSingleton::~AudioDeviceManagerSingleton()
{
// this ensures that no dangling pointers are left when the
// singleton is deleted.
clearSingletonInstance();
}
[/code]

In my application shutdown code I include the following

…but when I close the application, there is a long delay and then I receive the following messages in the output window in VS2008.

The thread 'Juce DSound' (0x1470) has exited with code 0 (0x0). closing dsound in: Primary Sound Capture Driver The thread 'Win32 Thread' (0x390) has exited with code 0 (0x0). closing dsound out: Primary Sound Driver The thread 'Win32 Thread' (0x167c) has exited with code 0 (0x0). The thread 'Juce IPC server' (0xf7c) has exited with code 0 (0x0). First-chance exception at 0x7c919af2 in blah.exe: 0xC0000005: Access violation writing location 0xfeeefefe. Unhandled exception at 0x7c919af2 in blah.exe: 0xC0000005: Access violation writing location 0xfeeefefe.

The debugger brings up the following code in the editor in the file juce_win32_Threads.cpp. . .

void CriticalSection::enter() const noexcept { EnterCriticalSection ((CRITICAL_SECTION*) internal); }

I use one other unrelated singleton in my app and that cleans up after itself nicely. Can anyone shed any light on why I am receiving this error?