From 97ef44e1e61863b46a3227075b435c0f5fb66c99 Mon Sep 17 00:00:00 2001 From: jules Date: Mon, 8 Dec 2008 14:49:23 +0000 Subject: [PATCH] couple of small fixes to Timers, mac file searching and linux build macros --- juce_amalgamated.cpp | 14 +++++++++----- juce_amalgamated.h | 2 +- src/juce_appframework/events/juce_Timer.cpp | 5 +++++ src/juce_core/basics/juce_PlatformDefs.h | 2 +- src/juce_core/basics/juce_Random.cpp | 3 +-- src/juce_core/io/network/juce_Socket.cpp | 2 +- 6 files changed, 18 insertions(+), 10 deletions(-) diff --git a/juce_amalgamated.cpp b/juce_amalgamated.cpp index 77131552ab..2aa6bad92d 100644 --- a/juce_amalgamated.cpp +++ b/juce_amalgamated.cpp @@ -799,7 +799,7 @@ void Random::setSeed (const int64 newSeed) throw() void Random::setSeedRandomly() { - Random r1 (SystemStats::getClockCycleCounter()); + Random r1 (Time::getMillisecondCounter()); Random r2 (Time::getHighResolutionTicks()); Random r3 (Time::getHighResolutionTicksPerSecond()); Random r4 (Time::currentTimeMillis()); @@ -6510,7 +6510,7 @@ END_JUCE_NAMESPACE #endif #else - #ifdef LINUX + #if defined (LINUX) || defined (__linux__) #include #include #include @@ -36848,13 +36848,17 @@ public: if (instance == 0) instance = new InternalTimerThread(); + const ScopedLock sl (instance->lock); instance->addTimer (tim); } static inline void remove (Timer* const tim) throw() { if (instance != 0) + { + const ScopedLock sl (instance->lock); instance->removeTimer (tim); + } } static inline void resetCounter (Timer* const tim, @@ -36868,6 +36872,7 @@ public: if ((tim->next != 0 && tim->next->countdownMs < tim->countdownMs) || (tim->previous != 0 && tim->previous->countdownMs > tim->countdownMs)) { + const ScopedLock sl (instance->lock); instance->removeTimer (tim); instance->addTimer (tim); } @@ -262856,8 +262861,7 @@ int64 Time::getHighResolutionTicksPerSecond() throw() int64 SystemStats::getClockCycleCounter() throw() { - jassertfalse - return 0; + return (int64) AudioGetCurrentHostTime(); } bool Time::setSystemTimeToThisTime() const throw() @@ -264133,7 +264137,7 @@ struct FindFileStruct if (fnmatch (wildCardUTF8, de->d_name, 0) == 0) { - result = PlatformUtilities::convertToPrecomposedUnicode (String::fromUTF8 ((const uint8*) de->d_name)); + result = String::fromUTF8 ((const uint8*) de->d_name); const String path (parentDir + result); diff --git a/juce_amalgamated.h b/juce_amalgamated.h index 65ba9ff158..cc21c95593 100644 --- a/juce_amalgamated.h +++ b/juce_amalgamated.h @@ -307,7 +307,7 @@ #if (defined (_WIN32) || defined (_WIN64)) #define JUCE_WIN32 1 #else - #ifdef LINUX + #if defined (LINUX) || defined (__linux__) #define JUCE_LINUX 1 #else #define JUCE_MAC 1 diff --git a/src/juce_appframework/events/juce_Timer.cpp b/src/juce_appframework/events/juce_Timer.cpp index 4cc9e40b5c..1a84d0f06f 100644 --- a/src/juce_appframework/events/juce_Timer.cpp +++ b/src/juce_appframework/events/juce_Timer.cpp @@ -273,13 +273,17 @@ public: if (instance == 0) instance = new InternalTimerThread(); + const ScopedLock sl (instance->lock); instance->addTimer (tim); } static inline void remove (Timer* const tim) throw() { if (instance != 0) + { + const ScopedLock sl (instance->lock); instance->removeTimer (tim); + } } static inline void resetCounter (Timer* const tim, @@ -293,6 +297,7 @@ public: if ((tim->next != 0 && tim->next->countdownMs < tim->countdownMs) || (tim->previous != 0 && tim->previous->countdownMs > tim->countdownMs)) { + const ScopedLock sl (instance->lock); instance->removeTimer (tim); instance->addTimer (tim); } diff --git a/src/juce_core/basics/juce_PlatformDefs.h b/src/juce_core/basics/juce_PlatformDefs.h index e085c16b7e..2b8b50b048 100644 --- a/src/juce_core/basics/juce_PlatformDefs.h +++ b/src/juce_core/basics/juce_PlatformDefs.h @@ -55,7 +55,7 @@ #if (defined (_WIN32) || defined (_WIN64)) #define JUCE_WIN32 1 #else - #ifdef LINUX + #if defined (LINUX) || defined (__linux__) #define JUCE_LINUX 1 #else #define JUCE_MAC 1 diff --git a/src/juce_core/basics/juce_Random.cpp b/src/juce_core/basics/juce_Random.cpp index 9f5ec7ed59..01e43df190 100644 --- a/src/juce_core/basics/juce_Random.cpp +++ b/src/juce_core/basics/juce_Random.cpp @@ -35,7 +35,6 @@ BEGIN_JUCE_NAMESPACE #include "juce_Random.h" #include "juce_Time.h" -#include "juce_SystemStats.h" //============================================================================== @@ -55,7 +54,7 @@ void Random::setSeed (const int64 newSeed) throw() void Random::setSeedRandomly() { - Random r1 (SystemStats::getClockCycleCounter()); + Random r1 (Time::getMillisecondCounter()); Random r2 (Time::getHighResolutionTicks()); Random r3 (Time::getHighResolutionTicksPerSecond()); Random r4 (Time::currentTimeMillis()); diff --git a/src/juce_core/io/network/juce_Socket.cpp b/src/juce_core/io/network/juce_Socket.cpp index eec04353bd..368891db56 100644 --- a/src/juce_core/io/network/juce_Socket.cpp +++ b/src/juce_core/io/network/juce_Socket.cpp @@ -37,7 +37,7 @@ #endif #else - #ifdef LINUX + #if defined (LINUX) || defined (__linux__) #include #include #include