naspro

view naspro-bridges-bad/ladspa/manifest.c @ 174:4f7243a606b1

Updated copyright notices and build system
author Stefano D'Angelo <zanga.mail@gmail.com>
date Sat May 01 21:51:33 2010 +0300 (2010-05-01)
parents d7568c8379c1
children
line source
1 /*
2 * NASPRO - NASPRO Architecture for Sound Processing
3 * LADSPA bridge
4 *
5 * Copyright (C) 2007-2010 Stefano D'Angelo <zanga.mail@gmail.com>
6 *
7 * See the COPYING file for license conditions.
8 */
10 #include <stdio.h>
12 #include "dyn-manifest.h"
14 #include <NASPRO/core/lib.h>
16 #include "pluglib.h"
17 #include "lv2api.h"
19 /* TODO: Until a serious rescan/automagical discovery policy emerges, we perform
20 * discovery only once at initialization time. */
22 static char inited = 0;
23 static char descs_ok = 0;
25 int
26 lv2_dyn_manifest_open(LV2_Dyn_Manifest_Handle *handle,
27 const LV2_Feature *const *features)
28 {
29 static char called = 0;
31 if (called)
32 return -1;
33 called = 1;
35 if (!inited)
36 {
37 _naladspa_pluglib_load_all();
38 descs_ok = _naladspa_lv2api_generate_descs() >= 0;
39 inited = 1;
40 }
42 *handle = NULL;
44 if (_naladspa_pluglib_desc_tree == NULL)
45 return -1;
47 called = 0;
49 return 0;
50 }
52 static void __attribute__((destructor))
53 fini()
54 {
55 _naladspa_pluglib_unload_all();
56 _naladspa_lv2api_free_descs();
57 }
59 static void
60 print_subject(void *content, void *data)
61 {
62 nacore_manifest_print_subject_triple(
63 (struct nacore_descriptor *)content, (FILE *)data);
64 }
66 int
67 lv2_dyn_manifest_get_subjects(LV2_Dyn_Manifest_Handle handle, FILE *fp)
68 {
69 if (descs_ok == 0)
70 return 0;
72 nacore_manifest_print_subject_prefixes(fp);
74 nacore_avl_tree_for_each(_naladspa_pluglib_desc_tree, print_subject,
75 (void *)fp);
77 return 0;
78 }
80 int
81 lv2_dyn_manifest_get_data(LV2_Dyn_Manifest_Handle handle, FILE *fp,
82 const char *uri)
83 {
84 struct nacore_descriptor *d;
86 if (descs_ok == 0)
87 return 0;
89 d = (struct nacore_descriptor *)nacore_avl_tree_find(
90 _naladspa_pluglib_desc_tree, (void *)uri);
91 if (d == NULL)
92 return -1;
94 nacore_manifest_print_data(d, fp, "ladspa");
96 return 0;
97 }
99 void
100 lv2_dyn_manifest_close(LV2_Dyn_Manifest_Handle handle)
101 {
102 }