mirror of
https://gitlab.freedesktop.org/gstreamer/gstreamer.git
synced 2025-01-11 01:45:33 +00:00
lv2: make it build with older lilv
Implementing the removal of presets is unfortunately not feasibla with versions < 0.22. Fixes #768595
This commit is contained in:
parent
74c0d5fdd2
commit
ea443a3fcc
1 changed files with 25 additions and 15 deletions
|
@ -146,6 +146,26 @@ gst_lv2_host_init (void)
|
||||||
|
|
||||||
/* preset interface */
|
/* preset interface */
|
||||||
|
|
||||||
|
static char *
|
||||||
|
make_bundle_name (GstObject * obj, const gchar * name)
|
||||||
|
{
|
||||||
|
GstElementFactory *factory;
|
||||||
|
gchar *basename, *s, *bundle;
|
||||||
|
|
||||||
|
factory = gst_element_get_factory ((GstElement *) obj);
|
||||||
|
basename = g_strdup (gst_element_factory_get_metadata (factory,
|
||||||
|
GST_ELEMENT_METADATA_LONGNAME));
|
||||||
|
s = basename;
|
||||||
|
while ((s = strchr (s, ' '))) {
|
||||||
|
*s = '_';
|
||||||
|
}
|
||||||
|
bundle = g_strjoin (NULL, basename, "_", name, ".preset.lv2", NULL);
|
||||||
|
|
||||||
|
g_free (basename);
|
||||||
|
|
||||||
|
return bundle;
|
||||||
|
}
|
||||||
|
|
||||||
gchar **
|
gchar **
|
||||||
gst_lv2_get_preset_names (GstLV2 * lv2, GstObject * obj)
|
gst_lv2_get_preset_names (GstLV2 * lv2, GstObject * obj)
|
||||||
{
|
{
|
||||||
|
@ -267,9 +287,8 @@ get_port_value (const char *port_symbol, void *data, uint32_t * size,
|
||||||
gboolean
|
gboolean
|
||||||
gst_lv2_save_preset (GstLV2 * lv2, GstObject * obj, const gchar * name)
|
gst_lv2_save_preset (GstLV2 * lv2, GstObject * obj, const gchar * name)
|
||||||
{
|
{
|
||||||
gchar *filename, *basename, *bundle, *dir, *tmp_dir, *s;
|
gchar *filename, *bundle, *dir, *tmp_dir;
|
||||||
gpointer user_data[] = { lv2->klass, obj };
|
gpointer user_data[] = { lv2->klass, obj };
|
||||||
GstElementFactory *factory;
|
|
||||||
LilvState *state;
|
LilvState *state;
|
||||||
LilvNode *bundle_dir;
|
LilvNode *bundle_dir;
|
||||||
const LilvNode *state_uri;
|
const LilvNode *state_uri;
|
||||||
|
@ -279,16 +298,8 @@ gst_lv2_save_preset (GstLV2 * lv2, GstObject * obj, const gchar * name)
|
||||||
gchar *filepath;
|
gchar *filepath;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
factory = gst_element_get_factory ((GstElement *) obj);
|
|
||||||
basename = g_strdup (gst_element_factory_get_metadata (factory,
|
|
||||||
GST_ELEMENT_METADATA_LONGNAME));
|
|
||||||
s = basename;
|
|
||||||
while ((s = strchr (s, ' '))) {
|
|
||||||
*s = '_';
|
|
||||||
}
|
|
||||||
|
|
||||||
filename = g_strjoin (NULL, name, ".ttl", NULL);
|
filename = g_strjoin (NULL, name, ".ttl", NULL);
|
||||||
bundle = g_strjoin (NULL, basename, "_", name, ".preset.lv2", NULL);
|
bundle = make_bundle_name (obj, name);
|
||||||
/* dir needs to end on a dir separator for the lilv_new_file_uri() to work */
|
/* dir needs to end on a dir separator for the lilv_new_file_uri() to work */
|
||||||
dir =
|
dir =
|
||||||
g_build_filename (g_get_home_dir (), ".lv2", bundle, G_DIR_SEPARATOR_S,
|
g_build_filename (g_get_home_dir (), ".lv2", bundle, G_DIR_SEPARATOR_S,
|
||||||
|
@ -322,12 +333,12 @@ gst_lv2_save_preset (GstLV2 * lv2, GstObject * obj, const gchar * name)
|
||||||
#else
|
#else
|
||||||
filepath = g_build_filename (dir, filename, NULL);
|
filepath = g_build_filename (dir, filename, NULL);
|
||||||
state_uri = lilv_new_uri (world, filepath);
|
state_uri = lilv_new_uri (world, filepath);
|
||||||
|
g_free (filepath);
|
||||||
#endif
|
#endif
|
||||||
lilv_world_load_resource (world, state_uri);
|
lilv_world_load_resource (world, state_uri);
|
||||||
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 (state_uri));
|
||||||
#ifndef HAVE_LILV_0_22
|
#ifndef HAVE_LILV_0_22
|
||||||
g_free (filepath);
|
|
||||||
lilv_node_free ((LilvNode *) state_uri);
|
lilv_node_free ((LilvNode *) state_uri);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
@ -340,7 +351,6 @@ gst_lv2_save_preset (GstLV2 * lv2, GstObject * obj, const gchar * name)
|
||||||
g_free (dir);
|
g_free (dir);
|
||||||
g_free (bundle);
|
g_free (bundle);
|
||||||
g_free (filename);
|
g_free (filename);
|
||||||
g_free (basename);
|
|
||||||
|
|
||||||
return res;
|
return res;
|
||||||
}
|
}
|
||||||
|
@ -358,19 +368,19 @@ gst_lv2_rename_preset (GstLV2 * lv2, GstObject * obj,
|
||||||
gboolean
|
gboolean
|
||||||
gst_lv2_delete_preset (GstLV2 * lv2, GstObject * obj, const gchar * name)
|
gst_lv2_delete_preset (GstLV2 * lv2, GstObject * obj, const gchar * name)
|
||||||
{
|
{
|
||||||
|
#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 (world, &lv2_map, preset);
|
||||||
|
|
||||||
lilv_world_unload_resource (world, lilv_state_get_uri (state));
|
lilv_world_unload_resource (world, lilv_state_get_uri (state));
|
||||||
lilv_state_delete (world, state);
|
lilv_state_delete (world, state);
|
||||||
lilv_state_free (state);
|
lilv_state_free (state);
|
||||||
|
#endif
|
||||||
g_hash_table_remove (lv2->presets, name);
|
g_hash_table_remove (lv2->presets, name);
|
||||||
|
|
||||||
return FALSE;
|
return FALSE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/* api helpers */
|
/* api helpers */
|
||||||
|
|
||||||
void
|
void
|
||||||
|
|
Loading…
Reference in a new issue