diff --git a/amalgamation/juce_amalgamated_template.cpp b/amalgamation/juce_amalgamated_template.cpp index eba370eeba..f103d4da4b 100644 --- a/amalgamation/juce_amalgamated_template.cpp +++ b/amalgamation/juce_amalgamated_template.cpp @@ -59,6 +59,10 @@ #undef JUCE_BUILD_GUI #endif +#ifndef JUCE_NAMESPACE + #define JUCE_NAMESPACE juce +#endif + //============================================================================== #if JUCE_BUILD_NATIVE || JUCE_BUILD_CORE || (JUCE_BUILD_MISC && (JUCE_PLUGINHOST_VST || JUCE_PLUGINHOST_AU)) #if JUCE_WINDOWS diff --git a/juce_Config.h b/juce_Config.h index e1019141f5..771d55fc86 100644 --- a/juce_Config.h +++ b/juce_Config.h @@ -31,14 +31,6 @@ This file contains macros that enable/disable various JUCE features. */ -//============================================================================= -/** The name of the namespace that all Juce classes and functions will be - put inside. If this is not defined, no namespace will be used. -*/ -#ifndef JUCE_NAMESPACE - #define JUCE_NAMESPACE juce -#endif - //============================================================================= /** JUCE_FORCE_DEBUG: Normally, JUCE_DEBUG is set to 1 or 0 based on compiler and project settings, but if you define this value, you can override this to force diff --git a/juce_amalgamated.cpp b/juce_amalgamated.cpp index cc0beb8ef7..ed66f7cd1c 100644 --- a/juce_amalgamated.cpp +++ b/juce_amalgamated.cpp @@ -206,13 +206,6 @@ This file contains macros that enable/disable various JUCE features. */ -/** The name of the namespace that all Juce classes and functions will be - put inside. If this is not defined, no namespace will be used. -*/ -#ifndef JUCE_NAMESPACE - #define JUCE_NAMESPACE juce -#endif - /** JUCE_FORCE_DEBUG: Normally, JUCE_DEBUG is set to 1 or 0 based on compiler and project settings, but if you define this value, you can override this to force it to be true or false. @@ -507,6 +500,10 @@ #undef JUCE_BUILD_GUI #endif +#ifndef JUCE_NAMESPACE + #define JUCE_NAMESPACE juce +#endif + //============================================================================== #if JUCE_BUILD_NATIVE || JUCE_BUILD_CORE || (JUCE_BUILD_MISC && (JUCE_PLUGINHOST_VST || JUCE_PLUGINHOST_AU)) #if JUCE_WINDOWS @@ -17396,7 +17393,7 @@ void Thread::signalThreadShouldExit() bool Thread::waitForThreadToExit (const int timeOutMilliseconds) const { // Doh! So how exactly do you expect this thread to wait for itself to stop?? - jassert (getThreadId() != getCurrentThreadId()); + jassert (getThreadId() != getCurrentThreadId() || getCurrentThreadId() == 0); const int sleepMsPerIteration = 5; int count = timeOutMilliseconds / sleepMsPerIteration; @@ -247258,7 +247255,7 @@ void MessageManager::doPlatformSpecificShutdown() OleUninitialize(); } -class DeviceChangeDetector // (Used by various audio classes) +class DeviceChangeDetector : private Timer // (Used by various audio classes) { public: DeviceChangeDetector (const wchar_t* const name) @@ -247283,11 +247280,18 @@ private: || wParam == 0x8004 /*DBT_DEVICEREMOVECOMPLETE*/ || wParam == 0x0007 /*DBT_DEVNODES_CHANGED*/)) { - ((DeviceChangeDetector*) GetWindowLongPtr (h, GWLP_USERDATA))->systemDeviceChanged(); + // We'll pause before sending a message, because on device removal, the OS hasn't always updated + // its device lists correctly at this point. This also helps avoid repeated callbacks. + ((DeviceChangeDetector*) GetWindowLongPtr (h, GWLP_USERDATA))->startTimer (500); } return DefWindowProc (h, message, wParam, lParam); } + + void timerCallback() + { + systemDeviceChanged(); + } }; #endif @@ -256396,7 +256400,7 @@ public: void handleSysEx (MIDIHDR* const hdr, const uint32 timeStamp) { - if (isStarted) + if (isStarted && hdr->dwBytesRecorded > 0) { concatenator.pushMidiData (hdr->lpData, hdr->dwBytesRecorded, convertTimeStamp (timeStamp), input, callback); writeFinishedBlocks(); diff --git a/juce_amalgamated.h b/juce_amalgamated.h index 036aa20c23..95edfabbcd 100644 --- a/juce_amalgamated.h +++ b/juce_amalgamated.h @@ -73,7 +73,7 @@ namespace JuceDummyNamespace {} */ #define JUCE_MAJOR_VERSION 1 #define JUCE_MINOR_VERSION 54 -#define JUCE_BUILDNUMBER 3 +#define JUCE_BUILDNUMBER 4 /** Current Juce version number. @@ -254,13 +254,6 @@ namespace JuceDummyNamespace {} This file contains macros that enable/disable various JUCE features. */ -/** The name of the namespace that all Juce classes and functions will be - put inside. If this is not defined, no namespace will be used. -*/ -#ifndef JUCE_NAMESPACE - #define JUCE_NAMESPACE juce -#endif - /** JUCE_FORCE_DEBUG: Normally, JUCE_DEBUG is set to 1 or 0 based on compiler and project settings, but if you define this value, you can override this to force it to be true or false. @@ -535,14 +528,13 @@ namespace JuceDummyNamespace {} /*** End of inlined file: juce_Config.h ***/ -#ifdef JUCE_NAMESPACE - #define BEGIN_JUCE_NAMESPACE namespace JUCE_NAMESPACE { - #define END_JUCE_NAMESPACE } -#else - #define BEGIN_JUCE_NAMESPACE - #define END_JUCE_NAMESPACE +#ifndef JUCE_NAMESPACE + #define JUCE_NAMESPACE juce #endif +#define BEGIN_JUCE_NAMESPACE namespace JUCE_NAMESPACE { +#define END_JUCE_NAMESPACE } + /*** Start of inlined file: juce_PlatformDefs.h ***/ #ifndef __JUCE_PLATFORMDEFS_JUCEHEADER__ diff --git a/src/core/juce_StandardHeader.h b/src/core/juce_StandardHeader.h index 98fc43586b..9b90ee1874 100644 --- a/src/core/juce_StandardHeader.h +++ b/src/core/juce_StandardHeader.h @@ -33,7 +33,7 @@ */ #define JUCE_MAJOR_VERSION 1 #define JUCE_MINOR_VERSION 54 -#define JUCE_BUILDNUMBER 3 +#define JUCE_BUILDNUMBER 4 /** Current Juce version number. @@ -52,14 +52,13 @@ #include "../../juce_Config.h" //============================================================================== -#ifdef JUCE_NAMESPACE - #define BEGIN_JUCE_NAMESPACE namespace JUCE_NAMESPACE { - #define END_JUCE_NAMESPACE } -#else - #define BEGIN_JUCE_NAMESPACE - #define END_JUCE_NAMESPACE +#ifndef JUCE_NAMESPACE + #define JUCE_NAMESPACE juce #endif +#define BEGIN_JUCE_NAMESPACE namespace JUCE_NAMESPACE { +#define END_JUCE_NAMESPACE } + //============================================================================== #include "juce_PlatformDefs.h" diff --git a/src/native/windows/juce_win32_Messaging.cpp b/src/native/windows/juce_win32_Messaging.cpp index 5b237f40de..e933252902 100644 --- a/src/native/windows/juce_win32_Messaging.cpp +++ b/src/native/windows/juce_win32_Messaging.cpp @@ -345,7 +345,7 @@ void MessageManager::doPlatformSpecificShutdown() } //============================================================================== -class DeviceChangeDetector // (Used by various audio classes) +class DeviceChangeDetector : private Timer // (Used by various audio classes) { public: DeviceChangeDetector (const wchar_t* const name) @@ -370,11 +370,18 @@ private: || wParam == 0x8004 /*DBT_DEVICEREMOVECOMPLETE*/ || wParam == 0x0007 /*DBT_DEVNODES_CHANGED*/)) { - ((DeviceChangeDetector*) GetWindowLongPtr (h, GWLP_USERDATA))->systemDeviceChanged(); + // We'll pause before sending a message, because on device removal, the OS hasn't always updated + // its device lists correctly at this point. This also helps avoid repeated callbacks. + ((DeviceChangeDetector*) GetWindowLongPtr (h, GWLP_USERDATA))->startTimer (500); } return DefWindowProc (h, message, wParam, lParam); } + + void timerCallback() + { + systemDeviceChanged(); + } }; #endif diff --git a/src/native/windows/juce_win32_Midi.cpp b/src/native/windows/juce_win32_Midi.cpp index 3e2376ede6..4ac908b038 100644 --- a/src/native/windows/juce_win32_Midi.cpp +++ b/src/native/windows/juce_win32_Midi.cpp @@ -73,7 +73,7 @@ public: void handleSysEx (MIDIHDR* const hdr, const uint32 timeStamp) { - if (isStarted) + if (isStarted && hdr->dwBytesRecorded > 0) { concatenator.pushMidiData (hdr->lpData, hdr->dwBytesRecorded, convertTimeStamp (timeStamp), input, callback); writeFinishedBlocks(); diff --git a/src/threads/juce_Thread.cpp b/src/threads/juce_Thread.cpp index cb44891a3c..69e5e75764 100644 --- a/src/threads/juce_Thread.cpp +++ b/src/threads/juce_Thread.cpp @@ -225,7 +225,7 @@ void Thread::signalThreadShouldExit() bool Thread::waitForThreadToExit (const int timeOutMilliseconds) const { // Doh! So how exactly do you expect this thread to wait for itself to stop?? - jassert (getThreadId() != getCurrentThreadId()); + jassert (getThreadId() != getCurrentThreadId() || getCurrentThreadId() == 0); const int sleepMsPerIteration = 5; int count = timeOutMilliseconds / sleepMsPerIteration;