From b44238821806e184a7042dd3dcce8c68be0a25ee Mon Sep 17 00:00:00 2001 From: Julian Storer Date: Fri, 28 Jan 2011 13:33:48 +0000 Subject: [PATCH] Minor string fixes. --- .../jucer_ProjectInformationComponent.h | 2 +- .../wrapper/juce_ActiveX_GlueCode.cpp | 22 +- extras/juce demo/Source/jucedemo_headers.h | 2 +- juce_Config.h | 4 +- juce_amalgamated.cpp | 384 ++++++++++-------- juce_amalgamated.h | 16 +- src/core/juce_Initialisation.h | 6 +- src/core/juce_PlatformDefs.h | 4 +- src/core/juce_StandardHeader.h | 2 +- src/native/android/juce_android_Messaging.cpp | 1 - .../android/juce_android_NativeCode.cpp | 2 +- .../android/juce_android_NativeIncludes.h | 1 + .../android/juce_android_SystemStats.cpp | 76 +++- src/native/windows/juce_win32_ASIO.cpp | 4 +- .../windows/juce_win32_CameraDevice.cpp | 4 +- 15 files changed, 328 insertions(+), 202 deletions(-) diff --git a/extras/Jucer (experimental)/Source/Project/jucer_ProjectInformationComponent.h b/extras/Jucer (experimental)/Source/Project/jucer_ProjectInformationComponent.h index f4cef0b2e7..93350a6cf9 100644 --- a/extras/Jucer (experimental)/Source/Project/jucer_ProjectInformationComponent.h +++ b/extras/Jucer (experimental)/Source/Project/jucer_ProjectInformationComponent.h @@ -33,7 +33,7 @@ */ class ProjectInformationComponent : public Component, public ChangeListener, - public Button::Listener + public ButtonListener { public: //============================================================================== diff --git a/extras/browser plugins/wrapper/juce_ActiveX_GlueCode.cpp b/extras/browser plugins/wrapper/juce_ActiveX_GlueCode.cpp index 0eb169f118..b1c42dbafc 100644 --- a/extras/browser plugins/wrapper/juce_ActiveX_GlueCode.cpp +++ b/extras/browser plugins/wrapper/juce_ActiveX_GlueCode.cpp @@ -234,7 +234,7 @@ public: const var getProperty (const Identifier& propertyName) const { const String nameCopy (propertyName.toString()); - LPCOLESTR name = (LPCOLESTR) nameCopy; + LPCOLESTR name = nameCopy.toUTF16(); DISPID id = 0; if (source->GetIDsOfNames (IID_NULL, (LPOLESTR*) &name, 1, 0, &id) == S_OK) { @@ -260,7 +260,7 @@ public: bool hasProperty (const Identifier& propertyName) const { const String nameCopy (propertyName.toString()); - LPCOLESTR name = (LPCOLESTR) nameCopy; + LPCOLESTR name = nameCopy.toUTF16(); DISPID id = 0; return source->GetIDsOfNames (IID_NULL, (LPOLESTR*) &name, 1, 0, &id) == S_OK; } @@ -268,7 +268,7 @@ public: void setProperty (const Identifier& propertyName, const var& newValue) { const String nameCopy (propertyName.toString()); - LPCOLESTR name = (LPCOLESTR) nameCopy; + LPCOLESTR name = nameCopy.toUTF16(); DISPID id = 0; if (source->GetIDsOfNames (IID_NULL, (LPOLESTR*) &name, 1, 0, &id) == S_OK) { @@ -305,7 +305,7 @@ public: bool hasMethod (const Identifier& methodName) const { const String nameCopy (methodName.toString()); - LPCOLESTR name = (LPCOLESTR) nameCopy; + LPCOLESTR name = nameCopy.toUTF16(); DISPID id = 0; return source->GetIDsOfNames (IID_NULL, (LPOLESTR*) &name, 1, 0, &id) == S_OK; } @@ -314,7 +314,7 @@ public: { var returnValue; const String nameCopy (methodName.toString()); - LPCOLESTR name = (LPCOLESTR) nameCopy; + LPCOLESTR name = nameCopy.toUTF16(); DISPID id = 0; if (source->GetIDsOfNames (IID_NULL, (LPOLESTR*) &name, 1, 0, &id) == S_OK) { @@ -374,7 +374,7 @@ void juceVarToVariant (const var& v, VARIANT& dest) else if (v.isString()) { dest.vt = VT_BSTR; - dest.bstrVal = SysAllocString (v.toString()); + dest.bstrVal = SysAllocString (v.toString().toUTF16()); } else if (v.isObject()) { @@ -411,7 +411,7 @@ const var variantTojuceVar (const VARIANT& v) case VT_UINT: return var ((int) v.uintVal); case VT_R4: return var ((double) v.fltVal); case VT_R8: return var ((double) v.dblVal); - case VT_BSTR: return var (v.bstrVal); + case VT_BSTR: return var (String (v.bstrVal)); case VT_BOOL: return var (v.boolVal ? true : false); case VT_DISPATCH: return var (new DynamicObjectWrappingIDispatch (v.pdispVal)); default: @@ -541,14 +541,14 @@ static const String getExeVersion (const String& exeFileName, const String& fiel { String resultString; DWORD pointlessWin32Variable; - DWORD size = GetFileVersionInfoSize (exeFileName, &pointlessWin32Variable); + DWORD size = GetFileVersionInfoSize (exeFileName.toUTF16(), &pointlessWin32Variable); if (size > 0) { HeapBlock exeInfo; exeInfo.calloc (size); - if (GetFileVersionInfo (exeFileName, 0, size, exeInfo)) + if (GetFileVersionInfo (exeFileName.toUTF16(), 0, size, exeInfo)) { TCHAR* result = 0; unsigned int resultLen = 0; @@ -556,11 +556,11 @@ static const String getExeVersion (const String& exeFileName, const String& fiel // try the 1200 codepage (Unicode) String queryStr ("\\StringFileInfo\\040904B0\\" + fieldName); - if (! VerQueryValue (exeInfo, (LPTSTR) (LPCTSTR) queryStr, (void**) &result, &resultLen)) + if (! VerQueryValue (exeInfo, (LPTSTR) queryStr.toUTF16().getAddress(), (void**) &result, &resultLen)) { // try the 1252 codepage (Windows Multilingual) queryStr = "\\StringFileInfo\\040904E4\\" + fieldName; - VerQueryValue (exeInfo, (LPTSTR) (LPCTSTR) queryStr, (void**) &result, &resultLen); + VerQueryValue (exeInfo, (LPTSTR) queryStr.toUTF16().getAddress(), (void**) &result, &resultLen); } resultString = String (result, resultLen); diff --git a/extras/juce demo/Source/jucedemo_headers.h b/extras/juce demo/Source/jucedemo_headers.h index 518c63ca66..36a5e27c73 100644 --- a/extras/juce demo/Source/jucedemo_headers.h +++ b/extras/juce demo/Source/jucedemo_headers.h @@ -29,7 +29,7 @@ // include the JUCE headers.. #include "../JuceLibraryCode/JuceHeader.h" -#if JUCE_IOS || JUCE_LINUX +#if JUCE_IOS || JUCE_LINUX || JUCE_ANDROID #undef JUCE_USE_CAMERA #endif diff --git a/juce_Config.h b/juce_Config.h index e812b52b1e..eb96130714 100644 --- a/juce_Config.h +++ b/juce_Config.h @@ -101,7 +101,7 @@ If you're building on Windows, you'll need to have the Apple QuickTime SDK installed, and its header files will need to be on your include path. */ -#if ! (defined (JUCE_QUICKTIME) || JUCE_LINUX || JUCE_IOS || (JUCE_WINDOWS && ! JUCE_MSVC)) +#if ! (defined (JUCE_QUICKTIME) || JUCE_LINUX || JUCE_IOS || JUCE_ANDROID || (JUCE_WINDOWS && ! JUCE_MSVC)) #define JUCE_QUICKTIME 0 #endif @@ -113,7 +113,7 @@ /** JUCE_OPENGL: Enables the OpenGLComponent class (available on all platforms). If you're not using OpenGL, you might want to turn this off to reduce your binary's size. */ -#ifndef JUCE_OPENGL +#if ! (defined (JUCE_OPENGL) || JUCE_ANDROID) #define JUCE_OPENGL 1 #endif diff --git a/juce_amalgamated.cpp b/juce_amalgamated.cpp index c0b57dd60c..70c08444a2 100644 --- a/juce_amalgamated.cpp +++ b/juce_amalgamated.cpp @@ -270,7 +270,7 @@ If you're building on Windows, you'll need to have the Apple QuickTime SDK installed, and its header files will need to be on your include path. */ -#if ! (defined (JUCE_QUICKTIME) || JUCE_LINUX || JUCE_IOS || (JUCE_WINDOWS && ! JUCE_MSVC)) +#if ! (defined (JUCE_QUICKTIME) || JUCE_LINUX || JUCE_IOS || JUCE_ANDROID || (JUCE_WINDOWS && ! JUCE_MSVC)) #define JUCE_QUICKTIME 0 #endif @@ -281,7 +281,7 @@ /** JUCE_OPENGL: Enables the OpenGLComponent class (available on all platforms). If you're not using OpenGL, you might want to turn this off to reduce your binary's size. */ -#ifndef JUCE_OPENGL +#if ! (defined (JUCE_OPENGL) || JUCE_ANDROID) #define JUCE_OPENGL 1 #endif @@ -933,6 +933,7 @@ protected: #ifndef __JUCE_ANDROID_NATIVEINCLUDES_JUCEHEADER__ #define __JUCE_ANDROID_NATIVEINCLUDES_JUCEHEADER__ +#include #include #include #include @@ -248876,7 +248877,7 @@ private: // doing a direct load of the COM object (only available via the juce_createASIOAudioIODeviceForGUID function). if (optionalDllForDirectLoading.isNotEmpty()) { - HMODULE h = LoadLibrary (optionalDllForDirectLoading); + HMODULE h = LoadLibrary (optionalDllForDirectLoading.toUTF16()); if (h != 0) { @@ -249878,7 +249879,7 @@ private: { HKEY subKey; - if (RegOpenKeyEx (hk, keyName, 0, KEY_READ, &subKey) == ERROR_SUCCESS) + if (RegOpenKeyEx (hk, keyName.toUTF16(), 0, KEY_READ, &subKey) == ERROR_SUCCESS) { WCHAR buf [256]; zerostruct (buf); @@ -252566,7 +252567,7 @@ public: if (SUCCEEDED (hr)) { - hr = fileSink->SetFileName (file.getFullPathName(), 0); + hr = fileSink->SetFileName (file.getFullPathName().toUTF16(), 0); if (SUCCEEDED (hr)) { @@ -252610,7 +252611,7 @@ public: .replace ("$AVGTIMEPERFRAME", String (10000000 / maxFramesPerSecond)); ComSmartPtr currentProfile; - hr = profileManager->LoadProfileByData ((const WCHAR*) prof, currentProfile.resetAndGetPointerAddress()); + hr = profileManager->LoadProfileByData (prof.toUTF16(), currentProfile.resetAndGetPointerAddress()); hr = asfConfig->ConfigureFilterUsingProfile (currentProfile); if (SUCCEEDED (hr)) @@ -278443,6 +278444,221 @@ BEGIN_JUCE_NAMESPACE // Now include the actual code files.. +/*** Start of inlined file: juce_android_SystemStats.cpp ***/ +// (This file gets included by juce_android_NativeCode.cpp, rather than being +// compiled on its own). +#if JUCE_INCLUDED_FILE + +END_JUCE_NAMESPACE +extern JUCE_NAMESPACE::JUCEApplication* juce_CreateApplication(); // (from START_JUCE_APPLICATION) +BEGIN_JUCE_NAMESPACE + +class AndroidJavaCallbacks +{ +public: + AndroidJavaCallbacks() : env (0) + { + } + + void initialise (JNIEnv* env_, jobject activity) + { + env = env_; + activityClass = (jclass) env->NewGlobalRef (env->GetObjectClass (activity)); + + printToConsole = env->GetStaticMethodID (activityClass, "printToConsole", "(Ljava/lang/String;)V"); + jassert (printToConsole != 0); + } + + void shutdown() + { + if (env != 0) + { + env->DeleteGlobalRef (activityClass); + } + } + + JNIEnv* env; + + jclass activityClass; + jmethodID printToConsole; +}; + +static AndroidJavaCallbacks androidEnv; + +#define JUCE_JNI_CALLBACK(className, methodName, returnType, params) \ + extern "C" __attribute__ ((visibility("default"))) returnType Java_com_juce_launch_ ## className ## _ ## methodName params + +JUCE_JNI_CALLBACK (JuceAppActivity, launchApp, void, (JNIEnv* env, jobject activity)) +{ + androidEnv.initialise (env, activity); + + JUCEApplication::createInstance = &juce_CreateApplication; + + initialiseJuce_GUI(); + + if (! JUCEApplication::createInstance()->initialiseApp (String::empty)) + exit (0); +} + +JUCE_JNI_CALLBACK (JuceAppActivity, quitApp, void, (JNIEnv* env, jobject activity)) +{ + JUCEApplication::appWillTerminateByForce(); + + androidEnv.shutdown(); +} + +void PlatformUtilities::beep() +{ + // TODO +} + +void Logger::outputDebugString (const String& text) +{ + androidEnv.env->CallStaticVoidMethod (androidEnv.activityClass, androidEnv.printToConsole, + androidEnv.env->NewStringUTF (text.toUTF8())); +} + +SystemStats::OperatingSystemType SystemStats::getOperatingSystemType() +{ + return Android; +} + +const String SystemStats::getOperatingSystemName() +{ + return "Android"; +} + +bool SystemStats::isOperatingSystem64Bit() +{ + #if JUCE_64BIT + return true; + #else + return false; + #endif +} + +namespace AndroidStatsHelpers +{ + // TODO + const String getCpuInfo (const char* const key) + { + StringArray lines; + lines.addLines (File ("/proc/cpuinfo").loadFileAsString()); + + for (int i = lines.size(); --i >= 0;) // (NB - it's important that this runs in reverse order) + if (lines[i].startsWithIgnoreCase (key)) + return lines[i].fromFirstOccurrenceOf (":", false, false).trim(); + + return String::empty; + } +} + +const String SystemStats::getCpuVendor() +{ + return AndroidStatsHelpers::getCpuInfo ("vendor_id"); +} + +int SystemStats::getCpuSpeedInMegaherz() +{ + return roundToInt (AndroidStatsHelpers::getCpuInfo ("cpu MHz").getFloatValue()); +} + +int SystemStats::getMemorySizeInMegabytes() +{ + // TODO + + struct sysinfo sysi; + + if (sysinfo (&sysi) == 0) + return (sysi.totalram * sysi.mem_unit / (1024 * 1024)); + + return 0; +} + +int SystemStats::getPageSize() +{ + // TODO + return sysconf (_SC_PAGESIZE); +} + +const String SystemStats::getLogonName() +{ + // TODO + + const char* user = getenv ("USER"); + + if (user == 0) + { + struct passwd* const pw = getpwuid (getuid()); + if (pw != 0) + user = pw->pw_name; + } + + return String::fromUTF8 (user); +} + +const String SystemStats::getFullUserName() +{ + return getLogonName(); +} + +void SystemStats::initialiseStats() +{ + // TODO + const String flags (AndroidStatsHelpers::getCpuInfo ("flags")); + cpuFlags.hasMMX = flags.contains ("mmx"); + cpuFlags.hasSSE = flags.contains ("sse"); + cpuFlags.hasSSE2 = flags.contains ("sse2"); + cpuFlags.has3DNow = flags.contains ("3dnow"); + + // TODO + cpuFlags.numCpus = AndroidStatsHelpers::getCpuInfo ("processor").getIntValue() + 1; +} + +void PlatformUtilities::fpuReset() {} + +uint32 juce_millisecondsSinceStartup() throw() +{ + // TODO + timespec t; + clock_gettime (CLOCK_MONOTONIC, &t); + + return t.tv_sec * 1000 + t.tv_nsec / 1000000; +} + +int64 Time::getHighResolutionTicks() throw() +{ + // TODO + + timespec t; + clock_gettime (CLOCK_MONOTONIC, &t); + + return (t.tv_sec * (int64) 1000000) + (t.tv_nsec / (int64) 1000); +} + +int64 Time::getHighResolutionTicksPerSecond() throw() +{ + // TODO + + return 1000000; // (microseconds) +} + +double Time::getMillisecondCounterHiRes() throw() +{ + return getHighResolutionTicks() * 0.001; +} + +bool Time::setSystemTimeToThisTime() const +{ + jassertfalse; + return false; +} + +#endif +/*** End of inlined file: juce_android_SystemStats.cpp ***/ + + // (must be first) + /*** Start of inlined file: juce_posix_SharedCode.h ***/ /* This file contains posix routines that are common to both the Linux and Mac builds. @@ -279665,162 +279881,6 @@ int NamedPipe::write (const void* sourceBuffer, int numBytesToWrite, int timeOut /*** End of inlined file: juce_posix_NamedPipe.cpp ***/ -/*** Start of inlined file: juce_android_SystemStats.cpp ***/ -// (This file gets included by juce_android_NativeCode.cpp, rather than being -// compiled on its own). -#if JUCE_INCLUDED_FILE - -void PlatformUtilities::beep() -{ - // TODO -} - -void Logger::outputDebugString (const String& text) -{ - // TODO - std::cerr << text << std::endl; -} - -SystemStats::OperatingSystemType SystemStats::getOperatingSystemType() -{ - return Android; -} - -const String SystemStats::getOperatingSystemName() -{ - return "Android"; -} - -bool SystemStats::isOperatingSystem64Bit() -{ - #if JUCE_64BIT - return true; - #else - return false; - #endif -} - -namespace LinuxStatsHelpers -{ - // TODO - const String getCpuInfo (const char* const key) - { - StringArray lines; - lines.addLines (File ("/proc/cpuinfo").loadFileAsString()); - - for (int i = lines.size(); --i >= 0;) // (NB - it's important that this runs in reverse order) - if (lines[i].startsWithIgnoreCase (key)) - return lines[i].fromFirstOccurrenceOf (":", false, false).trim(); - - return String::empty; - } -} - -const String SystemStats::getCpuVendor() -{ - return LinuxStatsHelpers::getCpuInfo ("vendor_id"); -} - -int SystemStats::getCpuSpeedInMegaherz() -{ - return roundToInt (LinuxStatsHelpers::getCpuInfo ("cpu MHz").getFloatValue()); -} - -int SystemStats::getMemorySizeInMegabytes() -{ - // TODO - - struct sysinfo sysi; - - if (sysinfo (&sysi) == 0) - return (sysi.totalram * sysi.mem_unit / (1024 * 1024)); - - return 0; -} - -int SystemStats::getPageSize() -{ - // TODO - return sysconf (_SC_PAGESIZE); -} - -const String SystemStats::getLogonName() -{ - // TODO - - const char* user = getenv ("USER"); - - if (user == 0) - { - struct passwd* const pw = getpwuid (getuid()); - if (pw != 0) - user = pw->pw_name; - } - - return String::fromUTF8 (user); -} - -const String SystemStats::getFullUserName() -{ - return getLogonName(); -} - -void SystemStats::initialiseStats() -{ - // TODO - const String flags (LinuxStatsHelpers::getCpuInfo ("flags")); - cpuFlags.hasMMX = flags.contains ("mmx"); - cpuFlags.hasSSE = flags.contains ("sse"); - cpuFlags.hasSSE2 = flags.contains ("sse2"); - cpuFlags.has3DNow = flags.contains ("3dnow"); - - // TODO - cpuFlags.numCpus = LinuxStatsHelpers::getCpuInfo ("processor").getIntValue() + 1; -} - -void PlatformUtilities::fpuReset() {} - -uint32 juce_millisecondsSinceStartup() throw() -{ - // TODO - timespec t; - clock_gettime (CLOCK_MONOTONIC, &t); - - return t.tv_sec * 1000 + t.tv_nsec / 1000000; -} - -int64 Time::getHighResolutionTicks() throw() -{ - // TODO - - timespec t; - clock_gettime (CLOCK_MONOTONIC, &t); - - return (t.tv_sec * (int64) 1000000) + (t.tv_nsec / (int64) 1000); -} - -int64 Time::getHighResolutionTicksPerSecond() throw() -{ - // TODO - - return 1000000; // (microseconds) -} - -double Time::getMillisecondCounterHiRes() throw() -{ - return getHighResolutionTicks() * 0.001; -} - -bool Time::setSystemTimeToThisTime() const -{ - jassertfalse; - return false; -} - -#endif -/*** End of inlined file: juce_android_SystemStats.cpp ***/ - - /*** Start of inlined file: juce_android_Threads.cpp ***/ // (This file gets included by juce_android_NativeCode.cpp, rather than being // compiled on its own). diff --git a/juce_amalgamated.h b/juce_amalgamated.h index c84f01e511..e311ae6102 100644 --- a/juce_amalgamated.h +++ b/juce_amalgamated.h @@ -73,7 +73,7 @@ namespace JuceDummyNamespace {} */ #define JUCE_MAJOR_VERSION 1 #define JUCE_MINOR_VERSION 53 -#define JUCE_BUILDNUMBER 20 +#define JUCE_BUILDNUMBER 21 /** Current Juce version number. @@ -318,7 +318,7 @@ namespace JuceDummyNamespace {} If you're building on Windows, you'll need to have the Apple QuickTime SDK installed, and its header files will need to be on your include path. */ -#if ! (defined (JUCE_QUICKTIME) || JUCE_LINUX || JUCE_IOS || (JUCE_WINDOWS && ! JUCE_MSVC)) +#if ! (defined (JUCE_QUICKTIME) || JUCE_LINUX || JUCE_IOS || JUCE_ANDROID || (JUCE_WINDOWS && ! JUCE_MSVC)) #define JUCE_QUICKTIME 0 #endif @@ -329,7 +329,7 @@ namespace JuceDummyNamespace {} /** JUCE_OPENGL: Enables the OpenGLComponent class (available on all platforms). If you're not using OpenGL, you might want to turn this off to reduce your binary's size. */ -#ifndef JUCE_OPENGL +#if ! (defined (JUCE_OPENGL) || JUCE_ANDROID) #define JUCE_OPENGL 1 #endif @@ -597,9 +597,7 @@ namespace JuceDummyNamespace {} #endif #elif JUCE_MAC #define juce_breakDebugger Debugger(); - #elif JUCE_IOS - #define juce_breakDebugger kill (0, SIGTRAP); - #elif JUCE_LINUX + #elif JUCE_IOS || JUCE_LINUX || JUCE_ANDROID #define juce_breakDebugger kill (0, SIGTRAP); #endif @@ -15911,7 +15909,11 @@ public: See the JUCEApplication class documentation (juce_Application.h) for more details. */ -#if defined (JUCE_GCC) || defined (__MWERKS__) +#if JUCE_ANDROID + #define START_JUCE_APPLICATION(AppClass) \ + JUCE_NAMESPACE::JUCEApplication* juce_CreateApplication() { return new AppClass(); } + +#elif defined (JUCE_GCC) || defined (__MWERKS__) #define START_JUCE_APPLICATION(AppClass) \ static JUCE_NAMESPACE::JUCEApplication* juce_CreateApplication() { return new AppClass(); } \ diff --git a/src/core/juce_Initialisation.h b/src/core/juce_Initialisation.h index 3beafd9dfa..f175aab0bb 100644 --- a/src/core/juce_Initialisation.h +++ b/src/core/juce_Initialisation.h @@ -134,7 +134,11 @@ public: See the JUCEApplication class documentation (juce_Application.h) for more details. */ -#if defined (JUCE_GCC) || defined (__MWERKS__) +#if JUCE_ANDROID + #define START_JUCE_APPLICATION(AppClass) \ + JUCE_NAMESPACE::JUCEApplication* juce_CreateApplication() { return new AppClass(); } + +#elif defined (JUCE_GCC) || defined (__MWERKS__) #define START_JUCE_APPLICATION(AppClass) \ static JUCE_NAMESPACE::JUCEApplication* juce_CreateApplication() { return new AppClass(); } \ diff --git a/src/core/juce_PlatformDefs.h b/src/core/juce_PlatformDefs.h index d3f4aa7c82..e8642cd0d7 100644 --- a/src/core/juce_PlatformDefs.h +++ b/src/core/juce_PlatformDefs.h @@ -98,9 +98,7 @@ #endif #elif JUCE_MAC #define juce_breakDebugger Debugger(); - #elif JUCE_IOS - #define juce_breakDebugger kill (0, SIGTRAP); - #elif JUCE_LINUX + #elif JUCE_IOS || JUCE_LINUX || JUCE_ANDROID #define juce_breakDebugger kill (0, SIGTRAP); #endif diff --git a/src/core/juce_StandardHeader.h b/src/core/juce_StandardHeader.h index 716edcc45c..c59a4a102b 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 53 -#define JUCE_BUILDNUMBER 20 +#define JUCE_BUILDNUMBER 21 /** Current Juce version number. diff --git a/src/native/android/juce_android_Messaging.cpp b/src/native/android/juce_android_Messaging.cpp index 9bcaedc019..daf5d97905 100644 --- a/src/native/android/juce_android_Messaging.cpp +++ b/src/native/android/juce_android_Messaging.cpp @@ -110,5 +110,4 @@ void MessageManager::broadcastMessage (const String&) { } - #endif diff --git a/src/native/android/juce_android_NativeCode.cpp b/src/native/android/juce_android_NativeCode.cpp index f2f437c67f..519c5cf998 100644 --- a/src/native/android/juce_android_NativeCode.cpp +++ b/src/native/android/juce_android_NativeCode.cpp @@ -94,10 +94,10 @@ BEGIN_JUCE_NAMESPACE #define JUCE_INCLUDED_FILE 1 // Now include the actual code files.. +#include "juce_android_SystemStats.cpp" // (must be first) #include "../common/juce_posix_SharedCode.h" #include "juce_android_Files.cpp" #include "../common/juce_posix_NamedPipe.cpp" -#include "juce_android_SystemStats.cpp" #include "juce_android_Threads.cpp" #include "juce_android_Network.cpp" #include "juce_android_Messaging.cpp" diff --git a/src/native/android/juce_android_NativeIncludes.h b/src/native/android/juce_android_NativeIncludes.h index 7e078097dc..84bc63afd2 100644 --- a/src/native/android/juce_android_NativeIncludes.h +++ b/src/native/android/juce_android_NativeIncludes.h @@ -31,6 +31,7 @@ #include "../../core/juce_TargetPlatform.h" #include "../../../juce_Config.h" +#include #include #include #include diff --git a/src/native/android/juce_android_SystemStats.cpp b/src/native/android/juce_android_SystemStats.cpp index aebbe08f2e..a35ac2129e 100644 --- a/src/native/android/juce_android_SystemStats.cpp +++ b/src/native/android/juce_android_SystemStats.cpp @@ -27,6 +27,68 @@ // compiled on its own). #if JUCE_INCLUDED_FILE +END_JUCE_NAMESPACE +extern JUCE_NAMESPACE::JUCEApplication* juce_CreateApplication(); // (from START_JUCE_APPLICATION) +BEGIN_JUCE_NAMESPACE + +//============================================================================== +class AndroidJavaCallbacks +{ +public: + AndroidJavaCallbacks() : env (0) + { + } + + void initialise (JNIEnv* env_, jobject activity) + { + env = env_; + activityClass = (jclass) env->NewGlobalRef (env->GetObjectClass (activity)); + + printToConsole = env->GetStaticMethodID (activityClass, "printToConsole", "(Ljava/lang/String;)V"); + jassert (printToConsole != 0); + } + + void shutdown() + { + if (env != 0) + { + env->DeleteGlobalRef (activityClass); + } + } + + //============================================================================== + JNIEnv* env; + + jclass activityClass; + jmethodID printToConsole; +}; + +static AndroidJavaCallbacks androidEnv; + +//============================================================================== +#define JUCE_JNI_CALLBACK(className, methodName, returnType, params) \ + extern "C" __attribute__ ((visibility("default"))) returnType Java_com_juce_launch_ ## className ## _ ## methodName params + +//============================================================================== +JUCE_JNI_CALLBACK (JuceAppActivity, launchApp, void, (JNIEnv* env, jobject activity)) +{ + androidEnv.initialise (env, activity); + + JUCEApplication::createInstance = &juce_CreateApplication; + + initialiseJuce_GUI(); + + if (! JUCEApplication::createInstance()->initialiseApp (String::empty)) + exit (0); +} + +JUCE_JNI_CALLBACK (JuceAppActivity, quitApp, void, (JNIEnv* env, jobject activity)) +{ + JUCEApplication::appWillTerminateByForce(); + + androidEnv.shutdown(); +} + //============================================================================== void PlatformUtilities::beep() { @@ -36,8 +98,8 @@ void PlatformUtilities::beep() //============================================================================== void Logger::outputDebugString (const String& text) { - // TODO - std::cerr << text << std::endl; + androidEnv.env->CallStaticVoidMethod (androidEnv.activityClass, androidEnv.printToConsole, + androidEnv.env->NewStringUTF (text.toUTF8())); } //============================================================================== @@ -61,7 +123,7 @@ bool SystemStats::isOperatingSystem64Bit() } //============================================================================== -namespace LinuxStatsHelpers +namespace AndroidStatsHelpers { // TODO const String getCpuInfo (const char* const key) @@ -79,12 +141,12 @@ namespace LinuxStatsHelpers const String SystemStats::getCpuVendor() { - return LinuxStatsHelpers::getCpuInfo ("vendor_id"); + return AndroidStatsHelpers::getCpuInfo ("vendor_id"); } int SystemStats::getCpuSpeedInMegaherz() { - return roundToInt (LinuxStatsHelpers::getCpuInfo ("cpu MHz").getFloatValue()); + return roundToInt (AndroidStatsHelpers::getCpuInfo ("cpu MHz").getFloatValue()); } int SystemStats::getMemorySizeInMegabytes() @@ -131,14 +193,14 @@ const String SystemStats::getFullUserName() void SystemStats::initialiseStats() { // TODO - const String flags (LinuxStatsHelpers::getCpuInfo ("flags")); + const String flags (AndroidStatsHelpers::getCpuInfo ("flags")); cpuFlags.hasMMX = flags.contains ("mmx"); cpuFlags.hasSSE = flags.contains ("sse"); cpuFlags.hasSSE2 = flags.contains ("sse2"); cpuFlags.has3DNow = flags.contains ("3dnow"); // TODO - cpuFlags.numCpus = LinuxStatsHelpers::getCpuInfo ("processor").getIntValue() + 1; + cpuFlags.numCpus = AndroidStatsHelpers::getCpuInfo ("processor").getIntValue() + 1; } void PlatformUtilities::fpuReset() {} diff --git a/src/native/windows/juce_win32_ASIO.cpp b/src/native/windows/juce_win32_ASIO.cpp index a7ab75ff8e..fef7fcd62d 100644 --- a/src/native/windows/juce_win32_ASIO.cpp +++ b/src/native/windows/juce_win32_ASIO.cpp @@ -809,7 +809,7 @@ private: // doing a direct load of the COM object (only available via the juce_createASIOAudioIODeviceForGUID function). if (optionalDllForDirectLoading.isNotEmpty()) { - HMODULE h = LoadLibrary (optionalDllForDirectLoading); + HMODULE h = LoadLibrary (optionalDllForDirectLoading.toUTF16()); if (h != 0) { @@ -1822,7 +1822,7 @@ private: { HKEY subKey; - if (RegOpenKeyEx (hk, keyName, 0, KEY_READ, &subKey) == ERROR_SUCCESS) + if (RegOpenKeyEx (hk, keyName.toUTF16(), 0, KEY_READ, &subKey) == ERROR_SUCCESS) { WCHAR buf [256]; zerostruct (buf); diff --git a/src/native/windows/juce_win32_CameraDevice.cpp b/src/native/windows/juce_win32_CameraDevice.cpp index 50c750e98a..ea3433b666 100644 --- a/src/native/windows/juce_win32_CameraDevice.cpp +++ b/src/native/windows/juce_win32_CameraDevice.cpp @@ -272,7 +272,7 @@ public: if (SUCCEEDED (hr)) { - hr = fileSink->SetFileName (file.getFullPathName(), 0); + hr = fileSink->SetFileName (file.getFullPathName().toUTF16(), 0); if (SUCCEEDED (hr)) { @@ -316,7 +316,7 @@ public: .replace ("$AVGTIMEPERFRAME", String (10000000 / maxFramesPerSecond)); ComSmartPtr currentProfile; - hr = profileManager->LoadProfileByData ((const WCHAR*) prof, currentProfile.resetAndGetPointerAddress()); + hr = profileManager->LoadProfileByData (prof.toUTF16(), currentProfile.resetAndGetPointerAddress()); hr = asfConfig->ConfigureFilterUsingProfile (currentProfile); if (SUCCEEDED (hr))