Browse Source

Android: add support for Google Oboe (developer preview).

tags/2021-05-28
Lukasz Kozakiewicz 7 years ago
parent
commit
c859b4af1d
12 changed files with 1565 additions and 8 deletions
  1. +22
    -1
      extras/Projucer/Source/ProjectSaving/jucer_ProjectExport_Android.h
  2. +1
    -0
      extras/Projucer/Source/Utility/Helpers/jucer_PresetIDs.h
  3. +1
    -0
      modules/juce_audio_devices/audio_io/juce_AudioDeviceManager.cpp
  4. +4
    -0
      modules/juce_audio_devices/audio_io/juce_AudioIODeviceType.cpp
  5. +2
    -0
      modules/juce_audio_devices/audio_io/juce_AudioIODeviceType.h
  6. +8
    -0
      modules/juce_audio_devices/juce_audio_devices.cpp
  7. +21
    -1
      modules/juce_audio_devices/juce_audio_devices.h
  8. +6
    -0
      modules/juce_audio_devices/native/juce_android_Audio.cpp
  9. +1490
    -0
      modules/juce_audio_devices/native/juce_android_Oboe.cpp
  10. +2
    -1
      modules/juce_core/native/juce_android_JNIHelpers.h
  11. +5
    -2
      modules/juce_core/native/juce_posix_SharedCode.h
  12. +3
    -3
      modules/juce_core/threads/juce_Thread.h

+ 22
- 1
extras/Projucer/Source/ProjectSaving/jucer_ProjectExport_Android.h View File

@@ -103,7 +103,7 @@ public:
ValueWithDefault androidJavaLibs, androidRepositories, androidDependencies, androidScreenOrientation, androidActivityClass,
androidActivitySubClassName, androidActivityBaseClassName, androidManifestCustomXmlElements, androidVersionCode,
androidMinimumSDK, androidTheme, androidSharedLibraries, androidStaticLibraries, androidExtraAssetsFolder,
androidInternetNeeded, androidMicNeeded, androidBluetoothNeeded, androidExternalReadPermission,
androidOboeRepositoryPath, androidInternetNeeded, androidMicNeeded, androidBluetoothNeeded, androidExternalReadPermission,
androidExternalWritePermission, androidInAppBillingPermission, androidVibratePermission,androidOtherPermissions,
androidEnableRemoteNotifications, androidRemoteNotificationsConfigFile, androidEnableContentSharing, androidKeyStore,
androidKeyStorePass, androidKeyAlias, androidKeyAliasPass, gradleVersion, gradleToolchain, androidPluginVersion, buildToolsVersion;
@@ -125,6 +125,7 @@ public:
androidSharedLibraries (settings, Ids::androidSharedLibraries, getUndoManager()),
androidStaticLibraries (settings, Ids::androidStaticLibraries, getUndoManager()),
androidExtraAssetsFolder (settings, Ids::androidExtraAssetsFolder, getUndoManager()),
androidOboeRepositoryPath (settings, Ids::androidOboeRepositoryPath, getUndoManager()),
androidInternetNeeded (settings, Ids::androidInternetNeeded, getUndoManager(), true),
androidMicNeeded (settings, Ids::microphonePermissionNeeded, getUndoManager(), false),
androidBluetoothNeeded (settings, Ids::androidBluetoothNeeded, getUndoManager(), true),
@@ -402,6 +403,14 @@ private:
if (! isLibrary())
mo << "SET(BINARY_NAME \"juce_jni\")" << newLine << newLine;
if (project.getConfigFlag ("JUCE_USE_ANDROID_OBOE").get())
{
String oboePath (androidOboeRepositoryPath.get().toString().quoted());
mo << "SET(OBOE_DIR " << oboePath << ")" << newLine << newLine;
mo << "add_subdirectory (${OBOE_DIR} ./oboe)" << newLine << newLine;
}
String cpufeaturesPath ("${ANDROID_NDK}/sources/android/cpufeatures/cpu-features.c");
mo << "add_library(\"cpufeatures\" STATIC \"" << cpufeaturesPath << "\")" << newLine
<< "set_source_files_properties(\"" << cpufeaturesPath << "\" PROPERTIES COMPILE_FLAGS \"-Wno-sign-conversion -Wno-gnu-statement-expression\")" << newLine << newLine;
@@ -419,6 +428,10 @@ private:
mo << " \"" << escapeDirectoryForCmake (path) << "\"" << newLine;
mo << " \"${ANDROID_NDK}/sources/android/cpufeatures\"" << newLine;
if (project.getConfigFlag ("JUCE_USE_ANDROID_OBOE").get())
mo << " \"${OBOE_DIR}/include\"" << newLine;
mo << ")" << newLine << newLine;
}
@@ -548,6 +561,10 @@ private:
mo << " \"cpufeatures\"" << newLine;
}
if (project.getConfigFlag ("JUCE_USE_ANDROID_OBOE").get())
mo << " \"oboe\"" << newLine;
mo << ")" << newLine;
overwriteFileIfDifferentOrThrow (file, mo);
@@ -892,6 +909,10 @@ private:
//==============================================================================
void createManifestExporterProperties (PropertyListBuilder& props)
{
props.add (new TextPropertyComponent (androidOboeRepositoryPath, "Oboe repository path", 2048, false),
"Path to the root of Oboe repository. Make sure to point Oboe repository to "
"commit with SHA 44c6b6ea9c8fa9b5b74cbd60f355068b57b50b37 before building.");
props.add (new ChoicePropertyComponent (androidInternetNeeded, "Internet Access"),
"If enabled, this will set the android.permission.INTERNET flag in the manifest.");


+ 1
- 0
extras/Projucer/Source/Utility/Helpers/jucer_PresetIDs.h View File

@@ -191,6 +191,7 @@ namespace Ids
DECLARE_ID (androidVersionCode);
DECLARE_ID (androidSDKPath);
DECLARE_ID (androidNDKPath);
DECLARE_ID (androidOboeRepositoryPath);
DECLARE_ID (androidInternetNeeded);
DECLARE_ID (androidArchitectures);
DECLARE_ID (androidManifestCustomXmlElements);


+ 1
- 0
modules/juce_audio_devices/audio_io/juce_AudioDeviceManager.cpp View File

@@ -158,6 +158,7 @@ void AudioDeviceManager::createAudioDeviceTypes (OwnedArray<AudioIODeviceType>&
addIfNotNull (list, AudioIODeviceType::createAudioIODeviceType_iOSAudio());
addIfNotNull (list, AudioIODeviceType::createAudioIODeviceType_ALSA());
addIfNotNull (list, AudioIODeviceType::createAudioIODeviceType_JACK());
addIfNotNull (list, AudioIODeviceType::createAudioIODeviceType_Oboe());
addIfNotNull (list, AudioIODeviceType::createAudioIODeviceType_OpenSLES());
addIfNotNull (list, AudioIODeviceType::createAudioIODeviceType_Android());
}


+ 4
- 0
modules/juce_audio_devices/audio_io/juce_AudioIODeviceType.cpp View File

@@ -78,4 +78,8 @@ AudioIODeviceType* AudioIODeviceType::createAudioIODeviceType_Android()
AudioIODeviceType* AudioIODeviceType::createAudioIODeviceType_OpenSLES() { return nullptr; }
#endif
#if ! (JUCE_ANDROID && JUCE_USE_ANDROID_OBOE)
AudioIODeviceType* AudioIODeviceType::createAudioIODeviceType_Oboe() { return nullptr; }
#endif
} // namespace juce

+ 2
- 0
modules/juce_audio_devices/audio_io/juce_AudioIODeviceType.h View File

@@ -161,6 +161,8 @@ public:
static AudioIODeviceType* createAudioIODeviceType_Android();
/** Creates an Android OpenSLES device type if it's available on this platform, or returns null. */
static AudioIODeviceType* createAudioIODeviceType_OpenSLES();
/** Creates an Oboe device type if it's available on this platform, or returns null. */
static AudioIODeviceType* createAudioIODeviceType_Oboe();
protected:
explicit AudioIODeviceType (const String& typeName);


+ 8
- 0
modules/juce_audio_devices/juce_audio_devices.cpp View File

@@ -153,6 +153,10 @@
#include <SLES/OpenSLES_AndroidConfiguration.h>
#endif
#if JUCE_USE_ANDROID_OBOE
#include <oboe/Oboe.h>
#endif
#endif
#include "audio_io/juce_AudioDeviceManager.cpp"
@@ -211,6 +215,10 @@
#if JUCE_USE_ANDROID_OPENSLES
#include "native/juce_android_OpenSL.cpp"
#endif
#if JUCE_USE_ANDROID_OBOE
#include "native/juce_android_Oboe.cpp"
#endif
#endif
#if ! JUCE_SYSTEMAUDIOVOL_IMPLEMENTED


+ 21
- 1
modules/juce_audio_devices/juce_audio_devices.h View File

@@ -108,11 +108,31 @@
#define JUCE_JACK 0
#endif
/** Config: JUCE_USE_ANDROID_OBOE
***
DEVELOPER PREVIEW - Oboe is currently in developer preview and
is in active development. This preview allows for early access
and evaluation for developers targeting Android platform.
***
Enables Oboe devices (Android only, API 16 or above). Requires
Oboe repository path to be specified in Android exporter.
*/
#ifndef JUCE_USE_ANDROID_OBOE
#define JUCE_USE_ANDROID_OBOE 0
#endif
#if JUCE_USE_ANDROID_OBOE && JUCE_ANDROID_API_VERSION < 16
#undef JUCE_USE_ANDROID_OBOE
#define JUCE_USE_ANDROID_OBOE 0
#endif
/** Config: JUCE_USE_ANDROID_OPENSLES
Enables OpenSLES devices (Android only).
*/
#ifndef JUCE_USE_ANDROID_OPENSLES
#if JUCE_ANDROID_API_VERSION > 8
#if ! JUCE_USE_ANDROID_OBOE && JUCE_ANDROID_API_VERSION >= 9
#define JUCE_USE_ANDROID_OPENSLES 1
#else
#define JUCE_USE_ANDROID_OPENSLES 0


+ 6
- 0
modules/juce_audio_devices/native/juce_android_Audio.cpp View File

@@ -482,10 +482,16 @@ private:
//==============================================================================
extern bool isOboeAvailable();
extern bool isOpenSLAvailable();
AudioIODeviceType* AudioIODeviceType::createAudioIODeviceType_Android()
{
#if JUCE_USE_ANDROID_OBOE
if (isOboeAvailable())
return nullptr;
#endif
#if JUCE_USE_ANDROID_OPENSLES
if (isOpenSLAvailable())
return nullptr;


+ 1490
- 0
modules/juce_audio_devices/native/juce_android_Oboe.cpp
File diff suppressed because it is too large
View File


+ 2
- 1
modules/juce_core/native/juce_android_JNIHelpers.h View File

@@ -570,7 +570,8 @@ DECLARE_JNI_CLASS (JavaHashMap, "java/util/HashMap");
#undef JNI_CLASS_MEMBERS
#define JNI_CLASS_MEMBERS(METHOD, STATICMETHOD, FIELD, STATICFIELD) \
STATICMETHOD (valueOf, "valueOf", "(I)Ljava/lang/Integer;")
STATICMETHOD (parseInt, "parseInt", "(Ljava/lang/String;I)I") \
STATICMETHOD (valueOf, "valueOf", "(I)Ljava/lang/Integer;")
DECLARE_JNI_CLASS (JavaInteger, "java/lang/Integer");
#undef JNI_CLASS_MEMBERS


+ 5
- 2
modules/juce_core/native/juce_posix_SharedCode.h View File

@@ -929,8 +929,11 @@ extern "C" void* threadEntryProc (void* userData)
return nullptr;
}
#if JUCE_ANDROID && JUCE_MODULE_AVAILABLE_juce_audio_devices && (JUCE_USE_ANDROID_OPENSLES || (! defined(JUCE_USE_ANDROID_OPENSLES) && JUCE_ANDROID_API_VERSION > 8))
#define JUCE_ANDROID_REALTIME_THREAD_AVAILABLE 1
#if JUCE_ANDROID && JUCE_MODULE_AVAILABLE_juce_audio_devices && \
((JUCE_USE_ANDROID_OPENSLES || (! defined(JUCE_USE_ANDROID_OPENSLES) && JUCE_ANDROID_API_VERSION > 8)) \
|| (JUCE_USE_ANDROID_OBOE || (! defined(JUCE_USE_ANDROID_OBOE) && JUCE_ANDROID_API_VERSION > 15)))
#define JUCE_ANDROID_REALTIME_THREAD_AVAILABLE 1
#endif
#if JUCE_ANDROID_REALTIME_THREAD_AVAILABLE


+ 3
- 3
modules/juce_core/threads/juce_Thread.h View File

@@ -200,9 +200,9 @@ public:
for realtime audio processing.
Currently, this priority is identical to priority 9, except when building
for Android with OpenSL support.
for Android with OpenSL/Oboe support.
In this case, JUCE will ask OpenSL to construct a super high priority thread
In this case, JUCE will ask OpenSL/Oboe to construct a super high priority thread
specifically for realtime audio processing.
Note that this priority can only be set **before** the thread has
@@ -210,7 +210,7 @@ public:
priority, is not supported under Android and will assert.
For best performance this thread should yield at regular intervals
and not call any blocking APIS.
and not call any blocking APIs.
@see startThread, setPriority, sleep, WaitableEvent
*/


Loading…
Cancel
Save