Skip to content

Commit

Permalink
more JUCE GUI support implementation code.
Browse files Browse the repository at this point in the history
Now it can render JUCE GUI on the remote SurfaceView.
Inputs still does not work though.
  • Loading branch information
atsushieno committed May 17, 2024
1 parent 3f351d1 commit 07d6a30
Show file tree
Hide file tree
Showing 3 changed files with 44 additions and 4 deletions.
6 changes: 5 additions & 1 deletion aap-modules/aap_audio_processors/juceaap_AAPWrappers.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,8 @@ using namespace juce;
extern juce::AudioProcessor *
createPluginFilter(); // it is defined in each Audio plugin project (by Projucer).

extern "C" void juce_juceEventsAndroidStartApp();

extern "C" { int juce_aap_wrapper_last_error_code{0}; }

#define JUCEAAP_SUCCESS 0
Expand Down Expand Up @@ -213,6 +215,7 @@ class JuceAAPWrapper : juce::AudioPlayHead, juce::AudioProcessorListener {
void addAndroidView(void* parentLinearLayout) {
auto creator = [&] {
auto editor = juce_processor->createEditorIfNeeded();
editor->setVisible(true);
editor->addToDesktop(0, parentLinearLayout);
};
if (juce::MessageManager::getInstance()->isThisTheMessageThread())
Expand Down Expand Up @@ -936,7 +939,7 @@ struct AndroidAudioPluginFactory juceaap_factory{
nullptr
};

extern "C" AndroidAudioPluginFactory *GetJuceAAPFactory() {
JNIEXPORT extern "C" AndroidAudioPluginFactory *GetJuceAAPFactory() {
return &juceaap_factory;
}

Expand All @@ -945,6 +948,7 @@ JNIEXPORT void JNICALL
Java_org_androidaudioplugin_juce_JuceAudioProcessorEditorView_addAndroidComponentPeerViewTo(
JNIEnv *env, jclass clazz, jlong pluginServiceNative, jstring plugin_id, jint instanceId,
jobject parentLinearLayout) {
juce_juceEventsAndroidStartApp();
auto service = (aap::PluginService *) pluginServiceNative;
auto instance = service->getLocalInstance(instanceId);
auto plugin = instance->getPlugin();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ import android.view.ViewGroup
import android.widget.LinearLayout
import org.androidaudioplugin.AudioPluginServiceHelper
import org.androidaudioplugin.AudioPluginViewFactory
import org.androidaudioplugin.NativePluginService

class JuceAudioPluginViewFactory : AudioPluginViewFactory() {
override fun createView(context: Context, pluginId: String, instanceId: Int): View =
Expand All @@ -19,15 +18,15 @@ internal class JuceAudioProcessorEditorView(
private val instanceId: Int) : LinearLayout(context) {

companion object {
// note: adding the view might be asynchronously done (depending on whether it is main thread or not).
@JvmStatic
private external fun addAndroidComponentPeerViewTo(serviceInstance: Long, pluginId: String, instanceId: Int, juceAudioProcessorEditorView: JuceAudioProcessorEditorView)
}

constructor(context: Context) : this(context, "", 0)

init {
layoutParams = ViewGroup.LayoutParams(width, height)
// adding the view is synchronously done.
layoutParams = ViewGroup.LayoutParams(200, 200) // stub values
addAndroidComponentPeerViewTo(AudioPluginServiceHelper.getServiceInstance(pluginId), pluginId, instanceId, this)
}
}
37 changes: 37 additions & 0 deletions juce-patches/7.0.6/support-plugin-ui.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
diff --git a/modules/juce_core/native/juce_Threads_android.cpp b/modules/juce_core/native/juce_Threads_android.cpp
index efbf3a9f6..099e67fb5 100644
--- a/modules/juce_core/native/juce_Threads_android.cpp
+++ b/modules/juce_core/native/juce_Threads_android.cpp
@@ -269,7 +269,7 @@ private:

//==============================================================================
#if JUCE_MODULE_AVAILABLE_juce_events && JUCE_ANDROID
-void juce_juceEventsAndroidStartApp();
+extern "C" void juce_juceEventsAndroidStartApp();
#endif

void Thread::initialiseJUCE (void* jniEnv, void* context)
@@ -303,7 +303,7 @@ void Thread::initialiseJUCE (void* jniEnv, void* context)
JuceActivityWatcher::getInstance();

#if JUCE_MODULE_AVAILABLE_juce_events && JUCE_ANDROID
- juce_juceEventsAndroidStartApp();
+ //juce_juceEventsAndroidStartApp();
#endif
}
}
diff --git a/modules/juce_events/native/juce_Messaging_android.cpp b/modules/juce_events/native/juce_Messaging_android.cpp
index 8062840f2..84f1c7679 100644
--- a/modules/juce_events/native/juce_Messaging_android.cpp
+++ b/modules/juce_events/native/juce_Messaging_android.cpp
@@ -288,8 +288,8 @@ private:
//==============================================================================
File juce_getExecutableFile();

-void juce_juceEventsAndroidStartApp();
-void juce_juceEventsAndroidStartApp()
+extern "C" void juce_juceEventsAndroidStartApp();
+extern "C" void juce_juceEventsAndroidStartApp()
{
auto dllPath = juce_getExecutableFile().getFullPathName();
auto addr = reinterpret_cast<juce::JUCEApplicationBase*(*)()> (DynamicLibrary (dllPath)

0 comments on commit 07d6a30

Please sign in to comment.