Skip to content

Commit

Permalink
Reorganized port properties.
Browse files Browse the repository at this point in the history
part of #32

- default, minimum, maximum have namespace with pp: prefix.
- introduced pp:type and pp:enumeration.
  • Loading branch information
atsushieno committed Feb 17, 2021
1 parent 58271bf commit 28b6363
Show file tree
Hide file tree
Showing 5 changed files with 32 additions and 16 deletions.
13 changes: 13 additions & 0 deletions docs/DESIGN_NOTES.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,19 @@ A better alternative is obviously JSON, but for AAP there is a constraining reas

They are important in that if they are not met then hosts will have to cache plugin metadata list like VST hosts. LV2 design is clever in this aspect.

On a related note, the actual parameter names were designed like:

```
#define AAP_PORT_BASE "org.androidaudioplugin.port"
#define AAP_PORT_DEFAULT AAP_PORT_BASE ":default"
```

which were like that it can be directly used as XML namespace prefix (because BASE does not contain a ':') while keeping things pseudo-globally-unique, or JSON object keys.
Since we were using an XML parser that does not support XML Namespaces (tinyxml2), it could work like a hacky solution.
But since we cannot switch to JSON anyways, we rather went back to the basics and eliminated any XML parsing bits from native code on Android, and used authentic XML parser (libxml2) on desktop.

At that stage, there is no point of avoiding standard URI format for port property identifiers, so we simply use "urn:" for the parameters. (It can be "http:", but I guess it would be weird if the protocol without 's' will stay forever and if it matches "cool URLs don't change." concept...)

### out-process model

Unlike in-host-process plugin processing, switching process context is important. Considering the performance loss and limited resources on mobile devices, it is best if we can avoid that. However it is inevitable. It will be handled via [NdkBinder](https://developer.android.com/ndk/reference/group/ndk-binder).
Expand Down
4 changes: 2 additions & 2 deletions docs/DEVELOPERS.md
Original file line number Diff line number Diff line change
Expand Up @@ -64,12 +64,12 @@ external fun initialize(lv2Path: String, assets: AssetManager)
The other one with `org.androidaudioplugin.AudioPluginService#Plugins` is to specify an additional XML resource for the service. The `android:resource` attribute indicates that there is `res/xml/aap_metadata.xml` in the project. The file content looks like this:

```
<plugins>
<plugins xmlns:pp="urn:org.androidaudioplugin.port">
<plugin manufacturer="AndroidAudioPluginProject"
name="BareBoneSamplePlugin">
<ports>
<port direction="input" content="midi" name="MidiIn" />
<port direction="input" default="0.5" minimum="0.0" maximum="1.0" content="other" name="ControlIn" />
<port direction="input" pp:default="0.5" pp:minimum="0.0" pp:maximum="1.0" content="other" name="ControlIn" />
<port direction="input" content="audio" name="AudioIn" />
<port direction="output" content="audio" name="AudioOut" />
</ports>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,8 @@ class AudioPluginHostHelper {
const val AAP_ACTION_NAME = "org.androidaudioplugin.AudioPluginService"
const val AAP_METADATA_NAME_PLUGINS = "org.androidaudioplugin.AudioPluginService#Plugins"
const val AAP_METADATA_NAME_EXTENSIONS = "org.androidaudioplugin.AudioPluginService#Extensions"
const val AAP_METADATA_CORE_NS = "urn:org.androidaudioplugin.core"
const val AAP_METADATA_PORT_PROPERTIES_NS = "urn:org.androidaudioplugin.port"

private fun parseAapMetadata(isOutProcess: Boolean, label: String, packageName: String, className: String, xp: XmlPullParser) : AudioPluginServiceInformation {
// TODO: this XML parsing is super hacky so far.
Expand All @@ -28,7 +30,7 @@ class AudioPluginHostHelper {
if (eventType == XmlPullParser.IGNORABLE_WHITESPACE)
continue
if (eventType == XmlPullParser.START_TAG) {
if (xp.name == "plugin") {
if (xp.name == "plugin" && (xp.namespace == "" || xp.namespace == AAP_METADATA_CORE_NS)) {
val name = xp.getAttributeValue(null, "name")
val backend = xp.getAttributeValue(null, "backend")
val version = xp.getAttributeValue(null, "version")
Expand Down Expand Up @@ -59,14 +61,14 @@ class AudioPluginHostHelper {
isOutProcess
)
aapServiceInfo.plugins.add(currentPlugin)
} else if (xp.name == "port") {
} else if (xp.name == "port" && (xp.namespace == "" || xp.namespace == AAP_METADATA_CORE_NS)) {
if (currentPlugin != null) {
val name = xp.getAttributeValue(null, "name")
val direction = xp.getAttributeValue(null, "direction")
val content = xp.getAttributeValue(null, "content")
val default = xp.getAttributeValue(null, "default")
val minimum = xp.getAttributeValue(null, "minimum")
val maximum = xp.getAttributeValue(null, "maximum")
val default = xp.getAttributeValue(AAP_METADATA_PORT_PROPERTIES_NS, "default")
val minimum = xp.getAttributeValue(AAP_METADATA_PORT_PROPERTIES_NS, "minimum")
val maximum = xp.getAttributeValue(AAP_METADATA_PORT_PROPERTIES_NS, "maximum")
val port = PortInformation(
name,
if (direction == "input") PortInformation.PORT_DIRECTION_INPUT else PortInformation.PORT_DIRECTION_OUTPUT,
Expand All @@ -83,7 +85,7 @@ class AudioPluginHostHelper {
}
}
if (eventType == XmlPullParser.END_TAG) {
if (xp.name == "plugin")
if (xp.name == "plugin" && (xp.namespace == "" || xp.namespace == AAP_METADATA_CORE_NS))
currentPlugin = null
}
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<plugins>
<plugins xmlns="urn:org.androidaudioplugin.core" xmlns:pp="urn:org.androidaudioplugin.port">
<plugin name="Flat Filter" category="Effect" author="atsushieno" manufacturer="atsushieno" unique-id="urn:org.androidaudioplugin/samples/aapbarebonepluginsample/FlatFilter" library="libaapbarebonepluginsample.so">
<ports>
<port direction="input" content="audio" name="Left In" />
Expand Down
15 changes: 8 additions & 7 deletions native/androidaudioplugin/core/include/aap/port-properties.h
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@

#define AAP_PORT_BASE "org.androidaudioplugin.port"
#define AAP_PORT_DEFAULT AAP_PORT_BASE ":default"
#define AAP_PORT_MAXIMUM AAP_PORT_BASE ":maximum"
#define AAP_PORT_MINIMUM AAP_PORT_BASE ":minimum"
#define AAP_PORT_OPTIONAL AAP_PORT_BASE ":optional"
#define AAP_PORT_ENUMERATION AAP_PORT_BASE ":enumeration"
#define AAP_PORT_PRIMITIVE_TYPE AAP_PORT_BASE ":primitive-type"
#define AAP_PORT_URL "urn:org.androidaudioplugin.port"
#define AAP_PORT_BASE AAP_PORT_URL "#"
#define AAP_PORT_DEFAULT AAP_PORT_BASE "default"
#define AAP_PORT_MAXIMUM AAP_PORT_BASE "maximum"
#define AAP_PORT_MINIMUM AAP_PORT_BASE "minimum"
#define AAP_PORT_OPTIONAL AAP_PORT_BASE "optional"
#define AAP_PORT_ENUMERATION AAP_PORT_BASE "enumeration"
#define AAP_PORT_TYPE AAP_PORT_BASE "type"

0 comments on commit 28b6363

Please sign in to comment.