lv2: Namespace global variables and explicitly make them private

And fix a LV2_PORT_GROUPS__rearLeft/LV2_PORT_GROUPS__rearRight typo

Part-of: <https://gitlab.freedesktop.org/gstreamer/gst-plugins-bad/-/merge_requests/1125>
This commit is contained in:
Thibault Saunier 2020-04-29 15:12:36 -04:00 committed by GStreamer Merge Bot
parent a0cd455dd0
commit a3595f7e0f
4 changed files with 207 additions and 177 deletions

View file

@ -69,38 +69,37 @@ GST_DEBUG_CATEGORY (lv2_debug);
#error "Unsupported OS" #error "Unsupported OS"
#endif #endif
LilvWorld *world = NULL; LilvWorld *gst_lv2_world_node = NULL;
LilvNode *atom_class = NULL; LilvNode *gst_lv2_audio_node = NULL;
LilvNode *audio_class = NULL; LilvNode *gst_lv2_control_node = NULL;
LilvNode *control_class = NULL; LilvNode *gst_lv2_cv_node = NULL;
LilvNode *cv_class = NULL; LilvNode *gst_lv2_event_node = NULL;
LilvNode *event_class = NULL; LilvNode *gst_lv2_input_node = NULL;
LilvNode *input_class = NULL; LilvNode *gst_lv2_output_node = NULL;
LilvNode *output_class = NULL; LilvNode *gst_lv2_preset_node = NULL;
LilvNode *preset_class = NULL; LilvNode *gst_lv2_state_iface_node = NULL;
LilvNode *state_iface = NULL; LilvNode *gst_lv2_state_uri_node = NULL;
LilvNode *state_uri = NULL;
LilvNode *integer_prop = NULL; LilvNode *gst_lv2_integer_prop_node = NULL;
LilvNode *toggled_prop = NULL; LilvNode *gst_lv2_toggled_prop_node = NULL;
LilvNode *designation_pred = NULL; LilvNode *gst_lv2_designation_pred_node = NULL;
LilvNode *in_place_broken_pred = NULL; LilvNode *gst_lv2_in_place_broken_pred_node = NULL;
LilvNode *optional_pred = NULL; LilvNode *gst_lv2_optional_pred_node = NULL;
LilvNode *group_pred = NULL; LilvNode *gst_lv2_group_pred_node = NULL;
LilvNode *supports_event_pred = NULL; LilvNode *gst_lv2_supports_event_pred_node = NULL;
LilvNode *label_pred = NULL; LilvNode *gst_lv2_label_pred_node = NULL;
LilvNode *center_role = NULL; LilvNode *gst_lv2_center_role_node = NULL;
LilvNode *left_role = NULL; LilvNode *gst_lv2_left_role_node = NULL;
LilvNode *right_role = NULL; LilvNode *gst_lv2_right_role_node = NULL;
LilvNode *rear_center_role = NULL; LilvNode *gst_lv2_rear_center_role_node = NULL;
LilvNode *rear_left_role = NULL; LilvNode *gst_lv2_rear_left_role_node = NULL;
LilvNode *rear_right_role = NULL; LilvNode *gst_lv2_rear_right_role_node = NULL;
LilvNode *lfe_role = NULL; LilvNode *gst_lv2_lfe_role_node = NULL;
LilvNode *center_left_role = NULL; LilvNode *gst_lv2_center_left_role_node = NULL;
LilvNode *center_right_role = NULL; LilvNode *gst_lv2_center_right_role_node = NULL;
LilvNode *side_left_role = NULL; LilvNode *gst_lv2_side_left_role_node = NULL;
LilvNode *side_right_role = NULL; LilvNode *gst_lv2_side_right_role_node = NULL;
GstStructure *lv2_meta_all = NULL; GstStructure *lv2_meta_all = NULL;
@ -131,9 +130,11 @@ lv2_count_ports (const LilvPlugin * lv2plugin, guint * audio_in,
for (i = 0; i < lilv_plugin_get_num_ports (lv2plugin); i++) { for (i = 0; i < lilv_plugin_get_num_ports (lv2plugin); i++) {
const LilvPort *port = lilv_plugin_get_port_by_index (lv2plugin, i); const LilvPort *port = lilv_plugin_get_port_by_index (lv2plugin, i);
if (lilv_port_is_a (lv2plugin, port, audio_class)) { if (lilv_port_is_a (lv2plugin, port, gst_lv2_audio_node)) {
const gboolean is_input = lilv_port_is_a (lv2plugin, port, input_class); const gboolean is_input =
LilvNodes *lv2group = lilv_port_get (lv2plugin, port, group_pred); lilv_port_is_a (lv2plugin, port, gst_lv2_input_node);
LilvNodes *lv2group =
lilv_port_get (lv2plugin, port, gst_lv2_group_pred_node);
if (lv2group) { if (lv2group) {
const gchar *uri = lilv_node_as_uri (lv2group); const gchar *uri = lilv_node_as_uri (lv2group);
@ -149,8 +150,8 @@ lv2_count_ports (const LilvPlugin * lv2plugin, guint * audio_in,
(*audio_in)++; (*audio_in)++;
else else
(*audio_out)++; (*audio_out)++;
} else if (lilv_port_is_a (lv2plugin, port, control_class) || } else if (lilv_port_is_a (lv2plugin, port, gst_lv2_control_node) ||
lilv_port_is_a (lv2plugin, port, cv_class)) { lilv_port_is_a (lv2plugin, port, gst_lv2_cv_node)) {
(*control)++; (*control)++;
} }
} }
@ -163,7 +164,7 @@ lv2_plugin_discover (GstPlugin * plugin)
{ {
guint audio_in, audio_out, control; guint audio_in, audio_out, control;
LilvIter *i; LilvIter *i;
const LilvPlugins *plugins = lilv_world_get_all_plugins (world); const LilvPlugins *plugins = lilv_world_get_all_plugins (gst_lv2_world_node);
for (i = lilv_plugins_begin (plugins); !lilv_plugins_is_end (plugins, i); for (i = lilv_plugins_begin (plugins); !lilv_plugins_is_end (plugins, i);
i = lilv_plugins_next (plugins, i)) { i = lilv_plugins_next (plugins, i)) {
@ -220,8 +221,9 @@ lv2_plugin_discover (GstPlugin * plugin)
} }
/* check supported extensions */ /* check supported extensions */
can_do_presets = lilv_plugin_has_extension_data (lv2plugin, state_iface) can_do_presets =
|| lilv_plugin_has_feature (lv2plugin, state_uri) lilv_plugin_has_extension_data (lv2plugin, gst_lv2_state_iface_node)
|| lilv_plugin_has_feature (lv2plugin, gst_lv2_state_uri_node)
|| (control > 0); || (control > 0);
GST_INFO ("plugin %s can%s do presets", type_name, GST_INFO ("plugin %s can%s do presets", type_name,
(can_do_presets ? "" : "'t")); (can_do_presets ? "" : "'t"));
@ -257,8 +259,8 @@ plugin_init (GstPlugin * plugin)
GST_DEBUG_CATEGORY_INIT (lv2_debug, "lv2", GST_DEBUG_CATEGORY_INIT (lv2_debug, "lv2",
GST_DEBUG_FG_GREEN | GST_DEBUG_BG_BLACK | GST_DEBUG_BOLD, "LV2"); GST_DEBUG_FG_GREEN | GST_DEBUG_BG_BLACK | GST_DEBUG_BOLD, "LV2");
world = lilv_world_new (); gst_lv2_world_node = lilv_world_new ();
lilv_world_load_all (world); lilv_world_load_all (gst_lv2_world_node);
gst_lv2_host_init (); gst_lv2_host_init ();
/* have been added after lilv-0.22.0, which is the last release */ /* have been added after lilv-0.22.0, which is the last release */
@ -269,37 +271,57 @@ plugin_init (GstPlugin * plugin)
#define LILV_URI_CV_PORT "http://lv2plug.in/ns/lv2core#CVPort" #define LILV_URI_CV_PORT "http://lv2plug.in/ns/lv2core#CVPort"
#endif #endif
atom_class = lilv_new_uri (world, LILV_URI_ATOM_PORT); gst_lv2_audio_node = lilv_new_uri (gst_lv2_world_node, LILV_URI_AUDIO_PORT);
audio_class = lilv_new_uri (world, LILV_URI_AUDIO_PORT); gst_lv2_control_node =
control_class = lilv_new_uri (world, LILV_URI_CONTROL_PORT); lilv_new_uri (gst_lv2_world_node, LILV_URI_CONTROL_PORT);
cv_class = lilv_new_uri (world, LILV_URI_CV_PORT); gst_lv2_cv_node = lilv_new_uri (gst_lv2_world_node, LILV_URI_CV_PORT);
event_class = lilv_new_uri (world, LILV_URI_EVENT_PORT); gst_lv2_event_node = lilv_new_uri (gst_lv2_world_node, LILV_URI_EVENT_PORT);
input_class = lilv_new_uri (world, LILV_URI_INPUT_PORT); gst_lv2_input_node = lilv_new_uri (gst_lv2_world_node, LILV_URI_INPUT_PORT);
output_class = lilv_new_uri (world, LILV_URI_OUTPUT_PORT); gst_lv2_output_node = lilv_new_uri (gst_lv2_world_node, LILV_URI_OUTPUT_PORT);
preset_class = lilv_new_uri (world, LV2_PRESETS__Preset); gst_lv2_preset_node = lilv_new_uri (gst_lv2_world_node, LV2_PRESETS__Preset);
state_iface = lilv_new_uri (world, LV2_STATE__interface); gst_lv2_state_iface_node =
state_uri = lilv_new_uri (world, LV2_STATE_URI); lilv_new_uri (gst_lv2_world_node, LV2_STATE__interface);
gst_lv2_state_uri_node = lilv_new_uri (gst_lv2_world_node, LV2_STATE_URI);
integer_prop = lilv_new_uri (world, LV2_CORE__integer); gst_lv2_integer_prop_node =
toggled_prop = lilv_new_uri (world, LV2_CORE__toggled); lilv_new_uri (gst_lv2_world_node, LV2_CORE__integer);
designation_pred = lilv_new_uri (world, LV2_CORE__designation); gst_lv2_toggled_prop_node =
in_place_broken_pred = lilv_new_uri (world, LV2_CORE__inPlaceBroken); lilv_new_uri (gst_lv2_world_node, LV2_CORE__toggled);
optional_pred = lilv_new_uri (world, LV2_CORE__optionalFeature); gst_lv2_designation_pred_node =
group_pred = lilv_new_uri (world, LV2_PORT_GROUPS__group); lilv_new_uri (gst_lv2_world_node, LV2_CORE__designation);
supports_event_pred = lilv_new_uri (world, LV2_EVENT__supportsEvent); gst_lv2_in_place_broken_pred_node =
label_pred = lilv_new_uri (world, LILV_NS_RDFS "label"); lilv_new_uri (gst_lv2_world_node, LV2_CORE__inPlaceBroken);
gst_lv2_optional_pred_node =
lilv_new_uri (gst_lv2_world_node, LV2_CORE__optionalFeature);
gst_lv2_group_pred_node =
lilv_new_uri (gst_lv2_world_node, LV2_PORT_GROUPS__group);
gst_lv2_supports_event_pred_node =
lilv_new_uri (gst_lv2_world_node, LV2_EVENT__supportsEvent);
gst_lv2_label_pred_node =
lilv_new_uri (gst_lv2_world_node, LILV_NS_RDFS "label");
center_role = lilv_new_uri (world, LV2_PORT_GROUPS__center); gst_lv2_center_role_node =
left_role = lilv_new_uri (world, LV2_PORT_GROUPS__left); lilv_new_uri (gst_lv2_world_node, LV2_PORT_GROUPS__center);
right_role = lilv_new_uri (world, LV2_PORT_GROUPS__right); gst_lv2_left_role_node =
rear_center_role = lilv_new_uri (world, LV2_PORT_GROUPS__rearCenter); lilv_new_uri (gst_lv2_world_node, LV2_PORT_GROUPS__left);
rear_left_role = lilv_new_uri (world, LV2_PORT_GROUPS__rearLeft); gst_lv2_right_role_node =
rear_right_role = lilv_new_uri (world, LV2_PORT_GROUPS__rearLeft); lilv_new_uri (gst_lv2_world_node, LV2_PORT_GROUPS__right);
lfe_role = lilv_new_uri (world, LV2_PORT_GROUPS__lowFrequencyEffects); gst_lv2_rear_center_role_node =
center_left_role = lilv_new_uri (world, LV2_PORT_GROUPS__centerLeft); lilv_new_uri (gst_lv2_world_node, LV2_PORT_GROUPS__rearCenter);
center_right_role = lilv_new_uri (world, LV2_PORT_GROUPS__centerRight); gst_lv2_rear_left_role_node =
side_left_role = lilv_new_uri (world, LV2_PORT_GROUPS__sideLeft); lilv_new_uri (gst_lv2_world_node, LV2_PORT_GROUPS__rearLeft);
side_right_role = lilv_new_uri (world, LV2_PORT_GROUPS__sideRight); gst_lv2_rear_right_role_node =
lilv_new_uri (gst_lv2_world_node, LV2_PORT_GROUPS__rearRight);
gst_lv2_lfe_role_node =
lilv_new_uri (gst_lv2_world_node, LV2_PORT_GROUPS__lowFrequencyEffects);
gst_lv2_center_left_role_node =
lilv_new_uri (gst_lv2_world_node, LV2_PORT_GROUPS__centerLeft);
gst_lv2_center_right_role_node =
lilv_new_uri (gst_lv2_world_node, LV2_PORT_GROUPS__centerRight);
gst_lv2_side_left_role_node =
lilv_new_uri (gst_lv2_world_node, LV2_PORT_GROUPS__sideLeft);
gst_lv2_side_right_role_node =
lilv_new_uri (gst_lv2_world_node, LV2_PORT_GROUPS__sideRight);
gst_plugin_add_dependency_simple (plugin, gst_plugin_add_dependency_simple (plugin,
"LV2_PATH:" GST_LV2_ENVVARS, GST_LV2_DEFAULT_PATH, NULL, "LV2_PATH:" GST_LV2_ENVVARS, GST_LV2_DEFAULT_PATH, NULL,
@ -356,39 +378,38 @@ __attribute__ ((destructor))
#endif #endif
static void plugin_cleanup (GstPlugin * plugin) static void plugin_cleanup (GstPlugin * plugin)
{ {
lilv_node_free (atom_class); lilv_node_free (gst_lv2_audio_node);
lilv_node_free (audio_class); lilv_node_free (gst_lv2_control_node);
lilv_node_free (control_class); lilv_node_free (gst_lv2_cv_node);
lilv_node_free (cv_class); lilv_node_free (gst_lv2_event_node);
lilv_node_free (event_class); lilv_node_free (gst_lv2_input_node);
lilv_node_free (input_class); lilv_node_free (gst_lv2_output_node);
lilv_node_free (output_class); lilv_node_free (gst_lv2_preset_node);
lilv_node_free (preset_class); lilv_node_free (gst_lv2_state_iface_node);
lilv_node_free (state_iface); lilv_node_free (gst_lv2_state_uri_node);
lilv_node_free (state_uri);
lilv_node_free (integer_prop); lilv_node_free (gst_lv2_integer_prop_node);
lilv_node_free (toggled_prop); lilv_node_free (gst_lv2_toggled_prop_node);
lilv_node_free (designation_pred); lilv_node_free (gst_lv2_designation_pred_node);
lilv_node_free (in_place_broken_pred); lilv_node_free (gst_lv2_in_place_broken_pred_node);
lilv_node_free (optional_pred); lilv_node_free (gst_lv2_optional_pred_node);
lilv_node_free (group_pred); lilv_node_free (gst_lv2_group_pred_node);
lilv_node_free (supports_event_pred); lilv_node_free (gst_lv2_supports_event_pred_node);
lilv_node_free (label_pred); lilv_node_free (gst_lv2_label_pred_node);
lilv_node_free (center_role); lilv_node_free (gst_lv2_center_role_node);
lilv_node_free (left_role); lilv_node_free (gst_lv2_left_role_node);
lilv_node_free (right_role); lilv_node_free (gst_lv2_right_role_node);
lilv_node_free (rear_center_role); lilv_node_free (gst_lv2_rear_center_role_node);
lilv_node_free (rear_left_role); lilv_node_free (gst_lv2_rear_left_role_node);
lilv_node_free (rear_right_role); lilv_node_free (gst_lv2_rear_right_role_node);
lilv_node_free (lfe_role); lilv_node_free (gst_lv2_lfe_role_node);
lilv_node_free (center_left_role); lilv_node_free (gst_lv2_center_left_role_node);
lilv_node_free (center_right_role); lilv_node_free (gst_lv2_center_right_role_node);
lilv_node_free (side_left_role); lilv_node_free (gst_lv2_side_left_role_node);
lilv_node_free (side_right_role); lilv_node_free (gst_lv2_side_right_role_node);
lilv_world_free (world); lilv_world_free (gst_lv2_world_node);
} }
GST_PLUGIN_DEFINE (GST_VERSION_MAJOR, GST_PLUGIN_DEFINE (GST_VERSION_MAJOR,

View file

@ -28,40 +28,39 @@
#include "gstlv2utils.h" #include "gstlv2utils.h"
extern LilvWorld *world; G_GNUC_INTERNAL extern LilvWorld *gst_lv2_world_node;
extern LilvNode *atom_class; G_GNUC_INTERNAL extern LilvNode *gst_lv2_audio_node;
extern LilvNode *audio_class; G_GNUC_INTERNAL extern LilvNode *gst_lv2_control_node;
extern LilvNode *control_class; G_GNUC_INTERNAL extern LilvNode *gst_lv2_cv_node;
extern LilvNode *cv_class; G_GNUC_INTERNAL extern LilvNode *gst_lv2_event_node;
extern LilvNode *event_class; G_GNUC_INTERNAL extern LilvNode *gst_lv2_input_node;
extern LilvNode *input_class; G_GNUC_INTERNAL extern LilvNode *gst_lv2_output_node;
extern LilvNode *output_class; G_GNUC_INTERNAL extern LilvNode *gst_lv2_preset_node;
extern LilvNode *preset_class; G_GNUC_INTERNAL extern LilvNode *gst_lv2_state_iface_node;
extern LilvNode *state_iface; G_GNUC_INTERNAL extern LilvNode *gst_lv2_state_uri_node;
extern LilvNode *state_uri;
extern LilvNode *integer_prop; G_GNUC_INTERNAL extern LilvNode *gst_lv2_integer_prop_node;
extern LilvNode *toggled_prop; G_GNUC_INTERNAL extern LilvNode *gst_lv2_toggled_prop_node;
extern LilvNode *designation_pred; G_GNUC_INTERNAL extern LilvNode *gst_lv2_designation_pred_node;
extern LilvNode *in_place_broken_pred; G_GNUC_INTERNAL extern LilvNode *gst_lv2_in_place_broken_pred_node;
extern LilvNode *optional_pred; G_GNUC_INTERNAL extern LilvNode *gst_lv2_optional_pred_node;
extern LilvNode *group_pred; G_GNUC_INTERNAL extern LilvNode *gst_lv2_group_pred_node;
extern LilvNode *supports_event_pred; G_GNUC_INTERNAL extern LilvNode *gst_lv2_supports_event_pred_node;
extern LilvNode *label_pred; G_GNUC_INTERNAL extern LilvNode *gst_lv2_label_pred_node;
extern LilvNode *center_role; G_GNUC_INTERNAL extern LilvNode *gst_lv2_center_role_node;
extern LilvNode *left_role; G_GNUC_INTERNAL extern LilvNode *gst_lv2_left_role_node;
extern LilvNode *right_role; G_GNUC_INTERNAL extern LilvNode *gst_lv2_right_role_node;
extern LilvNode *rear_center_role; G_GNUC_INTERNAL extern LilvNode *gst_lv2_rear_center_role_node;
extern LilvNode *rear_left_role; G_GNUC_INTERNAL extern LilvNode *gst_lv2_rear_left_role_node;
extern LilvNode *rear_right_role; G_GNUC_INTERNAL extern LilvNode *gst_lv2_rear_right_role_node;
extern LilvNode *lfe_role; G_GNUC_INTERNAL extern LilvNode *gst_lv2_lfe_role_node;
extern LilvNode *center_left_role; G_GNUC_INTERNAL extern LilvNode *gst_lv2_center_left_role_node;
extern LilvNode *center_right_role; G_GNUC_INTERNAL extern LilvNode *gst_lv2_center_right_role_node;
extern LilvNode *side_left_role; G_GNUC_INTERNAL extern LilvNode *gst_lv2_side_left_role_node;
extern LilvNode *side_right_role; G_GNUC_INTERNAL extern LilvNode *gst_lv2_side_right_role_node;
extern GstStructure *lv2_meta_all; G_GNUC_INTERNAL extern GstStructure *lv2_meta_all;
void gst_lv2_filter_register_element (GstPlugin *plugin, void gst_lv2_filter_register_element (GstPlugin *plugin,
GstStructure * lv2_meta); GstStructure * lv2_meta);

View file

@ -183,37 +183,37 @@ static GstAudioChannelPosition
gst_lv2_filter_role_to_position (LilvNode * role) gst_lv2_filter_role_to_position (LilvNode * role)
{ {
/* Front. Mono and left/right are mututally exclusive */ /* Front. Mono and left/right are mututally exclusive */
if (lilv_node_equals (role, center_role)) { if (lilv_node_equals (role, gst_lv2_center_role_node)) {
return GST_AUDIO_CHANNEL_POSITION_FRONT_CENTER; return GST_AUDIO_CHANNEL_POSITION_FRONT_CENTER;
} else if (lilv_node_equals (role, left_role)) { } else if (lilv_node_equals (role, gst_lv2_left_role_node)) {
return GST_AUDIO_CHANNEL_POSITION_FRONT_LEFT; return GST_AUDIO_CHANNEL_POSITION_FRONT_LEFT;
} else if (lilv_node_equals (role, right_role)) { } else if (lilv_node_equals (role, gst_lv2_right_role_node)) {
return GST_AUDIO_CHANNEL_POSITION_FRONT_RIGHT; return GST_AUDIO_CHANNEL_POSITION_FRONT_RIGHT;
/* Rear. Left/right and center are mututally exclusive */ /* Rear. Left/right and center are mututally exclusive */
} else if (lilv_node_equals (role, rear_center_role)) { } else if (lilv_node_equals (role, gst_lv2_rear_center_role_node)) {
return GST_AUDIO_CHANNEL_POSITION_REAR_CENTER; return GST_AUDIO_CHANNEL_POSITION_REAR_CENTER;
} else if (lilv_node_equals (role, rear_left_role)) { } else if (lilv_node_equals (role, gst_lv2_rear_left_role_node)) {
return GST_AUDIO_CHANNEL_POSITION_REAR_LEFT; return GST_AUDIO_CHANNEL_POSITION_REAR_LEFT;
} else if (lilv_node_equals (role, rear_right_role)) { } else if (lilv_node_equals (role, gst_lv2_rear_right_role_node)) {
return GST_AUDIO_CHANNEL_POSITION_REAR_RIGHT; return GST_AUDIO_CHANNEL_POSITION_REAR_RIGHT;
/* Subwoofer/low-frequency-effects */ /* Subwoofer/low-frequency-effects */
} else if (lilv_node_equals (role, lfe_role)) { } else if (lilv_node_equals (role, gst_lv2_lfe_role_node)) {
return GST_AUDIO_CHANNEL_POSITION_LFE1; return GST_AUDIO_CHANNEL_POSITION_LFE1;
/* Center front speakers. Center and left/right_of_center /* Center front speakers. Center and left/right_of_center
* are mutually exclusive */ * are mutually exclusive */
} else if (lilv_node_equals (role, center_left_role)) { } else if (lilv_node_equals (role, gst_lv2_center_left_role_node)) {
return GST_AUDIO_CHANNEL_POSITION_FRONT_LEFT_OF_CENTER; return GST_AUDIO_CHANNEL_POSITION_FRONT_LEFT_OF_CENTER;
} else if (lilv_node_equals (role, center_right_role)) { } else if (lilv_node_equals (role, gst_lv2_center_right_role_node)) {
return GST_AUDIO_CHANNEL_POSITION_FRONT_RIGHT_OF_CENTER; return GST_AUDIO_CHANNEL_POSITION_FRONT_RIGHT_OF_CENTER;
/* sides */ /* sides */
} else if (lilv_node_equals (role, side_left_role)) { } else if (lilv_node_equals (role, gst_lv2_side_left_role_node)) {
return GST_AUDIO_CHANNEL_POSITION_SIDE_LEFT; return GST_AUDIO_CHANNEL_POSITION_SIDE_LEFT;
} else if (lilv_node_equals (role, side_right_role)) { } else if (lilv_node_equals (role, gst_lv2_side_right_role_node)) {
return GST_AUDIO_CHANNEL_POSITION_SIDE_RIGHT; return GST_AUDIO_CHANNEL_POSITION_SIDE_RIGHT;
} }
@ -531,7 +531,8 @@ gst_lv2_filter_init (GstLV2Filter * self, GstLV2FilterClass * klass)
{ {
gst_lv2_init (&self->lv2, &klass->lv2); gst_lv2_init (&self->lv2, &klass->lv2);
if (!lilv_plugin_has_feature (klass->lv2.plugin, in_place_broken_pred)) if (!lilv_plugin_has_feature (klass->lv2.plugin,
gst_lv2_in_place_broken_pred_node))
gst_base_transform_set_in_place (GST_BASE_TRANSFORM (self), TRUE); gst_base_transform_set_in_place (GST_BASE_TRANSFORM (self), TRUE);
} }

View file

@ -177,7 +177,9 @@ gst_lv2_get_preset_names (GstLV2 * lv2, GstObject * obj)
if (!lv2->presets) { if (!lv2->presets) {
LilvNodes *presets; LilvNodes *presets;
if ((presets = lilv_plugin_get_related (lv2->klass->plugin, preset_class))) { if ((presets =
lilv_plugin_get_related (lv2->klass->plugin,
gst_lv2_preset_node))) {
LilvIter *j; LilvIter *j;
lv2->presets = g_hash_table_new_full (g_str_hash, g_str_equal, g_free, lv2->presets = g_hash_table_new_full (g_str_hash, g_str_equal, g_free,
@ -188,8 +190,10 @@ gst_lv2_get_preset_names (GstLV2 * lv2, GstObject * obj)
const LilvNode *preset = lilv_nodes_get (presets, j); const LilvNode *preset = lilv_nodes_get (presets, j);
LilvNodes *titles; LilvNodes *titles;
lilv_world_load_resource (world, preset); lilv_world_load_resource (gst_lv2_world_node, preset);
titles = lilv_world_find_nodes (world, preset, label_pred, NULL); titles =
lilv_world_find_nodes (gst_lv2_world_node, preset,
gst_lv2_label_pred_node, NULL);
if (titles) { if (titles) {
const LilvNode *title = lilv_nodes_get_first (titles); const LilvNode *title = lilv_nodes_get_first (titles);
g_hash_table_insert (lv2->presets, g_hash_table_insert (lv2->presets,
@ -253,7 +257,8 @@ gboolean
gst_lv2_load_preset (GstLV2 * lv2, GstObject * obj, const gchar * name) gst_lv2_load_preset (GstLV2 * lv2, GstObject * obj, const gchar * name)
{ {
LilvNode *preset = g_hash_table_lookup (lv2->presets, name); LilvNode *preset = g_hash_table_lookup (lv2->presets, name);
LilvState *state = lilv_state_new_from_world (world, &lv2_map, preset); LilvState *state =
lilv_state_new_from_world (gst_lv2_world_node, &lv2_map, preset);
gpointer user_data[] = { lv2->klass, obj }; gpointer user_data[] = { lv2->klass, obj };
GST_INFO_OBJECT (obj, "loading preset <%s>", lilv_node_as_string (preset)); GST_INFO_OBJECT (obj, "loading preset <%s>", lilv_node_as_string (preset));
@ -295,7 +300,7 @@ gst_lv2_save_preset (GstLV2 * lv2, GstObject * obj, const gchar * name)
gpointer user_data[] = { lv2->klass, obj }; gpointer user_data[] = { lv2->klass, obj };
LilvState *state; LilvState *state;
LilvNode *bundle_dir; LilvNode *bundle_dir;
const LilvNode *state_uri; const LilvNode *gst_lv2_state_uri_node;
LilvInstance *instance = lv2->instance; LilvInstance *instance = lv2->instance;
gboolean res; gboolean res;
#ifndef HAVE_LILV_0_22 #ifndef HAVE_LILV_0_22
@ -323,27 +328,27 @@ gst_lv2_save_preset (GstLV2 * lv2, GstObject * obj, const gchar * name)
lilv_state_set_label (state, name); lilv_state_set_label (state, name);
res = lilv_state_save (world, &lv2_map, &lv2_unmap, state, /*uri */ NULL, dir, res = lilv_state_save (gst_lv2_world_node, &lv2_map, &lv2_unmap, state, /*uri */
filename) != 0; NULL, dir, filename) != 0;
/* reload bundle into the world */ /* reload bundle into the gst_lv2_world_node */
bundle_dir = lilv_new_file_uri (world, NULL, dir); bundle_dir = lilv_new_file_uri (gst_lv2_world_node, NULL, dir);
lilv_world_unload_bundle (world, bundle_dir); lilv_world_unload_bundle (gst_lv2_world_node, bundle_dir);
lilv_world_load_bundle (world, bundle_dir); lilv_world_load_bundle (gst_lv2_world_node, bundle_dir);
lilv_node_free (bundle_dir); lilv_node_free (bundle_dir);
#ifdef HAVE_LILV_0_22 #ifdef HAVE_LILV_0_22
state_uri = lilv_state_get_uri (state); gst_lv2_state_uri_node = lilv_state_get_uri (state);
#else #else
filepath = g_build_filename (dir, filename, NULL); filepath = g_build_filename (dir, filename, NULL);
state_uri = lilv_new_uri (world, filepath); gst_lv2_state_uri_node = lilv_new_uri (gst_lv2_world_node, filepath);
g_free (filepath); g_free (filepath);
#endif #endif
lilv_world_load_resource (world, state_uri); lilv_world_load_resource (gst_lv2_world_node, gst_lv2_state_uri_node);
g_hash_table_insert (lv2->presets, g_strdup (name), g_hash_table_insert (lv2->presets, g_strdup (name),
lilv_node_duplicate (state_uri)); lilv_node_duplicate (gst_lv2_state_uri_node));
#ifndef HAVE_LILV_0_22 #ifndef HAVE_LILV_0_22
lilv_node_free ((LilvNode *) state_uri); lilv_node_free ((LilvNode *) gst_lv2_state_uri_node);
#endif #endif
lilv_state_free (state); lilv_state_free (state);
@ -374,10 +379,11 @@ gst_lv2_delete_preset (GstLV2 * lv2, GstObject * obj, const gchar * name)
{ {
#ifdef HAVE_LILV_0_22 #ifdef HAVE_LILV_0_22
LilvNode *preset = g_hash_table_lookup (lv2->presets, name); LilvNode *preset = g_hash_table_lookup (lv2->presets, name);
LilvState *state = lilv_state_new_from_world (world, &lv2_map, preset); LilvState *state =
lilv_state_new_from_world (gst_lv2_world_node, &lv2_map, preset);
lilv_world_unload_resource (world, lilv_state_get_uri (state)); lilv_world_unload_resource (gst_lv2_world_node, lilv_state_get_uri (state));
lilv_state_delete (world, state); lilv_state_delete (gst_lv2_world_node, state);
lilv_state_free (state); lilv_state_free (state);
#endif #endif
g_hash_table_remove (lv2->presets, name); g_hash_table_remove (lv2->presets, name);
@ -624,13 +630,13 @@ gst_lv2_class_get_param_spec (GstLV2Class * klass, GObjectClass * object_class,
lilv_node_as_string (lilv_plugin_get_uri (lv2plugin)), name, nick); lilv_node_as_string (lilv_plugin_get_uri (lv2plugin)), name, nick);
perms = G_PARAM_READABLE; perms = G_PARAM_READABLE;
if (lilv_port_is_a (lv2plugin, port, input_class)) if (lilv_port_is_a (lv2plugin, port, gst_lv2_input_node))
perms |= G_PARAM_WRITABLE | G_PARAM_CONSTRUCT; perms |= G_PARAM_WRITABLE | G_PARAM_CONSTRUCT;
if (lilv_port_is_a (lv2plugin, port, control_class) || if (lilv_port_is_a (lv2plugin, port, gst_lv2_control_node) ||
lilv_port_is_a (lv2plugin, port, cv_class)) lilv_port_is_a (lv2plugin, port, gst_lv2_cv_node))
perms |= GST_PARAM_CONTROLLABLE; perms |= GST_PARAM_CONTROLLABLE;
if (lilv_port_has_property (lv2plugin, port, toggled_prop)) { if (lilv_port_has_property (lv2plugin, port, gst_lv2_toggled_prop_node)) {
ret = g_param_spec_boolean (name, nick, nick, FALSE, perms); ret = g_param_spec_boolean (name, nick, nick, FALSE, perms);
goto done; goto done;
} }
@ -726,7 +732,8 @@ gst_lv2_class_get_param_spec (GstLV2Class * klass, GObjectClass * object_class,
if (enum_type != G_TYPE_INVALID) { if (enum_type != G_TYPE_INVALID) {
ret = g_param_spec_enum (name, nick, nick, enum_type, def, perms); ret = g_param_spec_enum (name, nick, nick, enum_type, def, perms);
} else if (lilv_port_has_property (lv2plugin, port, integer_prop)) } else if (lilv_port_has_property (lv2plugin, port,
gst_lv2_integer_prop_node))
ret = g_param_spec_int (name, nick, nick, lower, upper, def, perms); ret = g_param_spec_int (name, nick, nick, lower, upper, def, perms);
else else
ret = g_param_spec_float (name, nick, nick, lower, upper, def, perms); ret = g_param_spec_float (name, nick, nick, lower, upper, def, perms);
@ -818,14 +825,14 @@ gst_lv2_class_init (GstLV2Class * lv2_class, GType type)
GstStructure *lv2_meta = g_value_get_boxed (value); GstStructure *lv2_meta = g_value_get_boxed (value);
const LilvPlugin *lv2plugin; const LilvPlugin *lv2plugin;
guint j, in_pad_index = 0, out_pad_index = 0; guint j, in_pad_index = 0, out_pad_index = 0;
const LilvPlugins *plugins = lilv_world_get_all_plugins (world); const LilvPlugins *plugins = lilv_world_get_all_plugins (gst_lv2_world_node);
LilvNode *plugin_uri; LilvNode *plugin_uri;
const gchar *element_uri; const gchar *element_uri;
GST_DEBUG ("LV2 initializing class"); GST_DEBUG ("LV2 initializing class");
element_uri = gst_structure_get_string (lv2_meta, "element-uri"); element_uri = gst_structure_get_string (lv2_meta, "element-uri");
plugin_uri = lilv_new_uri (world, element_uri); plugin_uri = lilv_new_uri (gst_lv2_world_node, element_uri);
g_assert (plugin_uri); g_assert (plugin_uri);
lv2plugin = lilv_plugins_get_by_uri (plugins, plugin_uri); lv2plugin = lilv_plugins_get_by_uri (plugins, plugin_uri);
g_assert (lv2plugin); g_assert (lv2plugin);
@ -842,11 +849,13 @@ gst_lv2_class_init (GstLV2Class * lv2_class, GType type)
/* find ports and groups */ /* find ports and groups */
for (j = 0; j < lilv_plugin_get_num_ports (lv2plugin); j++) { for (j = 0; j < lilv_plugin_get_num_ports (lv2plugin); j++) {
const LilvPort *port = lilv_plugin_get_port_by_index (lv2plugin, j); const LilvPort *port = lilv_plugin_get_port_by_index (lv2plugin, j);
const gboolean is_input = lilv_port_is_a (lv2plugin, port, input_class); const gboolean is_input =
lilv_port_is_a (lv2plugin, port, gst_lv2_input_node);
const gboolean is_optional = lilv_port_has_property (lv2plugin, port, const gboolean is_optional = lilv_port_has_property (lv2plugin, port,
optional_pred); gst_lv2_optional_pred_node);
GstLV2Port desc = { j, GST_LV2_PORT_AUDIO, -1, }; GstLV2Port desc = { j, GST_LV2_PORT_AUDIO, -1, };
LilvNodes *lv2group = lilv_port_get (lv2plugin, port, group_pred); LilvNodes *lv2group =
lilv_port_get (lv2plugin, port, gst_lv2_group_pred_node);
/* FIXME Handle channels positioning /* FIXME Handle channels positioning
* GstAudioChannelPosition position = GST_AUDIO_CHANNEL_POSITION_INVALID; */ * GstAudioChannelPosition position = GST_AUDIO_CHANNEL_POSITION_INVALID; */
@ -864,7 +873,7 @@ gst_lv2_class_init (GstLV2Class * lv2_class, GType type)
/* FIXME Handle channels positioning /* FIXME Handle channels positioning
position = GST_AUDIO_CHANNEL_POSITION_FRONT_LEFT; position = GST_AUDIO_CHANNEL_POSITION_FRONT_LEFT;
sub_values = lilv_port_get_value (lv2plugin, port, designation_pred); sub_values = lilv_port_get_value (lv2plugin, port, gst_lv2_designation_pred_node);
if (lilv_nodes_size (sub_values) > 0) { if (lilv_nodes_size (sub_values) > 0) {
LilvNode *role = lilv_nodes_get_at (sub_values, 0); LilvNode *role = lilv_nodes_get_at (sub_values, 0);
position = gst_lv2_filter_role_to_position (role); position = gst_lv2_filter_role_to_position (role);
@ -879,7 +888,7 @@ gst_lv2_class_init (GstLV2Class * lv2_class, GType type)
} else { } else {
/* port is not part of a group, or it is part of a group but that group /* port is not part of a group, or it is part of a group but that group
* is illegal so we just ignore it */ * is illegal so we just ignore it */
if (lilv_port_is_a (lv2plugin, port, audio_class)) { if (lilv_port_is_a (lv2plugin, port, gst_lv2_audio_node)) {
if (is_input) { if (is_input) {
desc.pad = in_pad_index++; desc.pad = in_pad_index++;
g_array_append_val (lv2_class->in_group.ports, desc); g_array_append_val (lv2_class->in_group.ports, desc);
@ -887,7 +896,7 @@ gst_lv2_class_init (GstLV2Class * lv2_class, GType type)
desc.pad = out_pad_index++; desc.pad = out_pad_index++;
g_array_append_val (lv2_class->out_group.ports, desc); g_array_append_val (lv2_class->out_group.ports, desc);
} }
} else if (lilv_port_is_a (lv2plugin, port, control_class)) { } else if (lilv_port_is_a (lv2plugin, port, gst_lv2_control_node)) {
desc.type = GST_LV2_PORT_CONTROL; desc.type = GST_LV2_PORT_CONTROL;
if (is_input) { if (is_input) {
lv2_class->num_control_in++; lv2_class->num_control_in++;
@ -896,7 +905,7 @@ gst_lv2_class_init (GstLV2Class * lv2_class, GType type)
lv2_class->num_control_out++; lv2_class->num_control_out++;
g_array_append_val (lv2_class->control_out_ports, desc); g_array_append_val (lv2_class->control_out_ports, desc);
} }
} else if (lilv_port_is_a (lv2plugin, port, cv_class)) { } else if (lilv_port_is_a (lv2plugin, port, gst_lv2_cv_node)) {
desc.type = GST_LV2_PORT_CV; desc.type = GST_LV2_PORT_CV;
if (is_input) { if (is_input) {
lv2_class->num_cv_in++; lv2_class->num_cv_in++;
@ -905,9 +914,9 @@ gst_lv2_class_init (GstLV2Class * lv2_class, GType type)
lv2_class->num_cv_out++; lv2_class->num_cv_out++;
g_array_append_val (lv2_class->control_out_ports, desc); g_array_append_val (lv2_class->control_out_ports, desc);
} }
} else if (lilv_port_is_a (lv2plugin, port, event_class)) { } else if (lilv_port_is_a (lv2plugin, port, gst_lv2_event_node)) {
LilvNodes *supported = lilv_port_get_value (lv2plugin, port, LilvNodes *supported = lilv_port_get_value (lv2plugin, port,
supports_event_pred); gst_lv2_supports_event_pred_node);
GST_INFO ("%s: unhandled event port %d: %s, optional=%d, input=%d", GST_INFO ("%s: unhandled event port %d: %s, optional=%d, input=%d",
element_uri, j, element_uri, j,