annotate libaf/af_ladspa.c @ 32832:d3c28b47ffcd

Add alpha channel value to the ARGB initialization constant for a pixel in the image (although it is zero). (This clarifies the 32-bit / 4 bytes nature of the image.)
author ib
date Thu, 17 Feb 2011 10:17:45 +0000
parents 8fa2f43cb760
children a93891202051
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
14217
5b5ebf93ec16 Adds support for LADSPA (Linux Audio Developer's Simple Plugin API) plugins.
ivo
parents:
diff changeset
1 /*
28924
d5d66bff938a cosmetics: Remove file names from file header, it only causes trouble.
diego
parents: 27727
diff changeset
2 * LADSPA plugin loader
14217
5b5ebf93ec16 Adds support for LADSPA (Linux Audio Developer's Simple Plugin API) plugins.
ivo
parents:
diff changeset
3 *
5b5ebf93ec16 Adds support for LADSPA (Linux Audio Developer's Simple Plugin API) plugins.
ivo
parents:
diff changeset
4 * Written by Ivo van Poorten <ivop@euronet.nl>
5b5ebf93ec16 Adds support for LADSPA (Linux Audio Developer's Simple Plugin API) plugins.
ivo
parents:
diff changeset
5 * Copyright (C) 2004, 2005
5b5ebf93ec16 Adds support for LADSPA (Linux Audio Developer's Simple Plugin API) plugins.
ivo
parents:
diff changeset
6 *
26740
b3a38b361fef Use standard license headers with standard formatting.
diego
parents: 25171
diff changeset
7 * This file is part of MPlayer.
14217
5b5ebf93ec16 Adds support for LADSPA (Linux Audio Developer's Simple Plugin API) plugins.
ivo
parents:
diff changeset
8 *
26740
b3a38b361fef Use standard license headers with standard formatting.
diego
parents: 25171
diff changeset
9 * MPlayer is free software; you can redistribute it and/or modify
b3a38b361fef Use standard license headers with standard formatting.
diego
parents: 25171
diff changeset
10 * it under the terms of the GNU General Public License as published by
b3a38b361fef Use standard license headers with standard formatting.
diego
parents: 25171
diff changeset
11 * the Free Software Foundation; either version 2 of the License, or
b3a38b361fef Use standard license headers with standard formatting.
diego
parents: 25171
diff changeset
12 * (at your option) any later version.
b3a38b361fef Use standard license headers with standard formatting.
diego
parents: 25171
diff changeset
13 *
b3a38b361fef Use standard license headers with standard formatting.
diego
parents: 25171
diff changeset
14 * MPlayer is distributed in the hope that it will be useful,
14217
5b5ebf93ec16 Adds support for LADSPA (Linux Audio Developer's Simple Plugin API) plugins.
ivo
parents:
diff changeset
15 * but WITHOUT ANY WARRANTY; without even the implied warranty of
5b5ebf93ec16 Adds support for LADSPA (Linux Audio Developer's Simple Plugin API) plugins.
ivo
parents:
diff changeset
16 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
5b5ebf93ec16 Adds support for LADSPA (Linux Audio Developer's Simple Plugin API) plugins.
ivo
parents:
diff changeset
17 * GNU General Public License for more details.
5b5ebf93ec16 Adds support for LADSPA (Linux Audio Developer's Simple Plugin API) plugins.
ivo
parents:
diff changeset
18 *
26740
b3a38b361fef Use standard license headers with standard formatting.
diego
parents: 25171
diff changeset
19 * You should have received a copy of the GNU General Public License along
b3a38b361fef Use standard license headers with standard formatting.
diego
parents: 25171
diff changeset
20 * with MPlayer; if not, write to the Free Software Foundation, Inc.,
b3a38b361fef Use standard license headers with standard formatting.
diego
parents: 25171
diff changeset
21 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
14217
5b5ebf93ec16 Adds support for LADSPA (Linux Audio Developer's Simple Plugin API) plugins.
ivo
parents:
diff changeset
22 */
5b5ebf93ec16 Adds support for LADSPA (Linux Audio Developer's Simple Plugin API) plugins.
ivo
parents:
diff changeset
23
5b5ebf93ec16 Adds support for LADSPA (Linux Audio Developer's Simple Plugin API) plugins.
ivo
parents:
diff changeset
24 /* ------------------------------------------------------------------------- */
5b5ebf93ec16 Adds support for LADSPA (Linux Audio Developer's Simple Plugin API) plugins.
ivo
parents:
diff changeset
25
5b5ebf93ec16 Adds support for LADSPA (Linux Audio Developer's Simple Plugin API) plugins.
ivo
parents:
diff changeset
26 /* Global Includes */
5b5ebf93ec16 Adds support for LADSPA (Linux Audio Developer's Simple Plugin API) plugins.
ivo
parents:
diff changeset
27
5b5ebf93ec16 Adds support for LADSPA (Linux Audio Developer's Simple Plugin API) plugins.
ivo
parents:
diff changeset
28 #include <stdio.h>
5b5ebf93ec16 Adds support for LADSPA (Linux Audio Developer's Simple Plugin API) plugins.
ivo
parents:
diff changeset
29 #include <stdlib.h>
5b5ebf93ec16 Adds support for LADSPA (Linux Audio Developer's Simple Plugin API) plugins.
ivo
parents:
diff changeset
30 #include <string.h>
5b5ebf93ec16 Adds support for LADSPA (Linux Audio Developer's Simple Plugin API) plugins.
ivo
parents:
diff changeset
31
5b5ebf93ec16 Adds support for LADSPA (Linux Audio Developer's Simple Plugin API) plugins.
ivo
parents:
diff changeset
32 #include <inttypes.h>
5b5ebf93ec16 Adds support for LADSPA (Linux Audio Developer's Simple Plugin API) plugins.
ivo
parents:
diff changeset
33 #include <math.h>
5b5ebf93ec16 Adds support for LADSPA (Linux Audio Developer's Simple Plugin API) plugins.
ivo
parents:
diff changeset
34 #include <limits.h>
5b5ebf93ec16 Adds support for LADSPA (Linux Audio Developer's Simple Plugin API) plugins.
ivo
parents:
diff changeset
35
5b5ebf93ec16 Adds support for LADSPA (Linux Audio Developer's Simple Plugin API) plugins.
ivo
parents:
diff changeset
36 #include <dlfcn.h>
5b5ebf93ec16 Adds support for LADSPA (Linux Audio Developer's Simple Plugin API) plugins.
ivo
parents:
diff changeset
37 #include <ladspa.h>
5b5ebf93ec16 Adds support for LADSPA (Linux Audio Developer's Simple Plugin API) plugins.
ivo
parents:
diff changeset
38
5b5ebf93ec16 Adds support for LADSPA (Linux Audio Developer's Simple Plugin API) plugins.
ivo
parents:
diff changeset
39 /* ------------------------------------------------------------------------- */
5b5ebf93ec16 Adds support for LADSPA (Linux Audio Developer's Simple Plugin API) plugins.
ivo
parents:
diff changeset
40
5b5ebf93ec16 Adds support for LADSPA (Linux Audio Developer's Simple Plugin API) plugins.
ivo
parents:
diff changeset
41 /* Local Includes */
5b5ebf93ec16 Adds support for LADSPA (Linux Audio Developer's Simple Plugin API) plugins.
ivo
parents:
diff changeset
42
5b5ebf93ec16 Adds support for LADSPA (Linux Audio Developer's Simple Plugin API) plugins.
ivo
parents:
diff changeset
43 #include "af.h"
16982
a9da2db9eb16 Unify include paths by adding -I.. to CFLAGS.
diego
parents: 16904
diff changeset
44 #include "help_mp.h"
14217
5b5ebf93ec16 Adds support for LADSPA (Linux Audio Developer's Simple Plugin API) plugins.
ivo
parents:
diff changeset
45
5b5ebf93ec16 Adds support for LADSPA (Linux Audio Developer's Simple Plugin API) plugins.
ivo
parents:
diff changeset
46 /* ------------------------------------------------------------------------- */
5b5ebf93ec16 Adds support for LADSPA (Linux Audio Developer's Simple Plugin API) plugins.
ivo
parents:
diff changeset
47
5b5ebf93ec16 Adds support for LADSPA (Linux Audio Developer's Simple Plugin API) plugins.
ivo
parents:
diff changeset
48 /* Filter specific data */
5b5ebf93ec16 Adds support for LADSPA (Linux Audio Developer's Simple Plugin API) plugins.
ivo
parents:
diff changeset
49
5b5ebf93ec16 Adds support for LADSPA (Linux Audio Developer's Simple Plugin API) plugins.
ivo
parents:
diff changeset
50 typedef struct af_ladspa_s
5b5ebf93ec16 Adds support for LADSPA (Linux Audio Developer's Simple Plugin API) plugins.
ivo
parents:
diff changeset
51 {
5b5ebf93ec16 Adds support for LADSPA (Linux Audio Developer's Simple Plugin API) plugins.
ivo
parents:
diff changeset
52 int status; /**< Status of the filter.
5b5ebf93ec16 Adds support for LADSPA (Linux Audio Developer's Simple Plugin API) plugins.
ivo
parents:
diff changeset
53 * Either AF_OK or AF_ERROR
5b5ebf93ec16 Adds support for LADSPA (Linux Audio Developer's Simple Plugin API) plugins.
ivo
parents:
diff changeset
54 * Because MPlayer re-inits audio filters that
5b5ebf93ec16 Adds support for LADSPA (Linux Audio Developer's Simple Plugin API) plugins.
ivo
parents:
diff changeset
55 * _clearly_ returned AF_ERROR anyway, I use this
5b5ebf93ec16 Adds support for LADSPA (Linux Audio Developer's Simple Plugin API) plugins.
ivo
parents:
diff changeset
56 * in play() to skip the processing and return
5b5ebf93ec16 Adds support for LADSPA (Linux Audio Developer's Simple Plugin API) plugins.
ivo
parents:
diff changeset
57 * the data unchanged.
5b5ebf93ec16 Adds support for LADSPA (Linux Audio Developer's Simple Plugin API) plugins.
ivo
parents:
diff changeset
58 */
5b5ebf93ec16 Adds support for LADSPA (Linux Audio Developer's Simple Plugin API) plugins.
ivo
parents:
diff changeset
59
5b5ebf93ec16 Adds support for LADSPA (Linux Audio Developer's Simple Plugin API) plugins.
ivo
parents:
diff changeset
60 int activated; /**< 0 or 1. Activate LADSPA filters only once, even
5b5ebf93ec16 Adds support for LADSPA (Linux Audio Developer's Simple Plugin API) plugins.
ivo
parents:
diff changeset
61 * if the buffers get resized, to avoid a stuttering
5b5ebf93ec16 Adds support for LADSPA (Linux Audio Developer's Simple Plugin API) plugins.
ivo
parents:
diff changeset
62 * filter.
5b5ebf93ec16 Adds support for LADSPA (Linux Audio Developer's Simple Plugin API) plugins.
ivo
parents:
diff changeset
63 */
5b5ebf93ec16 Adds support for LADSPA (Linux Audio Developer's Simple Plugin API) plugins.
ivo
parents:
diff changeset
64
5b5ebf93ec16 Adds support for LADSPA (Linux Audio Developer's Simple Plugin API) plugins.
ivo
parents:
diff changeset
65 char *file;
5b5ebf93ec16 Adds support for LADSPA (Linux Audio Developer's Simple Plugin API) plugins.
ivo
parents:
diff changeset
66 char *label;
5b5ebf93ec16 Adds support for LADSPA (Linux Audio Developer's Simple Plugin API) plugins.
ivo
parents:
diff changeset
67
5b5ebf93ec16 Adds support for LADSPA (Linux Audio Developer's Simple Plugin API) plugins.
ivo
parents:
diff changeset
68 char *myname; /**< It's easy to have a concatenation of file and label */
5b5ebf93ec16 Adds support for LADSPA (Linux Audio Developer's Simple Plugin API) plugins.
ivo
parents:
diff changeset
69
5b5ebf93ec16 Adds support for LADSPA (Linux Audio Developer's Simple Plugin API) plugins.
ivo
parents:
diff changeset
70 void *libhandle;
5b5ebf93ec16 Adds support for LADSPA (Linux Audio Developer's Simple Plugin API) plugins.
ivo
parents:
diff changeset
71 const LADSPA_Descriptor *plugin_descriptor;
5b5ebf93ec16 Adds support for LADSPA (Linux Audio Developer's Simple Plugin API) plugins.
ivo
parents:
diff changeset
72
5b5ebf93ec16 Adds support for LADSPA (Linux Audio Developer's Simple Plugin API) plugins.
ivo
parents:
diff changeset
73 int nports;
5b5ebf93ec16 Adds support for LADSPA (Linux Audio Developer's Simple Plugin API) plugins.
ivo
parents:
diff changeset
74
5b5ebf93ec16 Adds support for LADSPA (Linux Audio Developer's Simple Plugin API) plugins.
ivo
parents:
diff changeset
75 int ninputs;
5b5ebf93ec16 Adds support for LADSPA (Linux Audio Developer's Simple Plugin API) plugins.
ivo
parents:
diff changeset
76 int *inputs;
5b5ebf93ec16 Adds support for LADSPA (Linux Audio Developer's Simple Plugin API) plugins.
ivo
parents:
diff changeset
77
5b5ebf93ec16 Adds support for LADSPA (Linux Audio Developer's Simple Plugin API) plugins.
ivo
parents:
diff changeset
78 int noutputs;
5b5ebf93ec16 Adds support for LADSPA (Linux Audio Developer's Simple Plugin API) plugins.
ivo
parents:
diff changeset
79 int *outputs;
5b5ebf93ec16 Adds support for LADSPA (Linux Audio Developer's Simple Plugin API) plugins.
ivo
parents:
diff changeset
80
5b5ebf93ec16 Adds support for LADSPA (Linux Audio Developer's Simple Plugin API) plugins.
ivo
parents:
diff changeset
81 int ninputcontrols;
5b5ebf93ec16 Adds support for LADSPA (Linux Audio Developer's Simple Plugin API) plugins.
ivo
parents:
diff changeset
82 int *inputcontrolsmap; /**< Map input port number [0-] to actual port */
5b5ebf93ec16 Adds support for LADSPA (Linux Audio Developer's Simple Plugin API) plugins.
ivo
parents:
diff changeset
83 float *inputcontrols;
5b5ebf93ec16 Adds support for LADSPA (Linux Audio Developer's Simple Plugin API) plugins.
ivo
parents:
diff changeset
84
5b5ebf93ec16 Adds support for LADSPA (Linux Audio Developer's Simple Plugin API) plugins.
ivo
parents:
diff changeset
85 int noutputcontrols;
5b5ebf93ec16 Adds support for LADSPA (Linux Audio Developer's Simple Plugin API) plugins.
ivo
parents:
diff changeset
86 int *outputcontrolsmap;
5b5ebf93ec16 Adds support for LADSPA (Linux Audio Developer's Simple Plugin API) plugins.
ivo
parents:
diff changeset
87 float *outputcontrols;
5b5ebf93ec16 Adds support for LADSPA (Linux Audio Developer's Simple Plugin API) plugins.
ivo
parents:
diff changeset
88
5b5ebf93ec16 Adds support for LADSPA (Linux Audio Developer's Simple Plugin API) plugins.
ivo
parents:
diff changeset
89 int nch; /**< number of channels */
5b5ebf93ec16 Adds support for LADSPA (Linux Audio Developer's Simple Plugin API) plugins.
ivo
parents:
diff changeset
90 int bufsize;
5b5ebf93ec16 Adds support for LADSPA (Linux Audio Developer's Simple Plugin API) plugins.
ivo
parents:
diff changeset
91 float **inbufs;
5b5ebf93ec16 Adds support for LADSPA (Linux Audio Developer's Simple Plugin API) plugins.
ivo
parents:
diff changeset
92 float **outbufs;
5b5ebf93ec16 Adds support for LADSPA (Linux Audio Developer's Simple Plugin API) plugins.
ivo
parents:
diff changeset
93 LADSPA_Handle *chhandles;
5b5ebf93ec16 Adds support for LADSPA (Linux Audio Developer's Simple Plugin API) plugins.
ivo
parents:
diff changeset
94
5b5ebf93ec16 Adds support for LADSPA (Linux Audio Developer's Simple Plugin API) plugins.
ivo
parents:
diff changeset
95 } af_ladspa_t;
5b5ebf93ec16 Adds support for LADSPA (Linux Audio Developer's Simple Plugin API) plugins.
ivo
parents:
diff changeset
96
5b5ebf93ec16 Adds support for LADSPA (Linux Audio Developer's Simple Plugin API) plugins.
ivo
parents:
diff changeset
97 /* ------------------------------------------------------------------------- */
5b5ebf93ec16 Adds support for LADSPA (Linux Audio Developer's Simple Plugin API) plugins.
ivo
parents:
diff changeset
98
22746
fd6f824ef894 Rename open to af_open so as not to conflict with a previous header definition.
diego
parents: 22156
diff changeset
99 static int af_open(af_instance_t *af);
14217
5b5ebf93ec16 Adds support for LADSPA (Linux Audio Developer's Simple Plugin API) plugins.
ivo
parents:
diff changeset
100 static int af_ladspa_malloc_failed(char*);
5b5ebf93ec16 Adds support for LADSPA (Linux Audio Developer's Simple Plugin API) plugins.
ivo
parents:
diff changeset
101
5b5ebf93ec16 Adds support for LADSPA (Linux Audio Developer's Simple Plugin API) plugins.
ivo
parents:
diff changeset
102 /* ------------------------------------------------------------------------- */
5b5ebf93ec16 Adds support for LADSPA (Linux Audio Developer's Simple Plugin API) plugins.
ivo
parents:
diff changeset
103
5b5ebf93ec16 Adds support for LADSPA (Linux Audio Developer's Simple Plugin API) plugins.
ivo
parents:
diff changeset
104 /* Description */
5b5ebf93ec16 Adds support for LADSPA (Linux Audio Developer's Simple Plugin API) plugins.
ivo
parents:
diff changeset
105
5b5ebf93ec16 Adds support for LADSPA (Linux Audio Developer's Simple Plugin API) plugins.
ivo
parents:
diff changeset
106 af_info_t af_info_ladspa = {
5b5ebf93ec16 Adds support for LADSPA (Linux Audio Developer's Simple Plugin API) plugins.
ivo
parents:
diff changeset
107 "LADSPA plugin loader",
5b5ebf93ec16 Adds support for LADSPA (Linux Audio Developer's Simple Plugin API) plugins.
ivo
parents:
diff changeset
108 "ladspa",
5b5ebf93ec16 Adds support for LADSPA (Linux Audio Developer's Simple Plugin API) plugins.
ivo
parents:
diff changeset
109 "Ivo van Poorten",
5b5ebf93ec16 Adds support for LADSPA (Linux Audio Developer's Simple Plugin API) plugins.
ivo
parents:
diff changeset
110 "",
5b5ebf93ec16 Adds support for LADSPA (Linux Audio Developer's Simple Plugin API) plugins.
ivo
parents:
diff changeset
111 AF_FLAGS_REENTRANT,
22746
fd6f824ef894 Rename open to af_open so as not to conflict with a previous header definition.
diego
parents: 22156
diff changeset
112 af_open
14217
5b5ebf93ec16 Adds support for LADSPA (Linux Audio Developer's Simple Plugin API) plugins.
ivo
parents:
diff changeset
113 };
5b5ebf93ec16 Adds support for LADSPA (Linux Audio Developer's Simple Plugin API) plugins.
ivo
parents:
diff changeset
114
5b5ebf93ec16 Adds support for LADSPA (Linux Audio Developer's Simple Plugin API) plugins.
ivo
parents:
diff changeset
115 /* ------------------------------------------------------------------------- */
5b5ebf93ec16 Adds support for LADSPA (Linux Audio Developer's Simple Plugin API) plugins.
ivo
parents:
diff changeset
116
5b5ebf93ec16 Adds support for LADSPA (Linux Audio Developer's Simple Plugin API) plugins.
ivo
parents:
diff changeset
117 /* By lack of a better word (in my vocabulary) this is called 'parse'.
5b5ebf93ec16 Adds support for LADSPA (Linux Audio Developer's Simple Plugin API) plugins.
ivo
parents:
diff changeset
118 * Feel free to suggest an alternative.
5b5ebf93ec16 Adds support for LADSPA (Linux Audio Developer's Simple Plugin API) plugins.
ivo
parents:
diff changeset
119 */
5b5ebf93ec16 Adds support for LADSPA (Linux Audio Developer's Simple Plugin API) plugins.
ivo
parents:
diff changeset
120
5b5ebf93ec16 Adds support for LADSPA (Linux Audio Developer's Simple Plugin API) plugins.
ivo
parents:
diff changeset
121 /** \brief Check for inputs, outputs and controls of a given filter.
5b5ebf93ec16 Adds support for LADSPA (Linux Audio Developer's Simple Plugin API) plugins.
ivo
parents:
diff changeset
122 *
5b5ebf93ec16 Adds support for LADSPA (Linux Audio Developer's Simple Plugin API) plugins.
ivo
parents:
diff changeset
123 * This function counts and checks all input, output and control ports
5b5ebf93ec16 Adds support for LADSPA (Linux Audio Developer's Simple Plugin API) plugins.
ivo
parents:
diff changeset
124 * of the filter that was loaded. If it turns out to be a valid
5b5ebf93ec16 Adds support for LADSPA (Linux Audio Developer's Simple Plugin API) plugins.
ivo
parents:
diff changeset
125 * filter for MPlayer use, it prints out a list of all controls and
5b5ebf93ec16 Adds support for LADSPA (Linux Audio Developer's Simple Plugin API) plugins.
ivo
parents:
diff changeset
126 * the corresponding range of its value at message level MSGL_V.
5b5ebf93ec16 Adds support for LADSPA (Linux Audio Developer's Simple Plugin API) plugins.
ivo
parents:
diff changeset
127 *
5b5ebf93ec16 Adds support for LADSPA (Linux Audio Developer's Simple Plugin API) plugins.
ivo
parents:
diff changeset
128 * \param setup Current setup of the filter. Must have its
5b5ebf93ec16 Adds support for LADSPA (Linux Audio Developer's Simple Plugin API) plugins.
ivo
parents:
diff changeset
129 * plugin_descriptor set!
5b5ebf93ec16 Adds support for LADSPA (Linux Audio Developer's Simple Plugin API) plugins.
ivo
parents:
diff changeset
130 *
5b5ebf93ec16 Adds support for LADSPA (Linux Audio Developer's Simple Plugin API) plugins.
ivo
parents:
diff changeset
131 * \return Returns AF_OK if it has a valid input/output/controls
5b5ebf93ec16 Adds support for LADSPA (Linux Audio Developer's Simple Plugin API) plugins.
ivo
parents:
diff changeset
132 * configuration. Else, it returns AF_ERROR.
5b5ebf93ec16 Adds support for LADSPA (Linux Audio Developer's Simple Plugin API) plugins.
ivo
parents:
diff changeset
133 */
5b5ebf93ec16 Adds support for LADSPA (Linux Audio Developer's Simple Plugin API) plugins.
ivo
parents:
diff changeset
134
5b5ebf93ec16 Adds support for LADSPA (Linux Audio Developer's Simple Plugin API) plugins.
ivo
parents:
diff changeset
135 static int af_ladspa_parse_plugin(af_ladspa_t *setup) {
5b5ebf93ec16 Adds support for LADSPA (Linux Audio Developer's Simple Plugin API) plugins.
ivo
parents:
diff changeset
136 int p, i;
5b5ebf93ec16 Adds support for LADSPA (Linux Audio Developer's Simple Plugin API) plugins.
ivo
parents:
diff changeset
137 const LADSPA_Descriptor *pdes = setup->plugin_descriptor;
5b5ebf93ec16 Adds support for LADSPA (Linux Audio Developer's Simple Plugin API) plugins.
ivo
parents:
diff changeset
138 LADSPA_PortDescriptor d;
5b5ebf93ec16 Adds support for LADSPA (Linux Audio Developer's Simple Plugin API) plugins.
ivo
parents:
diff changeset
139 LADSPA_PortRangeHint hint;
5b5ebf93ec16 Adds support for LADSPA (Linux Audio Developer's Simple Plugin API) plugins.
ivo
parents:
diff changeset
140
5b5ebf93ec16 Adds support for LADSPA (Linux Audio Developer's Simple Plugin API) plugins.
ivo
parents:
diff changeset
141 if (!setup->libhandle)
5b5ebf93ec16 Adds support for LADSPA (Linux Audio Developer's Simple Plugin API) plugins.
ivo
parents:
diff changeset
142 return AF_ERROR; /* only call parse after a succesful load */
5b5ebf93ec16 Adds support for LADSPA (Linux Audio Developer's Simple Plugin API) plugins.
ivo
parents:
diff changeset
143 if (!setup->plugin_descriptor)
5b5ebf93ec16 Adds support for LADSPA (Linux Audio Developer's Simple Plugin API) plugins.
ivo
parents:
diff changeset
144 return AF_ERROR; /* same as above */
5b5ebf93ec16 Adds support for LADSPA (Linux Audio Developer's Simple Plugin API) plugins.
ivo
parents:
diff changeset
145
5b5ebf93ec16 Adds support for LADSPA (Linux Audio Developer's Simple Plugin API) plugins.
ivo
parents:
diff changeset
146 /* let's do it */
5b5ebf93ec16 Adds support for LADSPA (Linux Audio Developer's Simple Plugin API) plugins.
ivo
parents:
diff changeset
147
5b5ebf93ec16 Adds support for LADSPA (Linux Audio Developer's Simple Plugin API) plugins.
ivo
parents:
diff changeset
148 setup->nports = pdes->PortCount;
5b5ebf93ec16 Adds support for LADSPA (Linux Audio Developer's Simple Plugin API) plugins.
ivo
parents:
diff changeset
149
5b5ebf93ec16 Adds support for LADSPA (Linux Audio Developer's Simple Plugin API) plugins.
ivo
parents:
diff changeset
150 /* allocate memory for all inputs/outputs/controls */
5b5ebf93ec16 Adds support for LADSPA (Linux Audio Developer's Simple Plugin API) plugins.
ivo
parents:
diff changeset
151
5b5ebf93ec16 Adds support for LADSPA (Linux Audio Developer's Simple Plugin API) plugins.
ivo
parents:
diff changeset
152 setup->inputs = calloc(setup->nports, sizeof(int));
5b5ebf93ec16 Adds support for LADSPA (Linux Audio Developer's Simple Plugin API) plugins.
ivo
parents:
diff changeset
153 if (!setup->inputs) return af_ladspa_malloc_failed(setup->myname);
5b5ebf93ec16 Adds support for LADSPA (Linux Audio Developer's Simple Plugin API) plugins.
ivo
parents:
diff changeset
154
5b5ebf93ec16 Adds support for LADSPA (Linux Audio Developer's Simple Plugin API) plugins.
ivo
parents:
diff changeset
155 setup->outputs = calloc(setup->nports, sizeof(int));
5b5ebf93ec16 Adds support for LADSPA (Linux Audio Developer's Simple Plugin API) plugins.
ivo
parents:
diff changeset
156 if (!setup->outputs) return af_ladspa_malloc_failed(setup->myname);
5b5ebf93ec16 Adds support for LADSPA (Linux Audio Developer's Simple Plugin API) plugins.
ivo
parents:
diff changeset
157
5b5ebf93ec16 Adds support for LADSPA (Linux Audio Developer's Simple Plugin API) plugins.
ivo
parents:
diff changeset
158 setup->inputcontrolsmap = calloc(setup->nports, sizeof(int));
5b5ebf93ec16 Adds support for LADSPA (Linux Audio Developer's Simple Plugin API) plugins.
ivo
parents:
diff changeset
159 if (!setup->inputcontrolsmap) return af_ladspa_malloc_failed(setup->myname);
5b5ebf93ec16 Adds support for LADSPA (Linux Audio Developer's Simple Plugin API) plugins.
ivo
parents:
diff changeset
160
5b5ebf93ec16 Adds support for LADSPA (Linux Audio Developer's Simple Plugin API) plugins.
ivo
parents:
diff changeset
161 setup->inputcontrols = calloc(setup->nports, sizeof(float));
5b5ebf93ec16 Adds support for LADSPA (Linux Audio Developer's Simple Plugin API) plugins.
ivo
parents:
diff changeset
162 if (!setup->inputcontrols) return af_ladspa_malloc_failed(setup->myname);
5b5ebf93ec16 Adds support for LADSPA (Linux Audio Developer's Simple Plugin API) plugins.
ivo
parents:
diff changeset
163
5b5ebf93ec16 Adds support for LADSPA (Linux Audio Developer's Simple Plugin API) plugins.
ivo
parents:
diff changeset
164 setup->outputcontrolsmap = calloc(setup->nports, sizeof(int));
5b5ebf93ec16 Adds support for LADSPA (Linux Audio Developer's Simple Plugin API) plugins.
ivo
parents:
diff changeset
165 if (!setup->outputcontrolsmap) return af_ladspa_malloc_failed(setup->myname);
5b5ebf93ec16 Adds support for LADSPA (Linux Audio Developer's Simple Plugin API) plugins.
ivo
parents:
diff changeset
166
5b5ebf93ec16 Adds support for LADSPA (Linux Audio Developer's Simple Plugin API) plugins.
ivo
parents:
diff changeset
167 setup->outputcontrols = calloc(setup->nports, sizeof(float));
5b5ebf93ec16 Adds support for LADSPA (Linux Audio Developer's Simple Plugin API) plugins.
ivo
parents:
diff changeset
168 if (!setup->outputcontrols) return af_ladspa_malloc_failed(setup->myname);
5b5ebf93ec16 Adds support for LADSPA (Linux Audio Developer's Simple Plugin API) plugins.
ivo
parents:
diff changeset
169
5b5ebf93ec16 Adds support for LADSPA (Linux Audio Developer's Simple Plugin API) plugins.
ivo
parents:
diff changeset
170 /* set counts to zero */
5b5ebf93ec16 Adds support for LADSPA (Linux Audio Developer's Simple Plugin API) plugins.
ivo
parents:
diff changeset
171
5b5ebf93ec16 Adds support for LADSPA (Linux Audio Developer's Simple Plugin API) plugins.
ivo
parents:
diff changeset
172 setup->ninputs = 0;
5b5ebf93ec16 Adds support for LADSPA (Linux Audio Developer's Simple Plugin API) plugins.
ivo
parents:
diff changeset
173 setup->noutputs = 0;
5b5ebf93ec16 Adds support for LADSPA (Linux Audio Developer's Simple Plugin API) plugins.
ivo
parents:
diff changeset
174 setup->ninputcontrols = 0;
5b5ebf93ec16 Adds support for LADSPA (Linux Audio Developer's Simple Plugin API) plugins.
ivo
parents:
diff changeset
175 setup->noutputcontrols = 0;
5b5ebf93ec16 Adds support for LADSPA (Linux Audio Developer's Simple Plugin API) plugins.
ivo
parents:
diff changeset
176
5b5ebf93ec16 Adds support for LADSPA (Linux Audio Developer's Simple Plugin API) plugins.
ivo
parents:
diff changeset
177 /* check all ports, see what type it is and set variables according to
5b5ebf93ec16 Adds support for LADSPA (Linux Audio Developer's Simple Plugin API) plugins.
ivo
parents:
diff changeset
178 * what we have found
5b5ebf93ec16 Adds support for LADSPA (Linux Audio Developer's Simple Plugin API) plugins.
ivo
parents:
diff changeset
179 */
5b5ebf93ec16 Adds support for LADSPA (Linux Audio Developer's Simple Plugin API) plugins.
ivo
parents:
diff changeset
180
5b5ebf93ec16 Adds support for LADSPA (Linux Audio Developer's Simple Plugin API) plugins.
ivo
parents:
diff changeset
181 for (p=0; p<setup->nports; p++) {
5b5ebf93ec16 Adds support for LADSPA (Linux Audio Developer's Simple Plugin API) plugins.
ivo
parents:
diff changeset
182 d = pdes->PortDescriptors[p];
5b5ebf93ec16 Adds support for LADSPA (Linux Audio Developer's Simple Plugin API) plugins.
ivo
parents:
diff changeset
183
5b5ebf93ec16 Adds support for LADSPA (Linux Audio Developer's Simple Plugin API) plugins.
ivo
parents:
diff changeset
184 if (LADSPA_IS_PORT_AUDIO(d)) {
5b5ebf93ec16 Adds support for LADSPA (Linux Audio Developer's Simple Plugin API) plugins.
ivo
parents:
diff changeset
185 if (LADSPA_IS_PORT_INPUT(d)) {
5b5ebf93ec16 Adds support for LADSPA (Linux Audio Developer's Simple Plugin API) plugins.
ivo
parents:
diff changeset
186 setup->inputs[setup->ninputs] = p;
5b5ebf93ec16 Adds support for LADSPA (Linux Audio Developer's Simple Plugin API) plugins.
ivo
parents:
diff changeset
187 setup->ninputs++;
5b5ebf93ec16 Adds support for LADSPA (Linux Audio Developer's Simple Plugin API) plugins.
ivo
parents:
diff changeset
188 } else if (LADSPA_IS_PORT_OUTPUT(d)) {
5b5ebf93ec16 Adds support for LADSPA (Linux Audio Developer's Simple Plugin API) plugins.
ivo
parents:
diff changeset
189 setup->outputs[setup->noutputs] = p;
5b5ebf93ec16 Adds support for LADSPA (Linux Audio Developer's Simple Plugin API) plugins.
ivo
parents:
diff changeset
190 setup->noutputs++;
5b5ebf93ec16 Adds support for LADSPA (Linux Audio Developer's Simple Plugin API) plugins.
ivo
parents:
diff changeset
191 }
5b5ebf93ec16 Adds support for LADSPA (Linux Audio Developer's Simple Plugin API) plugins.
ivo
parents:
diff changeset
192 }
5b5ebf93ec16 Adds support for LADSPA (Linux Audio Developer's Simple Plugin API) plugins.
ivo
parents:
diff changeset
193
5b5ebf93ec16 Adds support for LADSPA (Linux Audio Developer's Simple Plugin API) plugins.
ivo
parents:
diff changeset
194 if (LADSPA_IS_PORT_CONTROL(d)) {
5b5ebf93ec16 Adds support for LADSPA (Linux Audio Developer's Simple Plugin API) plugins.
ivo
parents:
diff changeset
195 if (LADSPA_IS_PORT_INPUT(d)) {
5b5ebf93ec16 Adds support for LADSPA (Linux Audio Developer's Simple Plugin API) plugins.
ivo
parents:
diff changeset
196 setup->inputcontrolsmap[setup->ninputcontrols] = p;
5b5ebf93ec16 Adds support for LADSPA (Linux Audio Developer's Simple Plugin API) plugins.
ivo
parents:
diff changeset
197 setup->ninputcontrols++;
5b5ebf93ec16 Adds support for LADSPA (Linux Audio Developer's Simple Plugin API) plugins.
ivo
parents:
diff changeset
198 /* set control to zero. set values after reading the rest
5b5ebf93ec16 Adds support for LADSPA (Linux Audio Developer's Simple Plugin API) plugins.
ivo
parents:
diff changeset
199 * of the suboptions and check LADSPA_?_HINT's later.
5b5ebf93ec16 Adds support for LADSPA (Linux Audio Developer's Simple Plugin API) plugins.
ivo
parents:
diff changeset
200 */
5b5ebf93ec16 Adds support for LADSPA (Linux Audio Developer's Simple Plugin API) plugins.
ivo
parents:
diff changeset
201 setup->inputcontrols[p] = 0.0f;
14848
f92a93cfc508 10l fix. misplaced ;
ivo
parents: 14390
diff changeset
202 } else if (LADSPA_IS_PORT_OUTPUT(d)) {
14217
5b5ebf93ec16 Adds support for LADSPA (Linux Audio Developer's Simple Plugin API) plugins.
ivo
parents:
diff changeset
203 /* read and handle these too, otherwise filters that have them
5b5ebf93ec16 Adds support for LADSPA (Linux Audio Developer's Simple Plugin API) plugins.
ivo
parents:
diff changeset
204 * will sig11
5b5ebf93ec16 Adds support for LADSPA (Linux Audio Developer's Simple Plugin API) plugins.
ivo
parents:
diff changeset
205 */
5b5ebf93ec16 Adds support for LADSPA (Linux Audio Developer's Simple Plugin API) plugins.
ivo
parents:
diff changeset
206 setup->outputcontrolsmap[setup->noutputcontrols]=p;
5b5ebf93ec16 Adds support for LADSPA (Linux Audio Developer's Simple Plugin API) plugins.
ivo
parents:
diff changeset
207 setup->noutputcontrols++;
5b5ebf93ec16 Adds support for LADSPA (Linux Audio Developer's Simple Plugin API) plugins.
ivo
parents:
diff changeset
208 setup->outputcontrols[p] = 0.0f;
5b5ebf93ec16 Adds support for LADSPA (Linux Audio Developer's Simple Plugin API) plugins.
ivo
parents:
diff changeset
209 }
5b5ebf93ec16 Adds support for LADSPA (Linux Audio Developer's Simple Plugin API) plugins.
ivo
parents:
diff changeset
210 }
5b5ebf93ec16 Adds support for LADSPA (Linux Audio Developer's Simple Plugin API) plugins.
ivo
parents:
diff changeset
211
5b5ebf93ec16 Adds support for LADSPA (Linux Audio Developer's Simple Plugin API) plugins.
ivo
parents:
diff changeset
212 }
5b5ebf93ec16 Adds support for LADSPA (Linux Audio Developer's Simple Plugin API) plugins.
ivo
parents:
diff changeset
213
5b5ebf93ec16 Adds support for LADSPA (Linux Audio Developer's Simple Plugin API) plugins.
ivo
parents:
diff changeset
214 if (setup->ninputs == 0) {
29263
0f1b5b68af32 whitespace cosmetics: Remove all trailing whitespace.
diego
parents: 29049
diff changeset
215 mp_msg(MSGT_AFILTER, MSGL_WARN, "%s: %s\n", setup->myname,
14217
5b5ebf93ec16 Adds support for LADSPA (Linux Audio Developer's Simple Plugin API) plugins.
ivo
parents:
diff changeset
216 MSGTR_AF_LADSPA_WarnNoInputs);
5b5ebf93ec16 Adds support for LADSPA (Linux Audio Developer's Simple Plugin API) plugins.
ivo
parents:
diff changeset
217 } else if (setup->ninputs == 1) {
29049
8c706ce21c6f Remove af_msg special-casing API in libaf.
bircoph
parents: 28924
diff changeset
218 mp_msg(MSGT_AFILTER, MSGL_V, "%s: this is a mono effect\n", setup->myname);
14217
5b5ebf93ec16 Adds support for LADSPA (Linux Audio Developer's Simple Plugin API) plugins.
ivo
parents:
diff changeset
219 } else if (setup->ninputs == 2) {
29049
8c706ce21c6f Remove af_msg special-casing API in libaf.
bircoph
parents: 28924
diff changeset
220 mp_msg(MSGT_AFILTER, MSGL_V, "%s: this is a stereo effect\n", setup->myname);
22127
c6c141ab4fcf Experimental support for multichannel ladspa effects
reimar
parents: 19614
diff changeset
221 } else {
29049
8c706ce21c6f Remove af_msg special-casing API in libaf.
bircoph
parents: 28924
diff changeset
222 mp_msg(MSGT_AFILTER, MSGL_V, "%s: this is a %i-channel effect, "
22127
c6c141ab4fcf Experimental support for multichannel ladspa effects
reimar
parents: 19614
diff changeset
223 "support is experimental\n", setup->myname, setup->ninputs);
14217
5b5ebf93ec16 Adds support for LADSPA (Linux Audio Developer's Simple Plugin API) plugins.
ivo
parents:
diff changeset
224 }
5b5ebf93ec16 Adds support for LADSPA (Linux Audio Developer's Simple Plugin API) plugins.
ivo
parents:
diff changeset
225
5b5ebf93ec16 Adds support for LADSPA (Linux Audio Developer's Simple Plugin API) plugins.
ivo
parents:
diff changeset
226 if (setup->noutputs == 0) {
29049
8c706ce21c6f Remove af_msg special-casing API in libaf.
bircoph
parents: 28924
diff changeset
227 mp_msg(MSGT_AFILTER, MSGL_ERR, "%s: %s\n", setup->myname,
14217
5b5ebf93ec16 Adds support for LADSPA (Linux Audio Developer's Simple Plugin API) plugins.
ivo
parents:
diff changeset
228 MSGTR_AF_LADSPA_ErrNoOutputs);
5b5ebf93ec16 Adds support for LADSPA (Linux Audio Developer's Simple Plugin API) plugins.
ivo
parents:
diff changeset
229 return AF_ERROR;
5b5ebf93ec16 Adds support for LADSPA (Linux Audio Developer's Simple Plugin API) plugins.
ivo
parents:
diff changeset
230 }
5b5ebf93ec16 Adds support for LADSPA (Linux Audio Developer's Simple Plugin API) plugins.
ivo
parents:
diff changeset
231
5b5ebf93ec16 Adds support for LADSPA (Linux Audio Developer's Simple Plugin API) plugins.
ivo
parents:
diff changeset
232 if (setup->noutputs != setup->ninputs ) {
29049
8c706ce21c6f Remove af_msg special-casing API in libaf.
bircoph
parents: 28924
diff changeset
233 mp_msg(MSGT_AFILTER, MSGL_ERR, "%s: %s\n", setup->myname,
14217
5b5ebf93ec16 Adds support for LADSPA (Linux Audio Developer's Simple Plugin API) plugins.
ivo
parents:
diff changeset
234 MSGTR_AF_LADSPA_ErrInOutDiff);
5b5ebf93ec16 Adds support for LADSPA (Linux Audio Developer's Simple Plugin API) plugins.
ivo
parents:
diff changeset
235 return AF_ERROR;
5b5ebf93ec16 Adds support for LADSPA (Linux Audio Developer's Simple Plugin API) plugins.
ivo
parents:
diff changeset
236 }
5b5ebf93ec16 Adds support for LADSPA (Linux Audio Developer's Simple Plugin API) plugins.
ivo
parents:
diff changeset
237
29049
8c706ce21c6f Remove af_msg special-casing API in libaf.
bircoph
parents: 28924
diff changeset
238 mp_msg(MSGT_AFILTER, MSGL_V, "%s: this plugin has %d input control(s)\n",
14217
5b5ebf93ec16 Adds support for LADSPA (Linux Audio Developer's Simple Plugin API) plugins.
ivo
parents:
diff changeset
239 setup->myname, setup->ninputcontrols);
5b5ebf93ec16 Adds support for LADSPA (Linux Audio Developer's Simple Plugin API) plugins.
ivo
parents:
diff changeset
240
5b5ebf93ec16 Adds support for LADSPA (Linux Audio Developer's Simple Plugin API) plugins.
ivo
parents:
diff changeset
241 /* Print list of controls and its range of values it accepts */
5b5ebf93ec16 Adds support for LADSPA (Linux Audio Developer's Simple Plugin API) plugins.
ivo
parents:
diff changeset
242
5b5ebf93ec16 Adds support for LADSPA (Linux Audio Developer's Simple Plugin API) plugins.
ivo
parents:
diff changeset
243 for (i=0; i<setup->ninputcontrols; i++) {
5b5ebf93ec16 Adds support for LADSPA (Linux Audio Developer's Simple Plugin API) plugins.
ivo
parents:
diff changeset
244 p = setup->inputcontrolsmap[i];
5b5ebf93ec16 Adds support for LADSPA (Linux Audio Developer's Simple Plugin API) plugins.
ivo
parents:
diff changeset
245 hint = pdes->PortRangeHints[p];
29049
8c706ce21c6f Remove af_msg special-casing API in libaf.
bircoph
parents: 28924
diff changeset
246 mp_msg(MSGT_AFILTER, MSGL_V, " --- %d %s [", i, pdes->PortNames[p]);
14217
5b5ebf93ec16 Adds support for LADSPA (Linux Audio Developer's Simple Plugin API) plugins.
ivo
parents:
diff changeset
247
5b5ebf93ec16 Adds support for LADSPA (Linux Audio Developer's Simple Plugin API) plugins.
ivo
parents:
diff changeset
248 if (LADSPA_IS_HINT_BOUNDED_BELOW(hint.HintDescriptor)) {
29049
8c706ce21c6f Remove af_msg special-casing API in libaf.
bircoph
parents: 28924
diff changeset
249 mp_msg(MSGT_AFILTER, MSGL_V, "%0.2f , ", hint.LowerBound);
14217
5b5ebf93ec16 Adds support for LADSPA (Linux Audio Developer's Simple Plugin API) plugins.
ivo
parents:
diff changeset
250 } else {
29049
8c706ce21c6f Remove af_msg special-casing API in libaf.
bircoph
parents: 28924
diff changeset
251 mp_msg(MSGT_AFILTER, MSGL_V, "... , ");
14217
5b5ebf93ec16 Adds support for LADSPA (Linux Audio Developer's Simple Plugin API) plugins.
ivo
parents:
diff changeset
252 }
5b5ebf93ec16 Adds support for LADSPA (Linux Audio Developer's Simple Plugin API) plugins.
ivo
parents:
diff changeset
253
5b5ebf93ec16 Adds support for LADSPA (Linux Audio Developer's Simple Plugin API) plugins.
ivo
parents:
diff changeset
254 if (LADSPA_IS_HINT_BOUNDED_ABOVE(hint.HintDescriptor)) {
29049
8c706ce21c6f Remove af_msg special-casing API in libaf.
bircoph
parents: 28924
diff changeset
255 mp_msg(MSGT_AFILTER, MSGL_V, "%0.2f]\n", hint.UpperBound);
14217
5b5ebf93ec16 Adds support for LADSPA (Linux Audio Developer's Simple Plugin API) plugins.
ivo
parents:
diff changeset
256 } else {
29049
8c706ce21c6f Remove af_msg special-casing API in libaf.
bircoph
parents: 28924
diff changeset
257 mp_msg(MSGT_AFILTER, MSGL_V, "...]\n");
14217
5b5ebf93ec16 Adds support for LADSPA (Linux Audio Developer's Simple Plugin API) plugins.
ivo
parents:
diff changeset
258 }
5b5ebf93ec16 Adds support for LADSPA (Linux Audio Developer's Simple Plugin API) plugins.
ivo
parents:
diff changeset
259
5b5ebf93ec16 Adds support for LADSPA (Linux Audio Developer's Simple Plugin API) plugins.
ivo
parents:
diff changeset
260 }
5b5ebf93ec16 Adds support for LADSPA (Linux Audio Developer's Simple Plugin API) plugins.
ivo
parents:
diff changeset
261
5b5ebf93ec16 Adds support for LADSPA (Linux Audio Developer's Simple Plugin API) plugins.
ivo
parents:
diff changeset
262 return AF_OK;
5b5ebf93ec16 Adds support for LADSPA (Linux Audio Developer's Simple Plugin API) plugins.
ivo
parents:
diff changeset
263 }
5b5ebf93ec16 Adds support for LADSPA (Linux Audio Developer's Simple Plugin API) plugins.
ivo
parents:
diff changeset
264
5b5ebf93ec16 Adds support for LADSPA (Linux Audio Developer's Simple Plugin API) plugins.
ivo
parents:
diff changeset
265 /* ------------------------------------------------------------------------- */
5b5ebf93ec16 Adds support for LADSPA (Linux Audio Developer's Simple Plugin API) plugins.
ivo
parents:
diff changeset
266
5b5ebf93ec16 Adds support for LADSPA (Linux Audio Developer's Simple Plugin API) plugins.
ivo
parents:
diff changeset
267 /* This function might "slightly" look like dlopenLADSPA in the LADSPA SDK :-)
5b5ebf93ec16 Adds support for LADSPA (Linux Audio Developer's Simple Plugin API) plugins.
ivo
parents:
diff changeset
268 * But, I changed a few things, because imho it was broken. It did not support
5b5ebf93ec16 Adds support for LADSPA (Linux Audio Developer's Simple Plugin API) plugins.
ivo
parents:
diff changeset
269 * relative paths, only absolute paths that start with a /
5b5ebf93ec16 Adds support for LADSPA (Linux Audio Developer's Simple Plugin API) plugins.
ivo
parents:
diff changeset
270 * I think ../../some/dir/foobar.so is just as valid. And if one wants to call
5b5ebf93ec16 Adds support for LADSPA (Linux Audio Developer's Simple Plugin API) plugins.
ivo
parents:
diff changeset
271 * his library '...somename...so' he's crazy, but it should be allowed.
5b5ebf93ec16 Adds support for LADSPA (Linux Audio Developer's Simple Plugin API) plugins.
ivo
parents:
diff changeset
272 * So, search the path first, try plain *filename later.
5b5ebf93ec16 Adds support for LADSPA (Linux Audio Developer's Simple Plugin API) plugins.
ivo
parents:
diff changeset
273 * Also, try adding .so first! I like the recursion the SDK did, but it's
5b5ebf93ec16 Adds support for LADSPA (Linux Audio Developer's Simple Plugin API) plugins.
ivo
parents:
diff changeset
274 * better the other way around. -af ladspa=cmt:amp_stereo:0.5 is easier to type
5b5ebf93ec16 Adds support for LADSPA (Linux Audio Developer's Simple Plugin API) plugins.
ivo
parents:
diff changeset
275 * than -af ladspa=cmt.so:amp_stereo:0.5 :-))
5b5ebf93ec16 Adds support for LADSPA (Linux Audio Developer's Simple Plugin API) plugins.
ivo
parents:
diff changeset
276 */
5b5ebf93ec16 Adds support for LADSPA (Linux Audio Developer's Simple Plugin API) plugins.
ivo
parents:
diff changeset
277
5b5ebf93ec16 Adds support for LADSPA (Linux Audio Developer's Simple Plugin API) plugins.
ivo
parents:
diff changeset
278 /** \brief dlopen() wrapper
5b5ebf93ec16 Adds support for LADSPA (Linux Audio Developer's Simple Plugin API) plugins.
ivo
parents:
diff changeset
279 *
5b5ebf93ec16 Adds support for LADSPA (Linux Audio Developer's Simple Plugin API) plugins.
ivo
parents:
diff changeset
280 * This is a wrapper around dlopen(). It tries various variations of the
5b5ebf93ec16 Adds support for LADSPA (Linux Audio Developer's Simple Plugin API) plugins.
ivo
parents:
diff changeset
281 * filename (with or without the addition of the .so extension) in various
5b5ebf93ec16 Adds support for LADSPA (Linux Audio Developer's Simple Plugin API) plugins.
ivo
parents:
diff changeset
282 * directories specified by the LADSPA_PATH environment variable. If all fails
5b5ebf93ec16 Adds support for LADSPA (Linux Audio Developer's Simple Plugin API) plugins.
ivo
parents:
diff changeset
283 * it tries the filename directly as an absolute path to the library.
29263
0f1b5b68af32 whitespace cosmetics: Remove all trailing whitespace.
diego
parents: 29049
diff changeset
284 *
14217
5b5ebf93ec16 Adds support for LADSPA (Linux Audio Developer's Simple Plugin API) plugins.
ivo
parents:
diff changeset
285 * \param filename filename of the library to load.
5b5ebf93ec16 Adds support for LADSPA (Linux Audio Developer's Simple Plugin API) plugins.
ivo
parents:
diff changeset
286 * \param flag see dlopen(3) for a description of the flags.
5b5ebf93ec16 Adds support for LADSPA (Linux Audio Developer's Simple Plugin API) plugins.
ivo
parents:
diff changeset
287 *
5b5ebf93ec16 Adds support for LADSPA (Linux Audio Developer's Simple Plugin API) plugins.
ivo
parents:
diff changeset
288 * \return returns a pointer to the loaded library on success, or
5b5ebf93ec16 Adds support for LADSPA (Linux Audio Developer's Simple Plugin API) plugins.
ivo
parents:
diff changeset
289 * NULL if it fails to load.
5b5ebf93ec16 Adds support for LADSPA (Linux Audio Developer's Simple Plugin API) plugins.
ivo
parents:
diff changeset
290 */
5b5ebf93ec16 Adds support for LADSPA (Linux Audio Developer's Simple Plugin API) plugins.
ivo
parents:
diff changeset
291
5b5ebf93ec16 Adds support for LADSPA (Linux Audio Developer's Simple Plugin API) plugins.
ivo
parents:
diff changeset
292 static void* mydlopen(const char *filename, int flag) {
5b5ebf93ec16 Adds support for LADSPA (Linux Audio Developer's Simple Plugin API) plugins.
ivo
parents:
diff changeset
293 char *buf;
5b5ebf93ec16 Adds support for LADSPA (Linux Audio Developer's Simple Plugin API) plugins.
ivo
parents:
diff changeset
294 const char *end, *start, *ladspapath;
5b5ebf93ec16 Adds support for LADSPA (Linux Audio Developer's Simple Plugin API) plugins.
ivo
parents:
diff changeset
295 int endsinso, needslash;
5b5ebf93ec16 Adds support for LADSPA (Linux Audio Developer's Simple Plugin API) plugins.
ivo
parents:
diff changeset
296 size_t filenamelen;
5b5ebf93ec16 Adds support for LADSPA (Linux Audio Developer's Simple Plugin API) plugins.
ivo
parents:
diff changeset
297 void *result = NULL;
5b5ebf93ec16 Adds support for LADSPA (Linux Audio Developer's Simple Plugin API) plugins.
ivo
parents:
diff changeset
298
27727
48c1ae64255b Replace preprocessor check for WIN32 with checks for __MINGW32__ and __CYGWIN__.
diego
parents: 26740
diff changeset
299 #if defined(__MINGW32__) || defined(__CYGWIN__)
48c1ae64255b Replace preprocessor check for WIN32 with checks for __MINGW32__ and __CYGWIN__.
diego
parents: 26740
diff changeset
300 /* For Windows there's only absolute path support.
48c1ae64255b Replace preprocessor check for WIN32 with checks for __MINGW32__ and __CYGWIN__.
diego
parents: 26740
diff changeset
301 * If you have a Windows machine, feel free to fix this.
48c1ae64255b Replace preprocessor check for WIN32 with checks for __MINGW32__ and __CYGWIN__.
diego
parents: 26740
diff changeset
302 * (path separator, shared objects extension, et cetera). */
29049
8c706ce21c6f Remove af_msg special-casing API in libaf.
bircoph
parents: 28924
diff changeset
303 mp_msg(MSGT_AFILTER, MSGL_V, "\ton windows, only absolute pathnames "
14217
5b5ebf93ec16 Adds support for LADSPA (Linux Audio Developer's Simple Plugin API) plugins.
ivo
parents:
diff changeset
304 "are supported\n");
29049
8c706ce21c6f Remove af_msg special-casing API in libaf.
bircoph
parents: 28924
diff changeset
305 mp_msg(MSGT_AFILTER, MSGL_V, "\ttrying %s\n", filename);
14217
5b5ebf93ec16 Adds support for LADSPA (Linux Audio Developer's Simple Plugin API) plugins.
ivo
parents:
diff changeset
306 return dlopen(filename, flag);
27727
48c1ae64255b Replace preprocessor check for WIN32 with checks for __MINGW32__ and __CYGWIN__.
diego
parents: 26740
diff changeset
307 #endif
14217
5b5ebf93ec16 Adds support for LADSPA (Linux Audio Developer's Simple Plugin API) plugins.
ivo
parents:
diff changeset
308
5b5ebf93ec16 Adds support for LADSPA (Linux Audio Developer's Simple Plugin API) plugins.
ivo
parents:
diff changeset
309 filenamelen = strlen(filename);
5b5ebf93ec16 Adds support for LADSPA (Linux Audio Developer's Simple Plugin API) plugins.
ivo
parents:
diff changeset
310
5b5ebf93ec16 Adds support for LADSPA (Linux Audio Developer's Simple Plugin API) plugins.
ivo
parents:
diff changeset
311 endsinso = 0;
5b5ebf93ec16 Adds support for LADSPA (Linux Audio Developer's Simple Plugin API) plugins.
ivo
parents:
diff changeset
312 if (filenamelen > 3)
5b5ebf93ec16 Adds support for LADSPA (Linux Audio Developer's Simple Plugin API) plugins.
ivo
parents:
diff changeset
313 endsinso = (strcmp(filename+filenamelen-3, ".so") == 0);
5b5ebf93ec16 Adds support for LADSPA (Linux Audio Developer's Simple Plugin API) plugins.
ivo
parents:
diff changeset
314 if (!endsinso) {
5b5ebf93ec16 Adds support for LADSPA (Linux Audio Developer's Simple Plugin API) plugins.
ivo
parents:
diff changeset
315 buf=malloc(filenamelen+4);
5b5ebf93ec16 Adds support for LADSPA (Linux Audio Developer's Simple Plugin API) plugins.
ivo
parents:
diff changeset
316 strcpy(buf, filename);
5b5ebf93ec16 Adds support for LADSPA (Linux Audio Developer's Simple Plugin API) plugins.
ivo
parents:
diff changeset
317 strcat(buf, ".so");
5b5ebf93ec16 Adds support for LADSPA (Linux Audio Developer's Simple Plugin API) plugins.
ivo
parents:
diff changeset
318 result=mydlopen(buf, flag);
5b5ebf93ec16 Adds support for LADSPA (Linux Audio Developer's Simple Plugin API) plugins.
ivo
parents:
diff changeset
319 free(buf);
5b5ebf93ec16 Adds support for LADSPA (Linux Audio Developer's Simple Plugin API) plugins.
ivo
parents:
diff changeset
320 }
5b5ebf93ec16 Adds support for LADSPA (Linux Audio Developer's Simple Plugin API) plugins.
ivo
parents:
diff changeset
321
5b5ebf93ec16 Adds support for LADSPA (Linux Audio Developer's Simple Plugin API) plugins.
ivo
parents:
diff changeset
322 if (result)
5b5ebf93ec16 Adds support for LADSPA (Linux Audio Developer's Simple Plugin API) plugins.
ivo
parents:
diff changeset
323 return result;
5b5ebf93ec16 Adds support for LADSPA (Linux Audio Developer's Simple Plugin API) plugins.
ivo
parents:
diff changeset
324
5b5ebf93ec16 Adds support for LADSPA (Linux Audio Developer's Simple Plugin API) plugins.
ivo
parents:
diff changeset
325 ladspapath=getenv("LADSPA_PATH");
5b5ebf93ec16 Adds support for LADSPA (Linux Audio Developer's Simple Plugin API) plugins.
ivo
parents:
diff changeset
326
5b5ebf93ec16 Adds support for LADSPA (Linux Audio Developer's Simple Plugin API) plugins.
ivo
parents:
diff changeset
327 if (ladspapath) {
5b5ebf93ec16 Adds support for LADSPA (Linux Audio Developer's Simple Plugin API) plugins.
ivo
parents:
diff changeset
328
5b5ebf93ec16 Adds support for LADSPA (Linux Audio Developer's Simple Plugin API) plugins.
ivo
parents:
diff changeset
329 start=ladspapath;
5b5ebf93ec16 Adds support for LADSPA (Linux Audio Developer's Simple Plugin API) plugins.
ivo
parents:
diff changeset
330 while (*start != '\0') {
5b5ebf93ec16 Adds support for LADSPA (Linux Audio Developer's Simple Plugin API) plugins.
ivo
parents:
diff changeset
331 end=start;
5b5ebf93ec16 Adds support for LADSPA (Linux Audio Developer's Simple Plugin API) plugins.
ivo
parents:
diff changeset
332 while ( (*end != ':') && (*end != '\0') )
5b5ebf93ec16 Adds support for LADSPA (Linux Audio Developer's Simple Plugin API) plugins.
ivo
parents:
diff changeset
333 end++;
5b5ebf93ec16 Adds support for LADSPA (Linux Audio Developer's Simple Plugin API) plugins.
ivo
parents:
diff changeset
334
5b5ebf93ec16 Adds support for LADSPA (Linux Audio Developer's Simple Plugin API) plugins.
ivo
parents:
diff changeset
335 buf=malloc(filenamelen + 2 + (end-start) );
5b5ebf93ec16 Adds support for LADSPA (Linux Audio Developer's Simple Plugin API) plugins.
ivo
parents:
diff changeset
336 if (end > start)
5b5ebf93ec16 Adds support for LADSPA (Linux Audio Developer's Simple Plugin API) plugins.
ivo
parents:
diff changeset
337 strncpy(buf, start, end-start);
5b5ebf93ec16 Adds support for LADSPA (Linux Audio Developer's Simple Plugin API) plugins.
ivo
parents:
diff changeset
338 needslash=0;
5b5ebf93ec16 Adds support for LADSPA (Linux Audio Developer's Simple Plugin API) plugins.
ivo
parents:
diff changeset
339 if (end > start)
5b5ebf93ec16 Adds support for LADSPA (Linux Audio Developer's Simple Plugin API) plugins.
ivo
parents:
diff changeset
340 if (*(end-1) != '/') {
5b5ebf93ec16 Adds support for LADSPA (Linux Audio Developer's Simple Plugin API) plugins.
ivo
parents:
diff changeset
341 needslash = 1;
5b5ebf93ec16 Adds support for LADSPA (Linux Audio Developer's Simple Plugin API) plugins.
ivo
parents:
diff changeset
342 buf[end-start] = '/';
5b5ebf93ec16 Adds support for LADSPA (Linux Audio Developer's Simple Plugin API) plugins.
ivo
parents:
diff changeset
343 }
5b5ebf93ec16 Adds support for LADSPA (Linux Audio Developer's Simple Plugin API) plugins.
ivo
parents:
diff changeset
344 strcpy(buf+needslash+(end-start), filename);
5b5ebf93ec16 Adds support for LADSPA (Linux Audio Developer's Simple Plugin API) plugins.
ivo
parents:
diff changeset
345
29049
8c706ce21c6f Remove af_msg special-casing API in libaf.
bircoph
parents: 28924
diff changeset
346 mp_msg(MSGT_AFILTER, MSGL_V, "\ttrying %s\n", buf);
14217
5b5ebf93ec16 Adds support for LADSPA (Linux Audio Developer's Simple Plugin API) plugins.
ivo
parents:
diff changeset
347 result=dlopen(buf, flag);
5b5ebf93ec16 Adds support for LADSPA (Linux Audio Developer's Simple Plugin API) plugins.
ivo
parents:
diff changeset
348
5b5ebf93ec16 Adds support for LADSPA (Linux Audio Developer's Simple Plugin API) plugins.
ivo
parents:
diff changeset
349 free(buf);
5b5ebf93ec16 Adds support for LADSPA (Linux Audio Developer's Simple Plugin API) plugins.
ivo
parents:
diff changeset
350 if (result)
5b5ebf93ec16 Adds support for LADSPA (Linux Audio Developer's Simple Plugin API) plugins.
ivo
parents:
diff changeset
351 return result;
5b5ebf93ec16 Adds support for LADSPA (Linux Audio Developer's Simple Plugin API) plugins.
ivo
parents:
diff changeset
352
5b5ebf93ec16 Adds support for LADSPA (Linux Audio Developer's Simple Plugin API) plugins.
ivo
parents:
diff changeset
353 start = end;
5b5ebf93ec16 Adds support for LADSPA (Linux Audio Developer's Simple Plugin API) plugins.
ivo
parents:
diff changeset
354 if (*start == ':')
5b5ebf93ec16 Adds support for LADSPA (Linux Audio Developer's Simple Plugin API) plugins.
ivo
parents:
diff changeset
355 start++;
5b5ebf93ec16 Adds support for LADSPA (Linux Audio Developer's Simple Plugin API) plugins.
ivo
parents:
diff changeset
356 } /* end while there's still more in the path */
5b5ebf93ec16 Adds support for LADSPA (Linux Audio Developer's Simple Plugin API) plugins.
ivo
parents:
diff changeset
357 } /* end if there's a ladspapath */
5b5ebf93ec16 Adds support for LADSPA (Linux Audio Developer's Simple Plugin API) plugins.
ivo
parents:
diff changeset
358
5b5ebf93ec16 Adds support for LADSPA (Linux Audio Developer's Simple Plugin API) plugins.
ivo
parents:
diff changeset
359 /* last resort, just open it again, so the dlerror() message is correct */
29049
8c706ce21c6f Remove af_msg special-casing API in libaf.
bircoph
parents: 28924
diff changeset
360 mp_msg(MSGT_AFILTER, MSGL_V, "\ttrying %s\n", filename);
14217
5b5ebf93ec16 Adds support for LADSPA (Linux Audio Developer's Simple Plugin API) plugins.
ivo
parents:
diff changeset
361 return dlopen(filename,flag);
5b5ebf93ec16 Adds support for LADSPA (Linux Audio Developer's Simple Plugin API) plugins.
ivo
parents:
diff changeset
362 }
5b5ebf93ec16 Adds support for LADSPA (Linux Audio Developer's Simple Plugin API) plugins.
ivo
parents:
diff changeset
363
5b5ebf93ec16 Adds support for LADSPA (Linux Audio Developer's Simple Plugin API) plugins.
ivo
parents:
diff changeset
364 /* ------------------------------------------------------------------------- */
5b5ebf93ec16 Adds support for LADSPA (Linux Audio Developer's Simple Plugin API) plugins.
ivo
parents:
diff changeset
365
5b5ebf93ec16 Adds support for LADSPA (Linux Audio Developer's Simple Plugin API) plugins.
ivo
parents:
diff changeset
366 /** \brief Load a LADSPA Plugin
5b5ebf93ec16 Adds support for LADSPA (Linux Audio Developer's Simple Plugin API) plugins.
ivo
parents:
diff changeset
367 *
5b5ebf93ec16 Adds support for LADSPA (Linux Audio Developer's Simple Plugin API) plugins.
ivo
parents:
diff changeset
368 * This function loads the LADSPA plugin specified by the file and label
5b5ebf93ec16 Adds support for LADSPA (Linux Audio Developer's Simple Plugin API) plugins.
ivo
parents:
diff changeset
369 * that are present in the setup variable. First, it loads the library.
5b5ebf93ec16 Adds support for LADSPA (Linux Audio Developer's Simple Plugin API) plugins.
ivo
parents:
diff changeset
370 * If it fails, it returns AF_ERROR. If not, it continues to look for the
5b5ebf93ec16 Adds support for LADSPA (Linux Audio Developer's Simple Plugin API) plugins.
ivo
parents:
diff changeset
371 * specified label. If it finds it, it sets the plugin_descriptor inside
5b5ebf93ec16 Adds support for LADSPA (Linux Audio Developer's Simple Plugin API) plugins.
ivo
parents:
diff changeset
372 * setup and returns AF_OK. If it doesn't, it returns AF_ERROR. Special case
5b5ebf93ec16 Adds support for LADSPA (Linux Audio Developer's Simple Plugin API) plugins.
ivo
parents:
diff changeset
373 * is a label called 'help'. In that case, it prints a list of all available
5b5ebf93ec16 Adds support for LADSPA (Linux Audio Developer's Simple Plugin API) plugins.
ivo
parents:
diff changeset
374 * labels (filters) in the library specified by file.
5b5ebf93ec16 Adds support for LADSPA (Linux Audio Developer's Simple Plugin API) plugins.
ivo
parents:
diff changeset
375 *
5b5ebf93ec16 Adds support for LADSPA (Linux Audio Developer's Simple Plugin API) plugins.
ivo
parents:
diff changeset
376 * \param setup Current setup of the filter. Contains filename and label.
5b5ebf93ec16 Adds support for LADSPA (Linux Audio Developer's Simple Plugin API) plugins.
ivo
parents:
diff changeset
377 *
5b5ebf93ec16 Adds support for LADSPA (Linux Audio Developer's Simple Plugin API) plugins.
ivo
parents:
diff changeset
378 * \return Either AF_ERROR or AF_OK, depending on the success of the operation.
5b5ebf93ec16 Adds support for LADSPA (Linux Audio Developer's Simple Plugin API) plugins.
ivo
parents:
diff changeset
379 */
5b5ebf93ec16 Adds support for LADSPA (Linux Audio Developer's Simple Plugin API) plugins.
ivo
parents:
diff changeset
380
5b5ebf93ec16 Adds support for LADSPA (Linux Audio Developer's Simple Plugin API) plugins.
ivo
parents:
diff changeset
381 static int af_ladspa_load_plugin(af_ladspa_t *setup) {
5b5ebf93ec16 Adds support for LADSPA (Linux Audio Developer's Simple Plugin API) plugins.
ivo
parents:
diff changeset
382 const LADSPA_Descriptor *ladspa_descriptor;
5b5ebf93ec16 Adds support for LADSPA (Linux Audio Developer's Simple Plugin API) plugins.
ivo
parents:
diff changeset
383 LADSPA_Descriptor_Function descriptor_function;
5b5ebf93ec16 Adds support for LADSPA (Linux Audio Developer's Simple Plugin API) plugins.
ivo
parents:
diff changeset
384 int i;
5b5ebf93ec16 Adds support for LADSPA (Linux Audio Developer's Simple Plugin API) plugins.
ivo
parents:
diff changeset
385
5b5ebf93ec16 Adds support for LADSPA (Linux Audio Developer's Simple Plugin API) plugins.
ivo
parents:
diff changeset
386 /* load library */
29049
8c706ce21c6f Remove af_msg special-casing API in libaf.
bircoph
parents: 28924
diff changeset
387 mp_msg(MSGT_AFILTER, MSGL_V, "%s: loading ladspa plugin library %s\n",
14217
5b5ebf93ec16 Adds support for LADSPA (Linux Audio Developer's Simple Plugin API) plugins.
ivo
parents:
diff changeset
388 setup->myname, setup->file);
5b5ebf93ec16 Adds support for LADSPA (Linux Audio Developer's Simple Plugin API) plugins.
ivo
parents:
diff changeset
389
5b5ebf93ec16 Adds support for LADSPA (Linux Audio Developer's Simple Plugin API) plugins.
ivo
parents:
diff changeset
390 setup->libhandle = mydlopen(setup->file, RTLD_NOW);
5b5ebf93ec16 Adds support for LADSPA (Linux Audio Developer's Simple Plugin API) plugins.
ivo
parents:
diff changeset
391
5b5ebf93ec16 Adds support for LADSPA (Linux Audio Developer's Simple Plugin API) plugins.
ivo
parents:
diff changeset
392 if (!setup->libhandle) {
29049
8c706ce21c6f Remove af_msg special-casing API in libaf.
bircoph
parents: 28924
diff changeset
393 mp_msg(MSGT_AFILTER, MSGL_ERR, "%s: %s %s\n\t%s\n", setup->myname,
14217
5b5ebf93ec16 Adds support for LADSPA (Linux Audio Developer's Simple Plugin API) plugins.
ivo
parents:
diff changeset
394 MSGTR_AF_LADSPA_ErrFailedToLoad, setup->file, dlerror() );
5b5ebf93ec16 Adds support for LADSPA (Linux Audio Developer's Simple Plugin API) plugins.
ivo
parents:
diff changeset
395 return AF_ERROR;
5b5ebf93ec16 Adds support for LADSPA (Linux Audio Developer's Simple Plugin API) plugins.
ivo
parents:
diff changeset
396 }
5b5ebf93ec16 Adds support for LADSPA (Linux Audio Developer's Simple Plugin API) plugins.
ivo
parents:
diff changeset
397
29049
8c706ce21c6f Remove af_msg special-casing API in libaf.
bircoph
parents: 28924
diff changeset
398 mp_msg(MSGT_AFILTER, MSGL_V, "%s: library found.\n", setup->myname);
14217
5b5ebf93ec16 Adds support for LADSPA (Linux Audio Developer's Simple Plugin API) plugins.
ivo
parents:
diff changeset
399
5b5ebf93ec16 Adds support for LADSPA (Linux Audio Developer's Simple Plugin API) plugins.
ivo
parents:
diff changeset
400 /* find descriptor function */
5b5ebf93ec16 Adds support for LADSPA (Linux Audio Developer's Simple Plugin API) plugins.
ivo
parents:
diff changeset
401 dlerror();
5b5ebf93ec16 Adds support for LADSPA (Linux Audio Developer's Simple Plugin API) plugins.
ivo
parents:
diff changeset
402 descriptor_function = (LADSPA_Descriptor_Function) dlsym (setup->libhandle,
5b5ebf93ec16 Adds support for LADSPA (Linux Audio Developer's Simple Plugin API) plugins.
ivo
parents:
diff changeset
403 "ladspa_descriptor");
5b5ebf93ec16 Adds support for LADSPA (Linux Audio Developer's Simple Plugin API) plugins.
ivo
parents:
diff changeset
404
5b5ebf93ec16 Adds support for LADSPA (Linux Audio Developer's Simple Plugin API) plugins.
ivo
parents:
diff changeset
405 if (!descriptor_function) {
29049
8c706ce21c6f Remove af_msg special-casing API in libaf.
bircoph
parents: 28924
diff changeset
406 mp_msg(MSGT_AFILTER, MSGL_ERR, "%s: %s\n\t%s\n", setup->myname,
14217
5b5ebf93ec16 Adds support for LADSPA (Linux Audio Developer's Simple Plugin API) plugins.
ivo
parents:
diff changeset
407 MSGTR_AF_LADSPA_ErrNoDescriptor, dlerror());
5b5ebf93ec16 Adds support for LADSPA (Linux Audio Developer's Simple Plugin API) plugins.
ivo
parents:
diff changeset
408 return AF_ERROR;
5b5ebf93ec16 Adds support for LADSPA (Linux Audio Developer's Simple Plugin API) plugins.
ivo
parents:
diff changeset
409 }
5b5ebf93ec16 Adds support for LADSPA (Linux Audio Developer's Simple Plugin API) plugins.
ivo
parents:
diff changeset
410
5b5ebf93ec16 Adds support for LADSPA (Linux Audio Developer's Simple Plugin API) plugins.
ivo
parents:
diff changeset
411 /* if label == help, list all labels in library and exit */
5b5ebf93ec16 Adds support for LADSPA (Linux Audio Developer's Simple Plugin API) plugins.
ivo
parents:
diff changeset
412
5b5ebf93ec16 Adds support for LADSPA (Linux Audio Developer's Simple Plugin API) plugins.
ivo
parents:
diff changeset
413 if (strcmp(setup->label, "help") == 0) {
29263
0f1b5b68af32 whitespace cosmetics: Remove all trailing whitespace.
diego
parents: 29049
diff changeset
414 mp_msg(MSGT_AFILTER, MSGL_INFO, "%s: %s %s:\n", setup->myname,
14217
5b5ebf93ec16 Adds support for LADSPA (Linux Audio Developer's Simple Plugin API) plugins.
ivo
parents:
diff changeset
415 MSGTR_AF_LADSPA_AvailableLabels, setup->file);
5b5ebf93ec16 Adds support for LADSPA (Linux Audio Developer's Simple Plugin API) plugins.
ivo
parents:
diff changeset
416 for (i=0; ; i++) {
5b5ebf93ec16 Adds support for LADSPA (Linux Audio Developer's Simple Plugin API) plugins.
ivo
parents:
diff changeset
417 ladspa_descriptor = descriptor_function(i);
5b5ebf93ec16 Adds support for LADSPA (Linux Audio Developer's Simple Plugin API) plugins.
ivo
parents:
diff changeset
418 if (ladspa_descriptor == NULL) {
5b5ebf93ec16 Adds support for LADSPA (Linux Audio Developer's Simple Plugin API) plugins.
ivo
parents:
diff changeset
419 return AF_ERROR;
5b5ebf93ec16 Adds support for LADSPA (Linux Audio Developer's Simple Plugin API) plugins.
ivo
parents:
diff changeset
420 }
29049
8c706ce21c6f Remove af_msg special-casing API in libaf.
bircoph
parents: 28924
diff changeset
421 mp_msg(MSGT_AFILTER, MSGL_INFO, " %-16s - %s (%lu)\n",
14217
5b5ebf93ec16 Adds support for LADSPA (Linux Audio Developer's Simple Plugin API) plugins.
ivo
parents:
diff changeset
422 ladspa_descriptor->Label,
5b5ebf93ec16 Adds support for LADSPA (Linux Audio Developer's Simple Plugin API) plugins.
ivo
parents:
diff changeset
423 ladspa_descriptor->Name,
5b5ebf93ec16 Adds support for LADSPA (Linux Audio Developer's Simple Plugin API) plugins.
ivo
parents:
diff changeset
424 ladspa_descriptor->UniqueID);
5b5ebf93ec16 Adds support for LADSPA (Linux Audio Developer's Simple Plugin API) plugins.
ivo
parents:
diff changeset
425 }
5b5ebf93ec16 Adds support for LADSPA (Linux Audio Developer's Simple Plugin API) plugins.
ivo
parents:
diff changeset
426 }
5b5ebf93ec16 Adds support for LADSPA (Linux Audio Developer's Simple Plugin API) plugins.
ivo
parents:
diff changeset
427
29049
8c706ce21c6f Remove af_msg special-casing API in libaf.
bircoph
parents: 28924
diff changeset
428 mp_msg(MSGT_AFILTER, MSGL_V, "%s: looking for label\n", setup->myname);
14217
5b5ebf93ec16 Adds support for LADSPA (Linux Audio Developer's Simple Plugin API) plugins.
ivo
parents:
diff changeset
429
5b5ebf93ec16 Adds support for LADSPA (Linux Audio Developer's Simple Plugin API) plugins.
ivo
parents:
diff changeset
430 /* find label in library */
5b5ebf93ec16 Adds support for LADSPA (Linux Audio Developer's Simple Plugin API) plugins.
ivo
parents:
diff changeset
431 for (i=0; ; i++) {
5b5ebf93ec16 Adds support for LADSPA (Linux Audio Developer's Simple Plugin API) plugins.
ivo
parents:
diff changeset
432 ladspa_descriptor = descriptor_function(i);
5b5ebf93ec16 Adds support for LADSPA (Linux Audio Developer's Simple Plugin API) plugins.
ivo
parents:
diff changeset
433 if (ladspa_descriptor == NULL) {
29049
8c706ce21c6f Remove af_msg special-casing API in libaf.
bircoph
parents: 28924
diff changeset
434 mp_msg(MSGT_AFILTER, MSGL_ERR, "%s: %s\n", setup->myname,
14217
5b5ebf93ec16 Adds support for LADSPA (Linux Audio Developer's Simple Plugin API) plugins.
ivo
parents:
diff changeset
435 MSGTR_AF_LADSPA_ErrLabelNotFound);
5b5ebf93ec16 Adds support for LADSPA (Linux Audio Developer's Simple Plugin API) plugins.
ivo
parents:
diff changeset
436 return AF_ERROR;
5b5ebf93ec16 Adds support for LADSPA (Linux Audio Developer's Simple Plugin API) plugins.
ivo
parents:
diff changeset
437 }
5b5ebf93ec16 Adds support for LADSPA (Linux Audio Developer's Simple Plugin API) plugins.
ivo
parents:
diff changeset
438 if (strcmp(ladspa_descriptor->Label, setup->label) == 0) {
5b5ebf93ec16 Adds support for LADSPA (Linux Audio Developer's Simple Plugin API) plugins.
ivo
parents:
diff changeset
439 setup->plugin_descriptor = ladspa_descriptor;
29049
8c706ce21c6f Remove af_msg special-casing API in libaf.
bircoph
parents: 28924
diff changeset
440 mp_msg(MSGT_AFILTER, MSGL_V, "%s: %s found\n", setup->myname,
14217
5b5ebf93ec16 Adds support for LADSPA (Linux Audio Developer's Simple Plugin API) plugins.
ivo
parents:
diff changeset
441 setup->label);
5b5ebf93ec16 Adds support for LADSPA (Linux Audio Developer's Simple Plugin API) plugins.
ivo
parents:
diff changeset
442 return AF_OK;
5b5ebf93ec16 Adds support for LADSPA (Linux Audio Developer's Simple Plugin API) plugins.
ivo
parents:
diff changeset
443 }
5b5ebf93ec16 Adds support for LADSPA (Linux Audio Developer's Simple Plugin API) plugins.
ivo
parents:
diff changeset
444 }
5b5ebf93ec16 Adds support for LADSPA (Linux Audio Developer's Simple Plugin API) plugins.
ivo
parents:
diff changeset
445
5b5ebf93ec16 Adds support for LADSPA (Linux Audio Developer's Simple Plugin API) plugins.
ivo
parents:
diff changeset
446 return AF_OK;
5b5ebf93ec16 Adds support for LADSPA (Linux Audio Developer's Simple Plugin API) plugins.
ivo
parents:
diff changeset
447 }
5b5ebf93ec16 Adds support for LADSPA (Linux Audio Developer's Simple Plugin API) plugins.
ivo
parents:
diff changeset
448
5b5ebf93ec16 Adds support for LADSPA (Linux Audio Developer's Simple Plugin API) plugins.
ivo
parents:
diff changeset
449 /* ------------------------------------------------------------------------- */
5b5ebf93ec16 Adds support for LADSPA (Linux Audio Developer's Simple Plugin API) plugins.
ivo
parents:
diff changeset
450
5b5ebf93ec16 Adds support for LADSPA (Linux Audio Developer's Simple Plugin API) plugins.
ivo
parents:
diff changeset
451 /** \brief Print a malloc() failed error message.
5b5ebf93ec16 Adds support for LADSPA (Linux Audio Developer's Simple Plugin API) plugins.
ivo
parents:
diff changeset
452 *
5b5ebf93ec16 Adds support for LADSPA (Linux Audio Developer's Simple Plugin API) plugins.
ivo
parents:
diff changeset
453 * Generic function which can be called if a call to malloc(), calloc(),
5b5ebf93ec16 Adds support for LADSPA (Linux Audio Developer's Simple Plugin API) plugins.
ivo
parents:
diff changeset
454 * strdup(), et cetera, failed. It prints a message to the console and
5b5ebf93ec16 Adds support for LADSPA (Linux Audio Developer's Simple Plugin API) plugins.
ivo
parents:
diff changeset
455 * returns AF_ERROR.
5b5ebf93ec16 Adds support for LADSPA (Linux Audio Developer's Simple Plugin API) plugins.
ivo
parents:
diff changeset
456 *
5b5ebf93ec16 Adds support for LADSPA (Linux Audio Developer's Simple Plugin API) plugins.
ivo
parents:
diff changeset
457 * \return AF_ERROR
5b5ebf93ec16 Adds support for LADSPA (Linux Audio Developer's Simple Plugin API) plugins.
ivo
parents:
diff changeset
458 */
5b5ebf93ec16 Adds support for LADSPA (Linux Audio Developer's Simple Plugin API) plugins.
ivo
parents:
diff changeset
459
5b5ebf93ec16 Adds support for LADSPA (Linux Audio Developer's Simple Plugin API) plugins.
ivo
parents:
diff changeset
460 static int af_ladspa_malloc_failed(char *myname) {
29049
8c706ce21c6f Remove af_msg special-casing API in libaf.
bircoph
parents: 28924
diff changeset
461 mp_msg(MSGT_AFILTER, MSGL_ERR, "%s: %s", myname, MSGTR_MemAllocFailed);
14217
5b5ebf93ec16 Adds support for LADSPA (Linux Audio Developer's Simple Plugin API) plugins.
ivo
parents:
diff changeset
462 return AF_ERROR;
5b5ebf93ec16 Adds support for LADSPA (Linux Audio Developer's Simple Plugin API) plugins.
ivo
parents:
diff changeset
463 }
5b5ebf93ec16 Adds support for LADSPA (Linux Audio Developer's Simple Plugin API) plugins.
ivo
parents:
diff changeset
464
5b5ebf93ec16 Adds support for LADSPA (Linux Audio Developer's Simple Plugin API) plugins.
ivo
parents:
diff changeset
465 /* ------------------------------------------------------------------------- */
5b5ebf93ec16 Adds support for LADSPA (Linux Audio Developer's Simple Plugin API) plugins.
ivo
parents:
diff changeset
466
5b5ebf93ec16 Adds support for LADSPA (Linux Audio Developer's Simple Plugin API) plugins.
ivo
parents:
diff changeset
467 /** \brief Controls the filter.
5b5ebf93ec16 Adds support for LADSPA (Linux Audio Developer's Simple Plugin API) plugins.
ivo
parents:
diff changeset
468 *
5b5ebf93ec16 Adds support for LADSPA (Linux Audio Developer's Simple Plugin API) plugins.
ivo
parents:
diff changeset
469 * Control the behaviour of the filter.
5b5ebf93ec16 Adds support for LADSPA (Linux Audio Developer's Simple Plugin API) plugins.
ivo
parents:
diff changeset
470 *
5b5ebf93ec16 Adds support for LADSPA (Linux Audio Developer's Simple Plugin API) plugins.
ivo
parents:
diff changeset
471 * Commands:
5b5ebf93ec16 Adds support for LADSPA (Linux Audio Developer's Simple Plugin API) plugins.
ivo
parents:
diff changeset
472 * CONTROL_REINIT Sets the af structure with proper values for number
5b5ebf93ec16 Adds support for LADSPA (Linux Audio Developer's Simple Plugin API) plugins.
ivo
parents:
diff changeset
473 * of channels, rate, format, et cetera.
5b5ebf93ec16 Adds support for LADSPA (Linux Audio Developer's Simple Plugin API) plugins.
ivo
parents:
diff changeset
474 * CONTROL_COMMAND_LINE Parses the suboptions given to this filter
5b5ebf93ec16 Adds support for LADSPA (Linux Audio Developer's Simple Plugin API) plugins.
ivo
parents:
diff changeset
475 * through arg. It first parses the filename and
5b5ebf93ec16 Adds support for LADSPA (Linux Audio Developer's Simple Plugin API) plugins.
ivo
parents:
diff changeset
476 * the label. After that, it loads the filter
5b5ebf93ec16 Adds support for LADSPA (Linux Audio Developer's Simple Plugin API) plugins.
ivo
parents:
diff changeset
477 * and finds out its proprties. Then in continues
5b5ebf93ec16 Adds support for LADSPA (Linux Audio Developer's Simple Plugin API) plugins.
ivo
parents:
diff changeset
478 * parsing the controls given on the commandline,
5b5ebf93ec16 Adds support for LADSPA (Linux Audio Developer's Simple Plugin API) plugins.
ivo
parents:
diff changeset
479 * if any are needed.
5b5ebf93ec16 Adds support for LADSPA (Linux Audio Developer's Simple Plugin API) plugins.
ivo
parents:
diff changeset
480 *
5b5ebf93ec16 Adds support for LADSPA (Linux Audio Developer's Simple Plugin API) plugins.
ivo
parents:
diff changeset
481 * \param af Audio filter instance
5b5ebf93ec16 Adds support for LADSPA (Linux Audio Developer's Simple Plugin API) plugins.
ivo
parents:
diff changeset
482 * \param cmd The command to execute
5b5ebf93ec16 Adds support for LADSPA (Linux Audio Developer's Simple Plugin API) plugins.
ivo
parents:
diff changeset
483 * \param arg Arguments to the command
5b5ebf93ec16 Adds support for LADSPA (Linux Audio Developer's Simple Plugin API) plugins.
ivo
parents:
diff changeset
484 *
5b5ebf93ec16 Adds support for LADSPA (Linux Audio Developer's Simple Plugin API) plugins.
ivo
parents:
diff changeset
485 * \return Either AF_ERROR or AF_OK, depending on the succes of the
5b5ebf93ec16 Adds support for LADSPA (Linux Audio Developer's Simple Plugin API) plugins.
ivo
parents:
diff changeset
486 * operation.
5b5ebf93ec16 Adds support for LADSPA (Linux Audio Developer's Simple Plugin API) plugins.
ivo
parents:
diff changeset
487 */
5b5ebf93ec16 Adds support for LADSPA (Linux Audio Developer's Simple Plugin API) plugins.
ivo
parents:
diff changeset
488
5b5ebf93ec16 Adds support for LADSPA (Linux Audio Developer's Simple Plugin API) plugins.
ivo
parents:
diff changeset
489 static int control(struct af_instance_s *af, int cmd, void *arg) {
5b5ebf93ec16 Adds support for LADSPA (Linux Audio Developer's Simple Plugin API) plugins.
ivo
parents:
diff changeset
490 af_ladspa_t *setup = (af_ladspa_t*) af->setup;
5b5ebf93ec16 Adds support for LADSPA (Linux Audio Developer's Simple Plugin API) plugins.
ivo
parents:
diff changeset
491 int i, r;
5b5ebf93ec16 Adds support for LADSPA (Linux Audio Developer's Simple Plugin API) plugins.
ivo
parents:
diff changeset
492 float val;
5b5ebf93ec16 Adds support for LADSPA (Linux Audio Developer's Simple Plugin API) plugins.
ivo
parents:
diff changeset
493
5b5ebf93ec16 Adds support for LADSPA (Linux Audio Developer's Simple Plugin API) plugins.
ivo
parents:
diff changeset
494 switch(cmd) {
5b5ebf93ec16 Adds support for LADSPA (Linux Audio Developer's Simple Plugin API) plugins.
ivo
parents:
diff changeset
495 case AF_CONTROL_REINIT:
29049
8c706ce21c6f Remove af_msg special-casing API in libaf.
bircoph
parents: 28924
diff changeset
496 mp_msg(MSGT_AFILTER, MSGL_V, "%s: (re)init\n", setup->myname);
14217
5b5ebf93ec16 Adds support for LADSPA (Linux Audio Developer's Simple Plugin API) plugins.
ivo
parents:
diff changeset
497
5b5ebf93ec16 Adds support for LADSPA (Linux Audio Developer's Simple Plugin API) plugins.
ivo
parents:
diff changeset
498 if (!arg) return AF_ERROR;
5b5ebf93ec16 Adds support for LADSPA (Linux Audio Developer's Simple Plugin API) plugins.
ivo
parents:
diff changeset
499
16195
cb08f47d3a79 Removed in-filter int to float conversion. af_ladspa now demands floats as
ivo
parents: 15790
diff changeset
500 /* accept FLOAT, let af_format do conversion */
14217
5b5ebf93ec16 Adds support for LADSPA (Linux Audio Developer's Simple Plugin API) plugins.
ivo
parents:
diff changeset
501
5b5ebf93ec16 Adds support for LADSPA (Linux Audio Developer's Simple Plugin API) plugins.
ivo
parents:
diff changeset
502 af->data->rate = ((af_data_t*)arg)->rate;
5b5ebf93ec16 Adds support for LADSPA (Linux Audio Developer's Simple Plugin API) plugins.
ivo
parents:
diff changeset
503 af->data->nch = ((af_data_t*)arg)->nch;
16195
cb08f47d3a79 Removed in-filter int to float conversion. af_ladspa now demands floats as
ivo
parents: 15790
diff changeset
504 af->data->format = AF_FORMAT_FLOAT_NE;
cb08f47d3a79 Removed in-filter int to float conversion. af_ladspa now demands floats as
ivo
parents: 15790
diff changeset
505 af->data->bps = 4;
14217
5b5ebf93ec16 Adds support for LADSPA (Linux Audio Developer's Simple Plugin API) plugins.
ivo
parents:
diff changeset
506
5b5ebf93ec16 Adds support for LADSPA (Linux Audio Developer's Simple Plugin API) plugins.
ivo
parents:
diff changeset
507 /* arg->len is not set here yet, so init of buffers and connecting the
5b5ebf93ec16 Adds support for LADSPA (Linux Audio Developer's Simple Plugin API) plugins.
ivo
parents:
diff changeset
508 * filter, has to be done in play() :-/
5b5ebf93ec16 Adds support for LADSPA (Linux Audio Developer's Simple Plugin API) plugins.
ivo
parents:
diff changeset
509 */
5b5ebf93ec16 Adds support for LADSPA (Linux Audio Developer's Simple Plugin API) plugins.
ivo
parents:
diff changeset
510
5b5ebf93ec16 Adds support for LADSPA (Linux Audio Developer's Simple Plugin API) plugins.
ivo
parents:
diff changeset
511 return af_test_output(af, (af_data_t*)arg);
5b5ebf93ec16 Adds support for LADSPA (Linux Audio Developer's Simple Plugin API) plugins.
ivo
parents:
diff changeset
512 case AF_CONTROL_COMMAND_LINE: {
5b5ebf93ec16 Adds support for LADSPA (Linux Audio Developer's Simple Plugin API) plugins.
ivo
parents:
diff changeset
513 char *buf;
5b5ebf93ec16 Adds support for LADSPA (Linux Audio Developer's Simple Plugin API) plugins.
ivo
parents:
diff changeset
514
29049
8c706ce21c6f Remove af_msg special-casing API in libaf.
bircoph
parents: 28924
diff changeset
515 mp_msg(MSGT_AFILTER, MSGL_V, "%s: parse suboptions\n", setup->myname);
14217
5b5ebf93ec16 Adds support for LADSPA (Linux Audio Developer's Simple Plugin API) plugins.
ivo
parents:
diff changeset
516
5b5ebf93ec16 Adds support for LADSPA (Linux Audio Developer's Simple Plugin API) plugins.
ivo
parents:
diff changeset
517 /* suboption parser here!
5b5ebf93ec16 Adds support for LADSPA (Linux Audio Developer's Simple Plugin API) plugins.
ivo
parents:
diff changeset
518 * format is (ladspa=)file:label:controls....
5b5ebf93ec16 Adds support for LADSPA (Linux Audio Developer's Simple Plugin API) plugins.
ivo
parents:
diff changeset
519 */
5b5ebf93ec16 Adds support for LADSPA (Linux Audio Developer's Simple Plugin API) plugins.
ivo
parents:
diff changeset
520
5b5ebf93ec16 Adds support for LADSPA (Linux Audio Developer's Simple Plugin API) plugins.
ivo
parents:
diff changeset
521 if (!arg) {
29049
8c706ce21c6f Remove af_msg special-casing API in libaf.
bircoph
parents: 28924
diff changeset
522 mp_msg(MSGT_AFILTER, MSGL_ERR, "%s: %s\n", setup->myname,
14217
5b5ebf93ec16 Adds support for LADSPA (Linux Audio Developer's Simple Plugin API) plugins.
ivo
parents:
diff changeset
523 MSGTR_AF_LADSPA_ErrNoSuboptions);
5b5ebf93ec16 Adds support for LADSPA (Linux Audio Developer's Simple Plugin API) plugins.
ivo
parents:
diff changeset
524 return AF_ERROR;
5b5ebf93ec16 Adds support for LADSPA (Linux Audio Developer's Simple Plugin API) plugins.
ivo
parents:
diff changeset
525 }
5b5ebf93ec16 Adds support for LADSPA (Linux Audio Developer's Simple Plugin API) plugins.
ivo
parents:
diff changeset
526
5b5ebf93ec16 Adds support for LADSPA (Linux Audio Developer's Simple Plugin API) plugins.
ivo
parents:
diff changeset
527 buf = malloc(strlen(arg)+1);
5b5ebf93ec16 Adds support for LADSPA (Linux Audio Developer's Simple Plugin API) plugins.
ivo
parents:
diff changeset
528 if (!buf) return af_ladspa_malloc_failed(setup->myname);
5b5ebf93ec16 Adds support for LADSPA (Linux Audio Developer's Simple Plugin API) plugins.
ivo
parents:
diff changeset
529
5b5ebf93ec16 Adds support for LADSPA (Linux Audio Developer's Simple Plugin API) plugins.
ivo
parents:
diff changeset
530 /* file... */
5b5ebf93ec16 Adds support for LADSPA (Linux Audio Developer's Simple Plugin API) plugins.
ivo
parents:
diff changeset
531 buf[0] = '\0';
5b5ebf93ec16 Adds support for LADSPA (Linux Audio Developer's Simple Plugin API) plugins.
ivo
parents:
diff changeset
532 sscanf(arg, "%[^:]", buf);
5b5ebf93ec16 Adds support for LADSPA (Linux Audio Developer's Simple Plugin API) plugins.
ivo
parents:
diff changeset
533 if (buf[0] == '\0') {
29049
8c706ce21c6f Remove af_msg special-casing API in libaf.
bircoph
parents: 28924
diff changeset
534 mp_msg(MSGT_AFILTER, MSGL_ERR, "%s: %s\n", setup->myname,
14217
5b5ebf93ec16 Adds support for LADSPA (Linux Audio Developer's Simple Plugin API) plugins.
ivo
parents:
diff changeset
535 MSGTR_AF_LADSPA_ErrNoLibFile);
5b5ebf93ec16 Adds support for LADSPA (Linux Audio Developer's Simple Plugin API) plugins.
ivo
parents:
diff changeset
536 free(buf);
5b5ebf93ec16 Adds support for LADSPA (Linux Audio Developer's Simple Plugin API) plugins.
ivo
parents:
diff changeset
537 return AF_ERROR;
5b5ebf93ec16 Adds support for LADSPA (Linux Audio Developer's Simple Plugin API) plugins.
ivo
parents:
diff changeset
538 }
5b5ebf93ec16 Adds support for LADSPA (Linux Audio Developer's Simple Plugin API) plugins.
ivo
parents:
diff changeset
539 arg += strlen(buf);
5b5ebf93ec16 Adds support for LADSPA (Linux Audio Developer's Simple Plugin API) plugins.
ivo
parents:
diff changeset
540 setup->file = strdup(buf);
5b5ebf93ec16 Adds support for LADSPA (Linux Audio Developer's Simple Plugin API) plugins.
ivo
parents:
diff changeset
541 if (!setup->file) return af_ladspa_malloc_failed(setup->myname);
29049
8c706ce21c6f Remove af_msg special-casing API in libaf.
bircoph
parents: 28924
diff changeset
542 mp_msg(MSGT_AFILTER, MSGL_V, "%s: file --> %s\n", setup->myname,
14217
5b5ebf93ec16 Adds support for LADSPA (Linux Audio Developer's Simple Plugin API) plugins.
ivo
parents:
diff changeset
543 setup->file);
5b5ebf93ec16 Adds support for LADSPA (Linux Audio Developer's Simple Plugin API) plugins.
ivo
parents:
diff changeset
544 if (*(char*)arg != '\0') arg++; /* read ':' */
5b5ebf93ec16 Adds support for LADSPA (Linux Audio Developer's Simple Plugin API) plugins.
ivo
parents:
diff changeset
545
5b5ebf93ec16 Adds support for LADSPA (Linux Audio Developer's Simple Plugin API) plugins.
ivo
parents:
diff changeset
546 /* label... */
5b5ebf93ec16 Adds support for LADSPA (Linux Audio Developer's Simple Plugin API) plugins.
ivo
parents:
diff changeset
547 buf[0] = '\0';
5b5ebf93ec16 Adds support for LADSPA (Linux Audio Developer's Simple Plugin API) plugins.
ivo
parents:
diff changeset
548 sscanf(arg, "%[^:]", buf);
5b5ebf93ec16 Adds support for LADSPA (Linux Audio Developer's Simple Plugin API) plugins.
ivo
parents:
diff changeset
549 if (buf[0] == '\0') {
29049
8c706ce21c6f Remove af_msg special-casing API in libaf.
bircoph
parents: 28924
diff changeset
550 mp_msg(MSGT_AFILTER, MSGL_ERR, "%s: %s\n", setup->myname,
14217
5b5ebf93ec16 Adds support for LADSPA (Linux Audio Developer's Simple Plugin API) plugins.
ivo
parents:
diff changeset
551 MSGTR_AF_LADSPA_ErrNoLabel);
5b5ebf93ec16 Adds support for LADSPA (Linux Audio Developer's Simple Plugin API) plugins.
ivo
parents:
diff changeset
552 free(buf);
5b5ebf93ec16 Adds support for LADSPA (Linux Audio Developer's Simple Plugin API) plugins.
ivo
parents:
diff changeset
553 return AF_ERROR;
5b5ebf93ec16 Adds support for LADSPA (Linux Audio Developer's Simple Plugin API) plugins.
ivo
parents:
diff changeset
554 }
5b5ebf93ec16 Adds support for LADSPA (Linux Audio Developer's Simple Plugin API) plugins.
ivo
parents:
diff changeset
555 arg += strlen(buf);
5b5ebf93ec16 Adds support for LADSPA (Linux Audio Developer's Simple Plugin API) plugins.
ivo
parents:
diff changeset
556 setup->label = strdup(buf);
5b5ebf93ec16 Adds support for LADSPA (Linux Audio Developer's Simple Plugin API) plugins.
ivo
parents:
diff changeset
557 if (!setup->label) return af_ladspa_malloc_failed(setup->myname);
29049
8c706ce21c6f Remove af_msg special-casing API in libaf.
bircoph
parents: 28924
diff changeset
558 mp_msg(MSGT_AFILTER, MSGL_V, "%s: label --> %s\n", setup->myname,
14217
5b5ebf93ec16 Adds support for LADSPA (Linux Audio Developer's Simple Plugin API) plugins.
ivo
parents:
diff changeset
559 setup->label);
5b5ebf93ec16 Adds support for LADSPA (Linux Audio Developer's Simple Plugin API) plugins.
ivo
parents:
diff changeset
560 /* if (*(char*)arg != '0') arg++; */ /* read ':' */
29263
0f1b5b68af32 whitespace cosmetics: Remove all trailing whitespace.
diego
parents: 29049
diff changeset
561
14217
5b5ebf93ec16 Adds support for LADSPA (Linux Audio Developer's Simple Plugin API) plugins.
ivo
parents:
diff changeset
562 free(buf); /* no longer needed */
5b5ebf93ec16 Adds support for LADSPA (Linux Audio Developer's Simple Plugin API) plugins.
ivo
parents:
diff changeset
563
5b5ebf93ec16 Adds support for LADSPA (Linux Audio Developer's Simple Plugin API) plugins.
ivo
parents:
diff changeset
564 /* set new setup->myname */
5b5ebf93ec16 Adds support for LADSPA (Linux Audio Developer's Simple Plugin API) plugins.
ivo
parents:
diff changeset
565
32537
8fa2f43cb760 Remove most of the NULL pointer check before free all over the code
cboesch
parents: 31492
diff changeset
566 free(setup->myname);
14217
5b5ebf93ec16 Adds support for LADSPA (Linux Audio Developer's Simple Plugin API) plugins.
ivo
parents:
diff changeset
567 setup->myname = calloc(strlen(af_info_ladspa.name)+strlen(setup->file)+
5b5ebf93ec16 Adds support for LADSPA (Linux Audio Developer's Simple Plugin API) plugins.
ivo
parents:
diff changeset
568 strlen(setup->label)+6, 1);
5b5ebf93ec16 Adds support for LADSPA (Linux Audio Developer's Simple Plugin API) plugins.
ivo
parents:
diff changeset
569 snprintf(setup->myname, strlen(af_info_ladspa.name)+
5b5ebf93ec16 Adds support for LADSPA (Linux Audio Developer's Simple Plugin API) plugins.
ivo
parents:
diff changeset
570 strlen(setup->file)+strlen(setup->label)+6, "%s: (%s:%s)",
5b5ebf93ec16 Adds support for LADSPA (Linux Audio Developer's Simple Plugin API) plugins.
ivo
parents:
diff changeset
571 af_info_ladspa.name, setup->file, setup->label);
5b5ebf93ec16 Adds support for LADSPA (Linux Audio Developer's Simple Plugin API) plugins.
ivo
parents:
diff changeset
572
5b5ebf93ec16 Adds support for LADSPA (Linux Audio Developer's Simple Plugin API) plugins.
ivo
parents:
diff changeset
573 /* load plugin :) */
5b5ebf93ec16 Adds support for LADSPA (Linux Audio Developer's Simple Plugin API) plugins.
ivo
parents:
diff changeset
574
5b5ebf93ec16 Adds support for LADSPA (Linux Audio Developer's Simple Plugin API) plugins.
ivo
parents:
diff changeset
575 if ( af_ladspa_load_plugin(setup) != AF_OK )
5b5ebf93ec16 Adds support for LADSPA (Linux Audio Developer's Simple Plugin API) plugins.
ivo
parents:
diff changeset
576 return AF_ERROR;
5b5ebf93ec16 Adds support for LADSPA (Linux Audio Developer's Simple Plugin API) plugins.
ivo
parents:
diff changeset
577
5b5ebf93ec16 Adds support for LADSPA (Linux Audio Developer's Simple Plugin API) plugins.
ivo
parents:
diff changeset
578 /* see what inputs, outputs and controls this plugin has */
5b5ebf93ec16 Adds support for LADSPA (Linux Audio Developer's Simple Plugin API) plugins.
ivo
parents:
diff changeset
579 if ( af_ladspa_parse_plugin(setup) != AF_OK )
5b5ebf93ec16 Adds support for LADSPA (Linux Audio Developer's Simple Plugin API) plugins.
ivo
parents:
diff changeset
580 return AF_ERROR;
5b5ebf93ec16 Adds support for LADSPA (Linux Audio Developer's Simple Plugin API) plugins.
ivo
parents:
diff changeset
581
5b5ebf93ec16 Adds support for LADSPA (Linux Audio Developer's Simple Plugin API) plugins.
ivo
parents:
diff changeset
582 /* ninputcontrols is set by now, read control values from arg */
5b5ebf93ec16 Adds support for LADSPA (Linux Audio Developer's Simple Plugin API) plugins.
ivo
parents:
diff changeset
583
5b5ebf93ec16 Adds support for LADSPA (Linux Audio Developer's Simple Plugin API) plugins.
ivo
parents:
diff changeset
584 for(i=0; i<setup->ninputcontrols; i++) {
5b5ebf93ec16 Adds support for LADSPA (Linux Audio Developer's Simple Plugin API) plugins.
ivo
parents:
diff changeset
585 if (!arg || (*(char*)arg != ':') ) {
29049
8c706ce21c6f Remove af_msg special-casing API in libaf.
bircoph
parents: 28924
diff changeset
586 mp_msg(MSGT_AFILTER, MSGL_ERR, "%s: %s\n", setup->myname,
14217
5b5ebf93ec16 Adds support for LADSPA (Linux Audio Developer's Simple Plugin API) plugins.
ivo
parents:
diff changeset
587 MSGTR_AF_LADSPA_ErrNotEnoughControls);
5b5ebf93ec16 Adds support for LADSPA (Linux Audio Developer's Simple Plugin API) plugins.
ivo
parents:
diff changeset
588 return AF_ERROR;
5b5ebf93ec16 Adds support for LADSPA (Linux Audio Developer's Simple Plugin API) plugins.
ivo
parents:
diff changeset
589 }
5b5ebf93ec16 Adds support for LADSPA (Linux Audio Developer's Simple Plugin API) plugins.
ivo
parents:
diff changeset
590 arg++;
5b5ebf93ec16 Adds support for LADSPA (Linux Audio Developer's Simple Plugin API) plugins.
ivo
parents:
diff changeset
591 r = sscanf(arg, "%f", &val);
5b5ebf93ec16 Adds support for LADSPA (Linux Audio Developer's Simple Plugin API) plugins.
ivo
parents:
diff changeset
592 if (r!=1) {
29049
8c706ce21c6f Remove af_msg special-casing API in libaf.
bircoph
parents: 28924
diff changeset
593 mp_msg(MSGT_AFILTER, MSGL_ERR, "%s: %s\n", setup->myname,
14217
5b5ebf93ec16 Adds support for LADSPA (Linux Audio Developer's Simple Plugin API) plugins.
ivo
parents:
diff changeset
594 MSGTR_AF_LADSPA_ErrNotEnoughControls);
5b5ebf93ec16 Adds support for LADSPA (Linux Audio Developer's Simple Plugin API) plugins.
ivo
parents:
diff changeset
595 return AF_ERROR;
5b5ebf93ec16 Adds support for LADSPA (Linux Audio Developer's Simple Plugin API) plugins.
ivo
parents:
diff changeset
596 }
5b5ebf93ec16 Adds support for LADSPA (Linux Audio Developer's Simple Plugin API) plugins.
ivo
parents:
diff changeset
597 setup->inputcontrols[setup->inputcontrolsmap[i]] = val;
5b5ebf93ec16 Adds support for LADSPA (Linux Audio Developer's Simple Plugin API) plugins.
ivo
parents:
diff changeset
598 arg = strchr(arg, ':');
5b5ebf93ec16 Adds support for LADSPA (Linux Audio Developer's Simple Plugin API) plugins.
ivo
parents:
diff changeset
599 }
5b5ebf93ec16 Adds support for LADSPA (Linux Audio Developer's Simple Plugin API) plugins.
ivo
parents:
diff changeset
600
29049
8c706ce21c6f Remove af_msg special-casing API in libaf.
bircoph
parents: 28924
diff changeset
601 mp_msg(MSGT_AFILTER, MSGL_V, "%s: input controls: ", setup->myname);
14217
5b5ebf93ec16 Adds support for LADSPA (Linux Audio Developer's Simple Plugin API) plugins.
ivo
parents:
diff changeset
602 for(i=0; i<setup->ninputcontrols; i++) {
29049
8c706ce21c6f Remove af_msg special-casing API in libaf.
bircoph
parents: 28924
diff changeset
603 mp_msg(MSGT_AFILTER, MSGL_V, "%0.4f ",
14217
5b5ebf93ec16 Adds support for LADSPA (Linux Audio Developer's Simple Plugin API) plugins.
ivo
parents:
diff changeset
604 setup->inputcontrols[setup->inputcontrolsmap[i]]);
5b5ebf93ec16 Adds support for LADSPA (Linux Audio Developer's Simple Plugin API) plugins.
ivo
parents:
diff changeset
605 }
29049
8c706ce21c6f Remove af_msg special-casing API in libaf.
bircoph
parents: 28924
diff changeset
606 mp_msg(MSGT_AFILTER, MSGL_V, "\n");
14217
5b5ebf93ec16 Adds support for LADSPA (Linux Audio Developer's Simple Plugin API) plugins.
ivo
parents:
diff changeset
607
5b5ebf93ec16 Adds support for LADSPA (Linux Audio Developer's Simple Plugin API) plugins.
ivo
parents:
diff changeset
608 /* check boundaries of inputcontrols */
5b5ebf93ec16 Adds support for LADSPA (Linux Audio Developer's Simple Plugin API) plugins.
ivo
parents:
diff changeset
609
29049
8c706ce21c6f Remove af_msg special-casing API in libaf.
bircoph
parents: 28924
diff changeset
610 mp_msg(MSGT_AFILTER, MSGL_V, "%s: checking boundaries of input controls\n",
14217
5b5ebf93ec16 Adds support for LADSPA (Linux Audio Developer's Simple Plugin API) plugins.
ivo
parents:
diff changeset
611 setup->myname);
5b5ebf93ec16 Adds support for LADSPA (Linux Audio Developer's Simple Plugin API) plugins.
ivo
parents:
diff changeset
612 for(i=0; i<setup->ninputcontrols; i++) {
5b5ebf93ec16 Adds support for LADSPA (Linux Audio Developer's Simple Plugin API) plugins.
ivo
parents:
diff changeset
613 int p = setup->inputcontrolsmap[i];
5b5ebf93ec16 Adds support for LADSPA (Linux Audio Developer's Simple Plugin API) plugins.
ivo
parents:
diff changeset
614 LADSPA_PortRangeHint hint =
5b5ebf93ec16 Adds support for LADSPA (Linux Audio Developer's Simple Plugin API) plugins.
ivo
parents:
diff changeset
615 setup->plugin_descriptor->PortRangeHints[p];
5b5ebf93ec16 Adds support for LADSPA (Linux Audio Developer's Simple Plugin API) plugins.
ivo
parents:
diff changeset
616 val = setup->inputcontrols[p];
5b5ebf93ec16 Adds support for LADSPA (Linux Audio Developer's Simple Plugin API) plugins.
ivo
parents:
diff changeset
617
5b5ebf93ec16 Adds support for LADSPA (Linux Audio Developer's Simple Plugin API) plugins.
ivo
parents:
diff changeset
618 if (LADSPA_IS_HINT_BOUNDED_BELOW(hint.HintDescriptor) &&
5b5ebf93ec16 Adds support for LADSPA (Linux Audio Developer's Simple Plugin API) plugins.
ivo
parents:
diff changeset
619 val < hint.LowerBound) {
29049
8c706ce21c6f Remove af_msg special-casing API in libaf.
bircoph
parents: 28924
diff changeset
620 mp_msg(MSGT_AFILTER, MSGL_ERR, MSGTR_AF_LADSPA_ErrControlBelow,
14217
5b5ebf93ec16 Adds support for LADSPA (Linux Audio Developer's Simple Plugin API) plugins.
ivo
parents:
diff changeset
621 setup->myname, i, hint.LowerBound);
5b5ebf93ec16 Adds support for LADSPA (Linux Audio Developer's Simple Plugin API) plugins.
ivo
parents:
diff changeset
622 return AF_ERROR;
5b5ebf93ec16 Adds support for LADSPA (Linux Audio Developer's Simple Plugin API) plugins.
ivo
parents:
diff changeset
623 }
5b5ebf93ec16 Adds support for LADSPA (Linux Audio Developer's Simple Plugin API) plugins.
ivo
parents:
diff changeset
624 if (LADSPA_IS_HINT_BOUNDED_ABOVE(hint.HintDescriptor) &&
5b5ebf93ec16 Adds support for LADSPA (Linux Audio Developer's Simple Plugin API) plugins.
ivo
parents:
diff changeset
625 val > hint.UpperBound) {
29049
8c706ce21c6f Remove af_msg special-casing API in libaf.
bircoph
parents: 28924
diff changeset
626 mp_msg(MSGT_AFILTER, MSGL_ERR, MSGTR_AF_LADSPA_ErrControlAbove,
14217
5b5ebf93ec16 Adds support for LADSPA (Linux Audio Developer's Simple Plugin API) plugins.
ivo
parents:
diff changeset
627 setup->myname, i, hint.UpperBound);
5b5ebf93ec16 Adds support for LADSPA (Linux Audio Developer's Simple Plugin API) plugins.
ivo
parents:
diff changeset
628 return AF_ERROR;
5b5ebf93ec16 Adds support for LADSPA (Linux Audio Developer's Simple Plugin API) plugins.
ivo
parents:
diff changeset
629 }
5b5ebf93ec16 Adds support for LADSPA (Linux Audio Developer's Simple Plugin API) plugins.
ivo
parents:
diff changeset
630 }
29049
8c706ce21c6f Remove af_msg special-casing API in libaf.
bircoph
parents: 28924
diff changeset
631 mp_msg(MSGT_AFILTER, MSGL_V, "%s: all controls have sane values\n",
14217
5b5ebf93ec16 Adds support for LADSPA (Linux Audio Developer's Simple Plugin API) plugins.
ivo
parents:
diff changeset
632 setup->myname);
5b5ebf93ec16 Adds support for LADSPA (Linux Audio Developer's Simple Plugin API) plugins.
ivo
parents:
diff changeset
633
5b5ebf93ec16 Adds support for LADSPA (Linux Audio Developer's Simple Plugin API) plugins.
ivo
parents:
diff changeset
634 /* All is well! */
5b5ebf93ec16 Adds support for LADSPA (Linux Audio Developer's Simple Plugin API) plugins.
ivo
parents:
diff changeset
635 setup->status = AF_OK;
5b5ebf93ec16 Adds support for LADSPA (Linux Audio Developer's Simple Plugin API) plugins.
ivo
parents:
diff changeset
636
5b5ebf93ec16 Adds support for LADSPA (Linux Audio Developer's Simple Plugin API) plugins.
ivo
parents:
diff changeset
637 return AF_OK; }
5b5ebf93ec16 Adds support for LADSPA (Linux Audio Developer's Simple Plugin API) plugins.
ivo
parents:
diff changeset
638 }
5b5ebf93ec16 Adds support for LADSPA (Linux Audio Developer's Simple Plugin API) plugins.
ivo
parents:
diff changeset
639
5b5ebf93ec16 Adds support for LADSPA (Linux Audio Developer's Simple Plugin API) plugins.
ivo
parents:
diff changeset
640 return AF_UNKNOWN;
5b5ebf93ec16 Adds support for LADSPA (Linux Audio Developer's Simple Plugin API) plugins.
ivo
parents:
diff changeset
641 }
5b5ebf93ec16 Adds support for LADSPA (Linux Audio Developer's Simple Plugin API) plugins.
ivo
parents:
diff changeset
642
5b5ebf93ec16 Adds support for LADSPA (Linux Audio Developer's Simple Plugin API) plugins.
ivo
parents:
diff changeset
643 /* ------------------------------------------------------------------------- */
5b5ebf93ec16 Adds support for LADSPA (Linux Audio Developer's Simple Plugin API) plugins.
ivo
parents:
diff changeset
644
5b5ebf93ec16 Adds support for LADSPA (Linux Audio Developer's Simple Plugin API) plugins.
ivo
parents:
diff changeset
645 /** \brief Uninitialise the LADSPA Plugin Loader filter.
5b5ebf93ec16 Adds support for LADSPA (Linux Audio Developer's Simple Plugin API) plugins.
ivo
parents:
diff changeset
646 *
5b5ebf93ec16 Adds support for LADSPA (Linux Audio Developer's Simple Plugin API) plugins.
ivo
parents:
diff changeset
647 * This function deactivates the plugin(s), cleans up, frees all allocated
5b5ebf93ec16 Adds support for LADSPA (Linux Audio Developer's Simple Plugin API) plugins.
ivo
parents:
diff changeset
648 * memory and exits.
5b5ebf93ec16 Adds support for LADSPA (Linux Audio Developer's Simple Plugin API) plugins.
ivo
parents:
diff changeset
649 *
5b5ebf93ec16 Adds support for LADSPA (Linux Audio Developer's Simple Plugin API) plugins.
ivo
parents:
diff changeset
650 * \return No return value.
5b5ebf93ec16 Adds support for LADSPA (Linux Audio Developer's Simple Plugin API) plugins.
ivo
parents:
diff changeset
651 */
5b5ebf93ec16 Adds support for LADSPA (Linux Audio Developer's Simple Plugin API) plugins.
ivo
parents:
diff changeset
652
5b5ebf93ec16 Adds support for LADSPA (Linux Audio Developer's Simple Plugin API) plugins.
ivo
parents:
diff changeset
653 static void uninit(struct af_instance_s *af) {
5b5ebf93ec16 Adds support for LADSPA (Linux Audio Developer's Simple Plugin API) plugins.
ivo
parents:
diff changeset
654 int i;
5b5ebf93ec16 Adds support for LADSPA (Linux Audio Developer's Simple Plugin API) plugins.
ivo
parents:
diff changeset
655
32537
8fa2f43cb760 Remove most of the NULL pointer check before free all over the code
cboesch
parents: 31492
diff changeset
656 free(af->data);
14217
5b5ebf93ec16 Adds support for LADSPA (Linux Audio Developer's Simple Plugin API) plugins.
ivo
parents:
diff changeset
657 if (af->setup) {
5b5ebf93ec16 Adds support for LADSPA (Linux Audio Developer's Simple Plugin API) plugins.
ivo
parents:
diff changeset
658 af_ladspa_t *setup = (af_ladspa_t*) af->setup;
5b5ebf93ec16 Adds support for LADSPA (Linux Audio Developer's Simple Plugin API) plugins.
ivo
parents:
diff changeset
659 const LADSPA_Descriptor *pdes = setup->plugin_descriptor;
5b5ebf93ec16 Adds support for LADSPA (Linux Audio Developer's Simple Plugin API) plugins.
ivo
parents:
diff changeset
660
5b5ebf93ec16 Adds support for LADSPA (Linux Audio Developer's Simple Plugin API) plugins.
ivo
parents:
diff changeset
661 if (setup->myname) {
29049
8c706ce21c6f Remove af_msg special-casing API in libaf.
bircoph
parents: 28924
diff changeset
662 mp_msg(MSGT_AFILTER, MSGL_V, "%s: cleaning up\n", setup->myname);
14217
5b5ebf93ec16 Adds support for LADSPA (Linux Audio Developer's Simple Plugin API) plugins.
ivo
parents:
diff changeset
663 free(setup->myname);
5b5ebf93ec16 Adds support for LADSPA (Linux Audio Developer's Simple Plugin API) plugins.
ivo
parents:
diff changeset
664 }
5b5ebf93ec16 Adds support for LADSPA (Linux Audio Developer's Simple Plugin API) plugins.
ivo
parents:
diff changeset
665
5b5ebf93ec16 Adds support for LADSPA (Linux Audio Developer's Simple Plugin API) plugins.
ivo
parents:
diff changeset
666 if (setup->chhandles) {
22127
c6c141ab4fcf Experimental support for multichannel ladspa effects
reimar
parents: 19614
diff changeset
667 for(i=0; i<setup->nch; i+=setup->ninputs) {
14217
5b5ebf93ec16 Adds support for LADSPA (Linux Audio Developer's Simple Plugin API) plugins.
ivo
parents:
diff changeset
668 if (pdes->deactivate) pdes->deactivate(setup->chhandles[i]);
5b5ebf93ec16 Adds support for LADSPA (Linux Audio Developer's Simple Plugin API) plugins.
ivo
parents:
diff changeset
669 if (pdes->cleanup) pdes->cleanup(setup->chhandles[i]);
5b5ebf93ec16 Adds support for LADSPA (Linux Audio Developer's Simple Plugin API) plugins.
ivo
parents:
diff changeset
670 }
5b5ebf93ec16 Adds support for LADSPA (Linux Audio Developer's Simple Plugin API) plugins.
ivo
parents:
diff changeset
671 free(setup->chhandles);
5b5ebf93ec16 Adds support for LADSPA (Linux Audio Developer's Simple Plugin API) plugins.
ivo
parents:
diff changeset
672 }
5b5ebf93ec16 Adds support for LADSPA (Linux Audio Developer's Simple Plugin API) plugins.
ivo
parents:
diff changeset
673
32537
8fa2f43cb760 Remove most of the NULL pointer check before free all over the code
cboesch
parents: 31492
diff changeset
674 free(setup->file);
8fa2f43cb760 Remove most of the NULL pointer check before free all over the code
cboesch
parents: 31492
diff changeset
675 free(setup->label);
8fa2f43cb760 Remove most of the NULL pointer check before free all over the code
cboesch
parents: 31492
diff changeset
676 free(setup->inputcontrolsmap);
8fa2f43cb760 Remove most of the NULL pointer check before free all over the code
cboesch
parents: 31492
diff changeset
677 free(setup->inputcontrols);
8fa2f43cb760 Remove most of the NULL pointer check before free all over the code
cboesch
parents: 31492
diff changeset
678 free(setup->outputcontrolsmap);
8fa2f43cb760 Remove most of the NULL pointer check before free all over the code
cboesch
parents: 31492
diff changeset
679 free(setup->outputcontrols);
8fa2f43cb760 Remove most of the NULL pointer check before free all over the code
cboesch
parents: 31492
diff changeset
680 free(setup->inputs);
8fa2f43cb760 Remove most of the NULL pointer check before free all over the code
cboesch
parents: 31492
diff changeset
681 free(setup->outputs);
14217
5b5ebf93ec16 Adds support for LADSPA (Linux Audio Developer's Simple Plugin API) plugins.
ivo
parents:
diff changeset
682
5b5ebf93ec16 Adds support for LADSPA (Linux Audio Developer's Simple Plugin API) plugins.
ivo
parents:
diff changeset
683 if (setup->inbufs) {
32537
8fa2f43cb760 Remove most of the NULL pointer check before free all over the code
cboesch
parents: 31492
diff changeset
684 for(i=0; i<setup->nch; i++)
8fa2f43cb760 Remove most of the NULL pointer check before free all over the code
cboesch
parents: 31492
diff changeset
685 free(setup->inbufs[i]);
14217
5b5ebf93ec16 Adds support for LADSPA (Linux Audio Developer's Simple Plugin API) plugins.
ivo
parents:
diff changeset
686 free(setup->inbufs);
5b5ebf93ec16 Adds support for LADSPA (Linux Audio Developer's Simple Plugin API) plugins.
ivo
parents:
diff changeset
687 }
5b5ebf93ec16 Adds support for LADSPA (Linux Audio Developer's Simple Plugin API) plugins.
ivo
parents:
diff changeset
688
5b5ebf93ec16 Adds support for LADSPA (Linux Audio Developer's Simple Plugin API) plugins.
ivo
parents:
diff changeset
689 if (setup->outbufs) {
32537
8fa2f43cb760 Remove most of the NULL pointer check before free all over the code
cboesch
parents: 31492
diff changeset
690 for(i=0; i<setup->nch; i++)
8fa2f43cb760 Remove most of the NULL pointer check before free all over the code
cboesch
parents: 31492
diff changeset
691 free(setup->outbufs[i]);
14217
5b5ebf93ec16 Adds support for LADSPA (Linux Audio Developer's Simple Plugin API) plugins.
ivo
parents:
diff changeset
692 free(setup->outbufs);
5b5ebf93ec16 Adds support for LADSPA (Linux Audio Developer's Simple Plugin API) plugins.
ivo
parents:
diff changeset
693 }
5b5ebf93ec16 Adds support for LADSPA (Linux Audio Developer's Simple Plugin API) plugins.
ivo
parents:
diff changeset
694
5b5ebf93ec16 Adds support for LADSPA (Linux Audio Developer's Simple Plugin API) plugins.
ivo
parents:
diff changeset
695 if (setup->libhandle)
5b5ebf93ec16 Adds support for LADSPA (Linux Audio Developer's Simple Plugin API) plugins.
ivo
parents:
diff changeset
696 dlclose(setup->libhandle);
5b5ebf93ec16 Adds support for LADSPA (Linux Audio Developer's Simple Plugin API) plugins.
ivo
parents:
diff changeset
697
5b5ebf93ec16 Adds support for LADSPA (Linux Audio Developer's Simple Plugin API) plugins.
ivo
parents:
diff changeset
698 free(setup);
5b5ebf93ec16 Adds support for LADSPA (Linux Audio Developer's Simple Plugin API) plugins.
ivo
parents:
diff changeset
699 setup = NULL;
5b5ebf93ec16 Adds support for LADSPA (Linux Audio Developer's Simple Plugin API) plugins.
ivo
parents:
diff changeset
700 }
5b5ebf93ec16 Adds support for LADSPA (Linux Audio Developer's Simple Plugin API) plugins.
ivo
parents:
diff changeset
701 }
5b5ebf93ec16 Adds support for LADSPA (Linux Audio Developer's Simple Plugin API) plugins.
ivo
parents:
diff changeset
702
5b5ebf93ec16 Adds support for LADSPA (Linux Audio Developer's Simple Plugin API) plugins.
ivo
parents:
diff changeset
703 /* ------------------------------------------------------------------------- */
5b5ebf93ec16 Adds support for LADSPA (Linux Audio Developer's Simple Plugin API) plugins.
ivo
parents:
diff changeset
704
5b5ebf93ec16 Adds support for LADSPA (Linux Audio Developer's Simple Plugin API) plugins.
ivo
parents:
diff changeset
705 /** \brief Process chunk of audio data through the selected LADSPA Plugin.
29263
0f1b5b68af32 whitespace cosmetics: Remove all trailing whitespace.
diego
parents: 29049
diff changeset
706 *
14217
5b5ebf93ec16 Adds support for LADSPA (Linux Audio Developer's Simple Plugin API) plugins.
ivo
parents:
diff changeset
707 * \param af Pointer to audio filter instance
5b5ebf93ec16 Adds support for LADSPA (Linux Audio Developer's Simple Plugin API) plugins.
ivo
parents:
diff changeset
708 * \param data Pointer to chunk of audio data
5b5ebf93ec16 Adds support for LADSPA (Linux Audio Developer's Simple Plugin API) plugins.
ivo
parents:
diff changeset
709 *
5b5ebf93ec16 Adds support for LADSPA (Linux Audio Developer's Simple Plugin API) plugins.
ivo
parents:
diff changeset
710 * \return Either AF_ERROR or AF_OK
5b5ebf93ec16 Adds support for LADSPA (Linux Audio Developer's Simple Plugin API) plugins.
ivo
parents:
diff changeset
711 */
5b5ebf93ec16 Adds support for LADSPA (Linux Audio Developer's Simple Plugin API) plugins.
ivo
parents:
diff changeset
712
5b5ebf93ec16 Adds support for LADSPA (Linux Audio Developer's Simple Plugin API) plugins.
ivo
parents:
diff changeset
713 static af_data_t* play(struct af_instance_s *af, af_data_t *data) {
5b5ebf93ec16 Adds support for LADSPA (Linux Audio Developer's Simple Plugin API) plugins.
ivo
parents:
diff changeset
714 af_ladspa_t *setup = af->setup;
5b5ebf93ec16 Adds support for LADSPA (Linux Audio Developer's Simple Plugin API) plugins.
ivo
parents:
diff changeset
715 const LADSPA_Descriptor *pdes = setup->plugin_descriptor;
16195
cb08f47d3a79 Removed in-filter int to float conversion. af_ladspa now demands floats as
ivo
parents: 15790
diff changeset
716 float *audio = (float*)data->audio;
cb08f47d3a79 Removed in-filter int to float conversion. af_ladspa now demands floats as
ivo
parents: 15790
diff changeset
717 int nsamples = data->len/4; /* /4 because it's 32-bit float */
14217
5b5ebf93ec16 Adds support for LADSPA (Linux Audio Developer's Simple Plugin API) plugins.
ivo
parents:
diff changeset
718 int nch = data->nch;
5b5ebf93ec16 Adds support for LADSPA (Linux Audio Developer's Simple Plugin API) plugins.
ivo
parents:
diff changeset
719 int rate = data->rate;
29263
0f1b5b68af32 whitespace cosmetics: Remove all trailing whitespace.
diego
parents: 29049
diff changeset
720 int i, p;
14217
5b5ebf93ec16 Adds support for LADSPA (Linux Audio Developer's Simple Plugin API) plugins.
ivo
parents:
diff changeset
721
5b5ebf93ec16 Adds support for LADSPA (Linux Audio Developer's Simple Plugin API) plugins.
ivo
parents:
diff changeset
722 if (setup->status !=AF_OK)
5b5ebf93ec16 Adds support for LADSPA (Linux Audio Developer's Simple Plugin API) plugins.
ivo
parents:
diff changeset
723 return data;
5b5ebf93ec16 Adds support for LADSPA (Linux Audio Developer's Simple Plugin API) plugins.
ivo
parents:
diff changeset
724
5b5ebf93ec16 Adds support for LADSPA (Linux Audio Developer's Simple Plugin API) plugins.
ivo
parents:
diff changeset
725 /* See if it's the first call. If so, setup inbufs/outbufs, instantiate
5b5ebf93ec16 Adds support for LADSPA (Linux Audio Developer's Simple Plugin API) plugins.
ivo
parents:
diff changeset
726 * plugin, connect ports and activate plugin
5b5ebf93ec16 Adds support for LADSPA (Linux Audio Developer's Simple Plugin API) plugins.
ivo
parents:
diff changeset
727 */
5b5ebf93ec16 Adds support for LADSPA (Linux Audio Developer's Simple Plugin API) plugins.
ivo
parents:
diff changeset
728
5b5ebf93ec16 Adds support for LADSPA (Linux Audio Developer's Simple Plugin API) plugins.
ivo
parents:
diff changeset
729 /* 2004-12-07: Also check if the buffersize has to be changed!
5b5ebf93ec16 Adds support for LADSPA (Linux Audio Developer's Simple Plugin API) plugins.
ivo
parents:
diff changeset
730 * data->len is not constant per se! re-init buffers.
5b5ebf93ec16 Adds support for LADSPA (Linux Audio Developer's Simple Plugin API) plugins.
ivo
parents:
diff changeset
731 */
5b5ebf93ec16 Adds support for LADSPA (Linux Audio Developer's Simple Plugin API) plugins.
ivo
parents:
diff changeset
732
5b5ebf93ec16 Adds support for LADSPA (Linux Audio Developer's Simple Plugin API) plugins.
ivo
parents:
diff changeset
733 if ( (setup->bufsize != nsamples/nch) || (setup->nch != nch) ) {
5b5ebf93ec16 Adds support for LADSPA (Linux Audio Developer's Simple Plugin API) plugins.
ivo
parents:
diff changeset
734
5b5ebf93ec16 Adds support for LADSPA (Linux Audio Developer's Simple Plugin API) plugins.
ivo
parents:
diff changeset
735 /* if setup->nch==0, it's the first call, if not, something has
5b5ebf93ec16 Adds support for LADSPA (Linux Audio Developer's Simple Plugin API) plugins.
ivo
parents:
diff changeset
736 * changed and all previous mallocs have to be freed
5b5ebf93ec16 Adds support for LADSPA (Linux Audio Developer's Simple Plugin API) plugins.
ivo
parents:
diff changeset
737 */
5b5ebf93ec16 Adds support for LADSPA (Linux Audio Developer's Simple Plugin API) plugins.
ivo
parents:
diff changeset
738
5b5ebf93ec16 Adds support for LADSPA (Linux Audio Developer's Simple Plugin API) plugins.
ivo
parents:
diff changeset
739 if (setup->nch != 0) {
29049
8c706ce21c6f Remove af_msg special-casing API in libaf.
bircoph
parents: 28924
diff changeset
740 mp_msg(MSGT_AFILTER, MSGL_DBG3, "%s: bufsize change; free old buffer\n",
14217
5b5ebf93ec16 Adds support for LADSPA (Linux Audio Developer's Simple Plugin API) plugins.
ivo
parents:
diff changeset
741 setup->myname);
5b5ebf93ec16 Adds support for LADSPA (Linux Audio Developer's Simple Plugin API) plugins.
ivo
parents:
diff changeset
742
5b5ebf93ec16 Adds support for LADSPA (Linux Audio Developer's Simple Plugin API) plugins.
ivo
parents:
diff changeset
743 if(setup->inbufs) {
32537
8fa2f43cb760 Remove most of the NULL pointer check before free all over the code
cboesch
parents: 31492
diff changeset
744 for(i=0; i<setup->nch; i++)
8fa2f43cb760 Remove most of the NULL pointer check before free all over the code
cboesch
parents: 31492
diff changeset
745 free(setup->inbufs[i]);
14217
5b5ebf93ec16 Adds support for LADSPA (Linux Audio Developer's Simple Plugin API) plugins.
ivo
parents:
diff changeset
746 free(setup->inbufs);
5b5ebf93ec16 Adds support for LADSPA (Linux Audio Developer's Simple Plugin API) plugins.
ivo
parents:
diff changeset
747 }
5b5ebf93ec16 Adds support for LADSPA (Linux Audio Developer's Simple Plugin API) plugins.
ivo
parents:
diff changeset
748 if(setup->outbufs) {
32537
8fa2f43cb760 Remove most of the NULL pointer check before free all over the code
cboesch
parents: 31492
diff changeset
749 for(i=0; i<setup->nch; i++)
8fa2f43cb760 Remove most of the NULL pointer check before free all over the code
cboesch
parents: 31492
diff changeset
750 free(setup->outbufs[i]);
14217
5b5ebf93ec16 Adds support for LADSPA (Linux Audio Developer's Simple Plugin API) plugins.
ivo
parents:
diff changeset
751 free(setup->outbufs);
5b5ebf93ec16 Adds support for LADSPA (Linux Audio Developer's Simple Plugin API) plugins.
ivo
parents:
diff changeset
752 }
5b5ebf93ec16 Adds support for LADSPA (Linux Audio Developer's Simple Plugin API) plugins.
ivo
parents:
diff changeset
753 } /* everything is freed */
5b5ebf93ec16 Adds support for LADSPA (Linux Audio Developer's Simple Plugin API) plugins.
ivo
parents:
diff changeset
754
5b5ebf93ec16 Adds support for LADSPA (Linux Audio Developer's Simple Plugin API) plugins.
ivo
parents:
diff changeset
755 setup->bufsize = nsamples/nch;
5b5ebf93ec16 Adds support for LADSPA (Linux Audio Developer's Simple Plugin API) plugins.
ivo
parents:
diff changeset
756 setup->nch = nch;
5b5ebf93ec16 Adds support for LADSPA (Linux Audio Developer's Simple Plugin API) plugins.
ivo
parents:
diff changeset
757
5b5ebf93ec16 Adds support for LADSPA (Linux Audio Developer's Simple Plugin API) plugins.
ivo
parents:
diff changeset
758 setup->inbufs = calloc(nch, sizeof(float*));
5b5ebf93ec16 Adds support for LADSPA (Linux Audio Developer's Simple Plugin API) plugins.
ivo
parents:
diff changeset
759 setup->outbufs = calloc(nch, sizeof(float*));
5b5ebf93ec16 Adds support for LADSPA (Linux Audio Developer's Simple Plugin API) plugins.
ivo
parents:
diff changeset
760
29049
8c706ce21c6f Remove af_msg special-casing API in libaf.
bircoph
parents: 28924
diff changeset
761 mp_msg(MSGT_AFILTER, MSGL_DBG3, "%s: bufsize = %d\n",
14217
5b5ebf93ec16 Adds support for LADSPA (Linux Audio Developer's Simple Plugin API) plugins.
ivo
parents:
diff changeset
762 setup->myname, setup->bufsize);
5b5ebf93ec16 Adds support for LADSPA (Linux Audio Developer's Simple Plugin API) plugins.
ivo
parents:
diff changeset
763
5b5ebf93ec16 Adds support for LADSPA (Linux Audio Developer's Simple Plugin API) plugins.
ivo
parents:
diff changeset
764 for(i=0; i<nch; i++) {
5b5ebf93ec16 Adds support for LADSPA (Linux Audio Developer's Simple Plugin API) plugins.
ivo
parents:
diff changeset
765 setup->inbufs[i] = calloc(setup->bufsize, sizeof(float));
5b5ebf93ec16 Adds support for LADSPA (Linux Audio Developer's Simple Plugin API) plugins.
ivo
parents:
diff changeset
766 setup->outbufs[i] = calloc(setup->bufsize, sizeof(float));
5b5ebf93ec16 Adds support for LADSPA (Linux Audio Developer's Simple Plugin API) plugins.
ivo
parents:
diff changeset
767 }
5b5ebf93ec16 Adds support for LADSPA (Linux Audio Developer's Simple Plugin API) plugins.
ivo
parents:
diff changeset
768
5b5ebf93ec16 Adds support for LADSPA (Linux Audio Developer's Simple Plugin API) plugins.
ivo
parents:
diff changeset
769 /* only on the first call, there are no handles. */
5b5ebf93ec16 Adds support for LADSPA (Linux Audio Developer's Simple Plugin API) plugins.
ivo
parents:
diff changeset
770
5b5ebf93ec16 Adds support for LADSPA (Linux Audio Developer's Simple Plugin API) plugins.
ivo
parents:
diff changeset
771 if (!setup->chhandles) {
5b5ebf93ec16 Adds support for LADSPA (Linux Audio Developer's Simple Plugin API) plugins.
ivo
parents:
diff changeset
772 setup->chhandles = calloc(nch, sizeof(LADSPA_Handle));
5b5ebf93ec16 Adds support for LADSPA (Linux Audio Developer's Simple Plugin API) plugins.
ivo
parents:
diff changeset
773
5b5ebf93ec16 Adds support for LADSPA (Linux Audio Developer's Simple Plugin API) plugins.
ivo
parents:
diff changeset
774 /* create handles
5b5ebf93ec16 Adds support for LADSPA (Linux Audio Developer's Simple Plugin API) plugins.
ivo
parents:
diff changeset
775 * for stereo effects, create one handle for two channels
5b5ebf93ec16 Adds support for LADSPA (Linux Audio Developer's Simple Plugin API) plugins.
ivo
parents:
diff changeset
776 */
5b5ebf93ec16 Adds support for LADSPA (Linux Audio Developer's Simple Plugin API) plugins.
ivo
parents:
diff changeset
777
5b5ebf93ec16 Adds support for LADSPA (Linux Audio Developer's Simple Plugin API) plugins.
ivo
parents:
diff changeset
778 for(i=0; i<nch; i++) {
5b5ebf93ec16 Adds support for LADSPA (Linux Audio Developer's Simple Plugin API) plugins.
ivo
parents:
diff changeset
779
22127
c6c141ab4fcf Experimental support for multichannel ladspa effects
reimar
parents: 19614
diff changeset
780 if (i % setup->ninputs) { /* stereo effect */
14217
5b5ebf93ec16 Adds support for LADSPA (Linux Audio Developer's Simple Plugin API) plugins.
ivo
parents:
diff changeset
781 /* copy the handle from previous channel */
5b5ebf93ec16 Adds support for LADSPA (Linux Audio Developer's Simple Plugin API) plugins.
ivo
parents:
diff changeset
782 setup->chhandles[i] = setup->chhandles[i-1];
5b5ebf93ec16 Adds support for LADSPA (Linux Audio Developer's Simple Plugin API) plugins.
ivo
parents:
diff changeset
783 continue;
5b5ebf93ec16 Adds support for LADSPA (Linux Audio Developer's Simple Plugin API) plugins.
ivo
parents:
diff changeset
784 }
5b5ebf93ec16 Adds support for LADSPA (Linux Audio Developer's Simple Plugin API) plugins.
ivo
parents:
diff changeset
785
5b5ebf93ec16 Adds support for LADSPA (Linux Audio Developer's Simple Plugin API) plugins.
ivo
parents:
diff changeset
786 setup->chhandles[i] = pdes->instantiate(pdes, rate);
5b5ebf93ec16 Adds support for LADSPA (Linux Audio Developer's Simple Plugin API) plugins.
ivo
parents:
diff changeset
787 }
5b5ebf93ec16 Adds support for LADSPA (Linux Audio Developer's Simple Plugin API) plugins.
ivo
parents:
diff changeset
788 }
5b5ebf93ec16 Adds support for LADSPA (Linux Audio Developer's Simple Plugin API) plugins.
ivo
parents:
diff changeset
789
5b5ebf93ec16 Adds support for LADSPA (Linux Audio Developer's Simple Plugin API) plugins.
ivo
parents:
diff changeset
790 /* connect input/output ports for each channel/filter instance
5b5ebf93ec16 Adds support for LADSPA (Linux Audio Developer's Simple Plugin API) plugins.
ivo
parents:
diff changeset
791 *
5b5ebf93ec16 Adds support for LADSPA (Linux Audio Developer's Simple Plugin API) plugins.
ivo
parents:
diff changeset
792 * always (re)connect ports
5b5ebf93ec16 Adds support for LADSPA (Linux Audio Developer's Simple Plugin API) plugins.
ivo
parents:
diff changeset
793 */
5b5ebf93ec16 Adds support for LADSPA (Linux Audio Developer's Simple Plugin API) plugins.
ivo
parents:
diff changeset
794
5b5ebf93ec16 Adds support for LADSPA (Linux Audio Developer's Simple Plugin API) plugins.
ivo
parents:
diff changeset
795 for(i=0; i<nch; i++) {
5b5ebf93ec16 Adds support for LADSPA (Linux Audio Developer's Simple Plugin API) plugins.
ivo
parents:
diff changeset
796 pdes->connect_port(setup->chhandles[i],
22127
c6c141ab4fcf Experimental support for multichannel ladspa effects
reimar
parents: 19614
diff changeset
797 setup->inputs[i % setup->ninputs],
14217
5b5ebf93ec16 Adds support for LADSPA (Linux Audio Developer's Simple Plugin API) plugins.
ivo
parents:
diff changeset
798 setup->inbufs[i]);
5b5ebf93ec16 Adds support for LADSPA (Linux Audio Developer's Simple Plugin API) plugins.
ivo
parents:
diff changeset
799 pdes->connect_port(setup->chhandles[i],
22127
c6c141ab4fcf Experimental support for multichannel ladspa effects
reimar
parents: 19614
diff changeset
800 setup->outputs[i % setup->ninputs],
14217
5b5ebf93ec16 Adds support for LADSPA (Linux Audio Developer's Simple Plugin API) plugins.
ivo
parents:
diff changeset
801 setup->outbufs[i]);
5b5ebf93ec16 Adds support for LADSPA (Linux Audio Developer's Simple Plugin API) plugins.
ivo
parents:
diff changeset
802
5b5ebf93ec16 Adds support for LADSPA (Linux Audio Developer's Simple Plugin API) plugins.
ivo
parents:
diff changeset
803 /* connect (input) controls */
5b5ebf93ec16 Adds support for LADSPA (Linux Audio Developer's Simple Plugin API) plugins.
ivo
parents:
diff changeset
804
5b5ebf93ec16 Adds support for LADSPA (Linux Audio Developer's Simple Plugin API) plugins.
ivo
parents:
diff changeset
805 for (p=0; p<setup->nports; p++) {
5b5ebf93ec16 Adds support for LADSPA (Linux Audio Developer's Simple Plugin API) plugins.
ivo
parents:
diff changeset
806 LADSPA_PortDescriptor d = pdes->PortDescriptors[p];
5b5ebf93ec16 Adds support for LADSPA (Linux Audio Developer's Simple Plugin API) plugins.
ivo
parents:
diff changeset
807 if (LADSPA_IS_PORT_CONTROL(d)) {
5b5ebf93ec16 Adds support for LADSPA (Linux Audio Developer's Simple Plugin API) plugins.
ivo
parents:
diff changeset
808 if (LADSPA_IS_PORT_INPUT(d)) {
5b5ebf93ec16 Adds support for LADSPA (Linux Audio Developer's Simple Plugin API) plugins.
ivo
parents:
diff changeset
809 pdes->connect_port(setup->chhandles[i], p,
5b5ebf93ec16 Adds support for LADSPA (Linux Audio Developer's Simple Plugin API) plugins.
ivo
parents:
diff changeset
810 &(setup->inputcontrols[p]) );
5b5ebf93ec16 Adds support for LADSPA (Linux Audio Developer's Simple Plugin API) plugins.
ivo
parents:
diff changeset
811 } else {
5b5ebf93ec16 Adds support for LADSPA (Linux Audio Developer's Simple Plugin API) plugins.
ivo
parents:
diff changeset
812 pdes->connect_port(setup->chhandles[i], p,
5b5ebf93ec16 Adds support for LADSPA (Linux Audio Developer's Simple Plugin API) plugins.
ivo
parents:
diff changeset
813 &(setup->outputcontrols[p]) );
5b5ebf93ec16 Adds support for LADSPA (Linux Audio Developer's Simple Plugin API) plugins.
ivo
parents:
diff changeset
814 }
5b5ebf93ec16 Adds support for LADSPA (Linux Audio Developer's Simple Plugin API) plugins.
ivo
parents:
diff changeset
815 }
5b5ebf93ec16 Adds support for LADSPA (Linux Audio Developer's Simple Plugin API) plugins.
ivo
parents:
diff changeset
816 }
5b5ebf93ec16 Adds support for LADSPA (Linux Audio Developer's Simple Plugin API) plugins.
ivo
parents:
diff changeset
817
5b5ebf93ec16 Adds support for LADSPA (Linux Audio Developer's Simple Plugin API) plugins.
ivo
parents:
diff changeset
818 /* Activate filter (if it isn't already :) ) */
5b5ebf93ec16 Adds support for LADSPA (Linux Audio Developer's Simple Plugin API) plugins.
ivo
parents:
diff changeset
819
31492
e4d6cf87aa06 ladspa: ensure that activate is called on each filter instance, even
reimar
parents: 29263
diff changeset
820 if (pdes->activate && !setup->activated && i % setup->ninputs == 0)
14217
5b5ebf93ec16 Adds support for LADSPA (Linux Audio Developer's Simple Plugin API) plugins.
ivo
parents:
diff changeset
821 pdes->activate(setup->chhandles[i]);
5b5ebf93ec16 Adds support for LADSPA (Linux Audio Developer's Simple Plugin API) plugins.
ivo
parents:
diff changeset
822
5b5ebf93ec16 Adds support for LADSPA (Linux Audio Developer's Simple Plugin API) plugins.
ivo
parents:
diff changeset
823 } /* All channels/filters done! except for... */
31492
e4d6cf87aa06 ladspa: ensure that activate is called on each filter instance, even
reimar
parents: 29263
diff changeset
824 setup->activated = 1;
14217
5b5ebf93ec16 Adds support for LADSPA (Linux Audio Developer's Simple Plugin API) plugins.
ivo
parents:
diff changeset
825
5b5ebf93ec16 Adds support for LADSPA (Linux Audio Developer's Simple Plugin API) plugins.
ivo
parents:
diff changeset
826 /* Stereo effect with one channel left. Use same buffer for left
5b5ebf93ec16 Adds support for LADSPA (Linux Audio Developer's Simple Plugin API) plugins.
ivo
parents:
diff changeset
827 * and right. connect it to the second port.
5b5ebf93ec16 Adds support for LADSPA (Linux Audio Developer's Simple Plugin API) plugins.
ivo
parents:
diff changeset
828 */
5b5ebf93ec16 Adds support for LADSPA (Linux Audio Developer's Simple Plugin API) plugins.
ivo
parents:
diff changeset
829
29263
0f1b5b68af32 whitespace cosmetics: Remove all trailing whitespace.
diego
parents: 29049
diff changeset
830 for (p = i; p % setup->ninputs; p++) {
14217
5b5ebf93ec16 Adds support for LADSPA (Linux Audio Developer's Simple Plugin API) plugins.
ivo
parents:
diff changeset
831 pdes->connect_port(setup->chhandles[i-1],
22127
c6c141ab4fcf Experimental support for multichannel ladspa effects
reimar
parents: 19614
diff changeset
832 setup->inputs[p % setup->ninputs],
14217
5b5ebf93ec16 Adds support for LADSPA (Linux Audio Developer's Simple Plugin API) plugins.
ivo
parents:
diff changeset
833 setup->inbufs[i-1]);
5b5ebf93ec16 Adds support for LADSPA (Linux Audio Developer's Simple Plugin API) plugins.
ivo
parents:
diff changeset
834 pdes->connect_port(setup->chhandles[i-1],
22127
c6c141ab4fcf Experimental support for multichannel ladspa effects
reimar
parents: 19614
diff changeset
835 setup->outputs[p % setup->ninputs],
14217
5b5ebf93ec16 Adds support for LADSPA (Linux Audio Developer's Simple Plugin API) plugins.
ivo
parents:
diff changeset
836 setup->outbufs[i-1]);
5b5ebf93ec16 Adds support for LADSPA (Linux Audio Developer's Simple Plugin API) plugins.
ivo
parents:
diff changeset
837 } /* done! */
5b5ebf93ec16 Adds support for LADSPA (Linux Audio Developer's Simple Plugin API) plugins.
ivo
parents:
diff changeset
838
5b5ebf93ec16 Adds support for LADSPA (Linux Audio Developer's Simple Plugin API) plugins.
ivo
parents:
diff changeset
839 } /* setup for first call/change of bufsize is done.
5b5ebf93ec16 Adds support for LADSPA (Linux Audio Developer's Simple Plugin API) plugins.
ivo
parents:
diff changeset
840 * normal playing routine follows...
5b5ebf93ec16 Adds support for LADSPA (Linux Audio Developer's Simple Plugin API) plugins.
ivo
parents:
diff changeset
841 */
5b5ebf93ec16 Adds support for LADSPA (Linux Audio Developer's Simple Plugin API) plugins.
ivo
parents:
diff changeset
842
5b5ebf93ec16 Adds support for LADSPA (Linux Audio Developer's Simple Plugin API) plugins.
ivo
parents:
diff changeset
843 /* Right now, I use a separate input and output buffer.
5b5ebf93ec16 Adds support for LADSPA (Linux Audio Developer's Simple Plugin API) plugins.
ivo
parents:
diff changeset
844 * I could change this to in-place processing (inbuf==outbuf), but some
5b5ebf93ec16 Adds support for LADSPA (Linux Audio Developer's Simple Plugin API) plugins.
ivo
parents:
diff changeset
845 * ladspa filters are broken and are not able to handle that. This seems
5b5ebf93ec16 Adds support for LADSPA (Linux Audio Developer's Simple Plugin API) plugins.
ivo
parents:
diff changeset
846 * fast enough, so unless somebody complains, it stays this way :)
5b5ebf93ec16 Adds support for LADSPA (Linux Audio Developer's Simple Plugin API) plugins.
ivo
parents:
diff changeset
847 */
5b5ebf93ec16 Adds support for LADSPA (Linux Audio Developer's Simple Plugin API) plugins.
ivo
parents:
diff changeset
848
5b5ebf93ec16 Adds support for LADSPA (Linux Audio Developer's Simple Plugin API) plugins.
ivo
parents:
diff changeset
849 /* Fill inbufs */
5b5ebf93ec16 Adds support for LADSPA (Linux Audio Developer's Simple Plugin API) plugins.
ivo
parents:
diff changeset
850
5b5ebf93ec16 Adds support for LADSPA (Linux Audio Developer's Simple Plugin API) plugins.
ivo
parents:
diff changeset
851 for (p=0; p<setup->bufsize; p++) {
5b5ebf93ec16 Adds support for LADSPA (Linux Audio Developer's Simple Plugin API) plugins.
ivo
parents:
diff changeset
852 for (i=0; i<nch; i++) {
16195
cb08f47d3a79 Removed in-filter int to float conversion. af_ladspa now demands floats as
ivo
parents: 15790
diff changeset
853 setup->inbufs[i][p] = audio[p*nch + i];
14217
5b5ebf93ec16 Adds support for LADSPA (Linux Audio Developer's Simple Plugin API) plugins.
ivo
parents:
diff changeset
854 }
5b5ebf93ec16 Adds support for LADSPA (Linux Audio Developer's Simple Plugin API) plugins.
ivo
parents:
diff changeset
855 }
5b5ebf93ec16 Adds support for LADSPA (Linux Audio Developer's Simple Plugin API) plugins.
ivo
parents:
diff changeset
856
5b5ebf93ec16 Adds support for LADSPA (Linux Audio Developer's Simple Plugin API) plugins.
ivo
parents:
diff changeset
857 /* Run filter(s) */
5b5ebf93ec16 Adds support for LADSPA (Linux Audio Developer's Simple Plugin API) plugins.
ivo
parents:
diff changeset
858
22127
c6c141ab4fcf Experimental support for multichannel ladspa effects
reimar
parents: 19614
diff changeset
859 for (i=0; i<nch; i+=setup->ninputs) {
14217
5b5ebf93ec16 Adds support for LADSPA (Linux Audio Developer's Simple Plugin API) plugins.
ivo
parents:
diff changeset
860 pdes->run(setup->chhandles[i], setup->bufsize);
5b5ebf93ec16 Adds support for LADSPA (Linux Audio Developer's Simple Plugin API) plugins.
ivo
parents:
diff changeset
861 }
5b5ebf93ec16 Adds support for LADSPA (Linux Audio Developer's Simple Plugin API) plugins.
ivo
parents:
diff changeset
862
16195
cb08f47d3a79 Removed in-filter int to float conversion. af_ladspa now demands floats as
ivo
parents: 15790
diff changeset
863 /* Extract outbufs */
14217
5b5ebf93ec16 Adds support for LADSPA (Linux Audio Developer's Simple Plugin API) plugins.
ivo
parents:
diff changeset
864
5b5ebf93ec16 Adds support for LADSPA (Linux Audio Developer's Simple Plugin API) plugins.
ivo
parents:
diff changeset
865 for (p=0; p<setup->bufsize; p++) {
5b5ebf93ec16 Adds support for LADSPA (Linux Audio Developer's Simple Plugin API) plugins.
ivo
parents:
diff changeset
866 for (i=0; i<nch; i++) {
16195
cb08f47d3a79 Removed in-filter int to float conversion. af_ladspa now demands floats as
ivo
parents: 15790
diff changeset
867 audio[p*nch + i] = setup->outbufs[i][p];
14217
5b5ebf93ec16 Adds support for LADSPA (Linux Audio Developer's Simple Plugin API) plugins.
ivo
parents:
diff changeset
868 }
5b5ebf93ec16 Adds support for LADSPA (Linux Audio Developer's Simple Plugin API) plugins.
ivo
parents:
diff changeset
869 }
5b5ebf93ec16 Adds support for LADSPA (Linux Audio Developer's Simple Plugin API) plugins.
ivo
parents:
diff changeset
870
5b5ebf93ec16 Adds support for LADSPA (Linux Audio Developer's Simple Plugin API) plugins.
ivo
parents:
diff changeset
871 /* done */
5b5ebf93ec16 Adds support for LADSPA (Linux Audio Developer's Simple Plugin API) plugins.
ivo
parents:
diff changeset
872
5b5ebf93ec16 Adds support for LADSPA (Linux Audio Developer's Simple Plugin API) plugins.
ivo
parents:
diff changeset
873 return data;
5b5ebf93ec16 Adds support for LADSPA (Linux Audio Developer's Simple Plugin API) plugins.
ivo
parents:
diff changeset
874 }
5b5ebf93ec16 Adds support for LADSPA (Linux Audio Developer's Simple Plugin API) plugins.
ivo
parents:
diff changeset
875
5b5ebf93ec16 Adds support for LADSPA (Linux Audio Developer's Simple Plugin API) plugins.
ivo
parents:
diff changeset
876 /* ------------------------------------------------------------------------- */
5b5ebf93ec16 Adds support for LADSPA (Linux Audio Developer's Simple Plugin API) plugins.
ivo
parents:
diff changeset
877
5b5ebf93ec16 Adds support for LADSPA (Linux Audio Developer's Simple Plugin API) plugins.
ivo
parents:
diff changeset
878 /** \brief Open LADSPA Plugin Loader Filter
5b5ebf93ec16 Adds support for LADSPA (Linux Audio Developer's Simple Plugin API) plugins.
ivo
parents:
diff changeset
879 *
5b5ebf93ec16 Adds support for LADSPA (Linux Audio Developer's Simple Plugin API) plugins.
ivo
parents:
diff changeset
880 * \param af Audio Filter instance
5b5ebf93ec16 Adds support for LADSPA (Linux Audio Developer's Simple Plugin API) plugins.
ivo
parents:
diff changeset
881 *
5b5ebf93ec16 Adds support for LADSPA (Linux Audio Developer's Simple Plugin API) plugins.
ivo
parents:
diff changeset
882 * \return Either AF_ERROR or AF_OK
5b5ebf93ec16 Adds support for LADSPA (Linux Audio Developer's Simple Plugin API) plugins.
ivo
parents:
diff changeset
883 */
5b5ebf93ec16 Adds support for LADSPA (Linux Audio Developer's Simple Plugin API) plugins.
ivo
parents:
diff changeset
884
22746
fd6f824ef894 Rename open to af_open so as not to conflict with a previous header definition.
diego
parents: 22156
diff changeset
885 static int af_open(af_instance_t *af) {
14217
5b5ebf93ec16 Adds support for LADSPA (Linux Audio Developer's Simple Plugin API) plugins.
ivo
parents:
diff changeset
886
5b5ebf93ec16 Adds support for LADSPA (Linux Audio Developer's Simple Plugin API) plugins.
ivo
parents:
diff changeset
887 af->control=control;
5b5ebf93ec16 Adds support for LADSPA (Linux Audio Developer's Simple Plugin API) plugins.
ivo
parents:
diff changeset
888 af->uninit=uninit;
5b5ebf93ec16 Adds support for LADSPA (Linux Audio Developer's Simple Plugin API) plugins.
ivo
parents:
diff changeset
889 af->play=play;
24888
b2402b4f0afa libaf: change filter input/output ratio calculations
uau
parents: 22748
diff changeset
890 af->mul=1;
14217
5b5ebf93ec16 Adds support for LADSPA (Linux Audio Developer's Simple Plugin API) plugins.
ivo
parents:
diff changeset
891
5b5ebf93ec16 Adds support for LADSPA (Linux Audio Developer's Simple Plugin API) plugins.
ivo
parents:
diff changeset
892 af->data = calloc(1, sizeof(af_data_t));
5b5ebf93ec16 Adds support for LADSPA (Linux Audio Developer's Simple Plugin API) plugins.
ivo
parents:
diff changeset
893 if (af->data == NULL)
5b5ebf93ec16 Adds support for LADSPA (Linux Audio Developer's Simple Plugin API) plugins.
ivo
parents:
diff changeset
894 return af_ladspa_malloc_failed((char*)af_info_ladspa.name);
5b5ebf93ec16 Adds support for LADSPA (Linux Audio Developer's Simple Plugin API) plugins.
ivo
parents:
diff changeset
895
5b5ebf93ec16 Adds support for LADSPA (Linux Audio Developer's Simple Plugin API) plugins.
ivo
parents:
diff changeset
896 af->setup = calloc(1, sizeof(af_ladspa_t));
5b5ebf93ec16 Adds support for LADSPA (Linux Audio Developer's Simple Plugin API) plugins.
ivo
parents:
diff changeset
897 if (af->setup == NULL) {
5b5ebf93ec16 Adds support for LADSPA (Linux Audio Developer's Simple Plugin API) plugins.
ivo
parents:
diff changeset
898 free(af->data);
5b5ebf93ec16 Adds support for LADSPA (Linux Audio Developer's Simple Plugin API) plugins.
ivo
parents:
diff changeset
899 af->data=NULL;
5b5ebf93ec16 Adds support for LADSPA (Linux Audio Developer's Simple Plugin API) plugins.
ivo
parents:
diff changeset
900 return af_ladspa_malloc_failed((char*)af_info_ladspa.name);
5b5ebf93ec16 Adds support for LADSPA (Linux Audio Developer's Simple Plugin API) plugins.
ivo
parents:
diff changeset
901 }
5b5ebf93ec16 Adds support for LADSPA (Linux Audio Developer's Simple Plugin API) plugins.
ivo
parents:
diff changeset
902
5b5ebf93ec16 Adds support for LADSPA (Linux Audio Developer's Simple Plugin API) plugins.
ivo
parents:
diff changeset
903 ((af_ladspa_t*)af->setup)->status = AF_ERROR; /* will be set to AF_OK if
5b5ebf93ec16 Adds support for LADSPA (Linux Audio Developer's Simple Plugin API) plugins.
ivo
parents:
diff changeset
904 * all went OK and play()
5b5ebf93ec16 Adds support for LADSPA (Linux Audio Developer's Simple Plugin API) plugins.
ivo
parents:
diff changeset
905 * should proceed.
5b5ebf93ec16 Adds support for LADSPA (Linux Audio Developer's Simple Plugin API) plugins.
ivo
parents:
diff changeset
906 */
5b5ebf93ec16 Adds support for LADSPA (Linux Audio Developer's Simple Plugin API) plugins.
ivo
parents:
diff changeset
907
5b5ebf93ec16 Adds support for LADSPA (Linux Audio Developer's Simple Plugin API) plugins.
ivo
parents:
diff changeset
908 ((af_ladspa_t*)af->setup)->myname = strdup(af_info_ladspa.name);
5b5ebf93ec16 Adds support for LADSPA (Linux Audio Developer's Simple Plugin API) plugins.
ivo
parents:
diff changeset
909 if (!((af_ladspa_t*)af->setup)->myname)
5b5ebf93ec16 Adds support for LADSPA (Linux Audio Developer's Simple Plugin API) plugins.
ivo
parents:
diff changeset
910 return af_ladspa_malloc_failed((char*)af_info_ladspa.name);
5b5ebf93ec16 Adds support for LADSPA (Linux Audio Developer's Simple Plugin API) plugins.
ivo
parents:
diff changeset
911
5b5ebf93ec16 Adds support for LADSPA (Linux Audio Developer's Simple Plugin API) plugins.
ivo
parents:
diff changeset
912 return AF_OK;
5b5ebf93ec16 Adds support for LADSPA (Linux Audio Developer's Simple Plugin API) plugins.
ivo
parents:
diff changeset
913 }
5b5ebf93ec16 Adds support for LADSPA (Linux Audio Developer's Simple Plugin API) plugins.
ivo
parents:
diff changeset
914
5b5ebf93ec16 Adds support for LADSPA (Linux Audio Developer's Simple Plugin API) plugins.
ivo
parents:
diff changeset
915 /* ------------------------------------------------------------------------- */