2 |
// |
// |
3 |
/**************************************************************************** |
/**************************************************************************** |
4 |
liblscp - LinuxSampler Control Protocol API |
liblscp - LinuxSampler Control Protocol API |
5 |
Copyright (C) 2004, rncbc aka Rui Nuno Capela. All rights reserved. |
Copyright (C) 2004-2008, rncbc aka Rui Nuno Capela. All rights reserved. |
6 |
|
|
7 |
This library is free software; you can redistribute it and/or |
This library is free software; you can redistribute it and/or |
8 |
modify it under the terms of the GNU Lesser General Public |
modify it under the terms of the GNU Lesser General Public |
14 |
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
15 |
Lesser General Public License for more details. |
Lesser General Public License for more details. |
16 |
|
|
17 |
You should have received a copy of the GNU Lesser General Public |
You should have received a copy of the GNU General Public License along |
18 |
License along with this library; if not, write to the Free Software |
with this program; if not, write to the Free Software Foundation, Inc., |
19 |
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA |
51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. |
20 |
|
|
21 |
*****************************************************************************/ |
*****************************************************************************/ |
22 |
|
|
25 |
|
|
26 |
// Local prototypes. |
// Local prototypes. |
27 |
|
|
28 |
static lscp_driver_info_t *_lscp_driver_info_query (lscp_client_t *pClient, lscp_driver_info_t *pDriverInfo, const char *pszQuery); |
static lscp_driver_info_t *_lscp_driver_info_query (lscp_client_t *pClient, lscp_driver_info_t *pDriverInfo, char *pszQuery); |
29 |
|
static lscp_device_info_t *_lscp_device_info_query (lscp_client_t *pClient, lscp_device_info_t *pDeviceInfo, char *pszQuery); |
30 |
|
static lscp_param_info_t *_lscp_param_info_query (lscp_client_t *pClient, lscp_param_info_t *pParamInfo, char *pszQuery, int cchMaxQuery, lscp_param_t *pDepList); |
31 |
|
|
32 |
|
static lscp_device_port_info_t *_lscp_device_port_info_query (lscp_client_t *pClient, lscp_device_port_info_t *pDevicePortInfo, char *pszQuery); |
33 |
|
|
34 |
|
|
35 |
//------------------------------------------------------------------------- |
//------------------------------------------------------------------------- |
36 |
// Local funtions. |
// Local funtions. |
37 |
|
|
38 |
// Common driver type query command. |
// Common driver type query command. |
39 |
static lscp_driver_info_t *_lscp_driver_info_query ( lscp_client_t *pClient, lscp_driver_info_t *pDriverInfo, const char *pszQuery ) |
static lscp_driver_info_t *_lscp_driver_info_query ( lscp_client_t *pClient, lscp_driver_info_t *pDriverInfo, char *pszQuery ) |
40 |
{ |
{ |
41 |
const char *pszResult; |
const char *pszResult; |
42 |
const char *pszSeps = ":"; |
const char *pszSeps = ":"; |
43 |
const char *pszCrlf = "\r\n"; |
const char *pszCrlf = "\r\n"; |
44 |
char *pszToken; |
char *pszToken; |
45 |
char *pch; |
char *pch; |
46 |
|
|
47 |
lscp_driver_info_reset(pDriverInfo); |
// Lock this section up. |
48 |
|
lscp_mutex_lock(pClient->mutex); |
49 |
if (lscp_client_query(pClient, pszQuery) != LSCP_OK) |
|
50 |
return NULL; |
lscp_driver_info_reset(pDriverInfo); |
51 |
|
if (lscp_client_call(pClient, pszQuery, 1) == LSCP_OK) { |
52 |
pszResult = lscp_client_get_result(pClient); |
pszResult = lscp_client_get_result(pClient); |
53 |
pszToken = lscp_strtok(pszResult, pszSeps, &(pch)); |
pszToken = lscp_strtok((char *) pszResult, pszSeps, &(pch)); |
54 |
while (pszToken) { |
while (pszToken) { |
55 |
if (strcasecmp(pszToken, "DESCRIPTION") == 0) { |
if (strcasecmp(pszToken, "DESCRIPTION") == 0) { |
56 |
pszToken = lscp_strtok(NULL, pszCrlf, &(pch)); |
pszToken = lscp_strtok(NULL, pszCrlf, &(pch)); |
57 |
if (pszToken) |
if (pszToken) |
58 |
pDriverInfo->description = lscp_unquote(&pszToken, 1); |
lscp_unquote_dup(&(pDriverInfo->description), &pszToken); |
59 |
} |
} |
60 |
else if (strcasecmp(pszToken, "VERSION") == 0) { |
else if (strcasecmp(pszToken, "VERSION") == 0) { |
61 |
pszToken = lscp_strtok(NULL, pszCrlf, &(pch)); |
pszToken = lscp_strtok(NULL, pszCrlf, &(pch)); |
62 |
if (pszToken) |
if (pszToken) |
63 |
pDriverInfo->version = lscp_unquote(&pszToken, 1); |
lscp_unquote_dup(&(pDriverInfo->version), &pszToken); |
64 |
} |
} |
65 |
else if (strcasecmp(pszToken, "PARAMETERS") == 0) { |
else if (strcasecmp(pszToken, "PARAMETERS") == 0) { |
66 |
pszToken = lscp_strtok(NULL, pszCrlf, &(pch)); |
pszToken = lscp_strtok(NULL, pszCrlf, &(pch)); |
67 |
if (pszToken) |
if (pszToken) { |
68 |
pDriverInfo->parameters = lscp_szsplit_create(pszToken, ","); |
if (pDriverInfo->parameters) |
69 |
} |
lscp_szsplit_destroy(pDriverInfo->parameters); |
70 |
pszToken = lscp_strtok(NULL, pszSeps, &(pch)); |
pDriverInfo->parameters = lscp_szsplit_create(pszToken, ","); |
71 |
} |
} |
72 |
|
} |
73 |
|
pszToken = lscp_strtok(NULL, pszSeps, &(pch)); |
74 |
|
} |
75 |
|
} |
76 |
|
else pDriverInfo = NULL; |
77 |
|
|
78 |
|
// Unlock this section down. |
79 |
|
lscp_mutex_unlock(pClient->mutex); |
80 |
|
|
81 |
|
return pDriverInfo; |
82 |
|
} |
83 |
|
|
84 |
|
|
85 |
|
// Common device info query command. |
86 |
|
static lscp_device_info_t *_lscp_device_info_query ( lscp_client_t *pClient, lscp_device_info_t *pDeviceInfo, char *pszQuery ) |
87 |
|
{ |
88 |
|
const char *pszResult; |
89 |
|
const char *pszSeps = ":"; |
90 |
|
const char *pszCrlf = "\r\n"; |
91 |
|
char *pszToken; |
92 |
|
char *pch; |
93 |
|
char *pszKey; |
94 |
|
|
95 |
|
// Lock this section up. |
96 |
|
lscp_mutex_lock(pClient->mutex); |
97 |
|
|
98 |
|
lscp_device_info_reset(pDeviceInfo); |
99 |
|
if (lscp_client_call(pClient, pszQuery, 1) == LSCP_OK) { |
100 |
|
pszResult = lscp_client_get_result(pClient); |
101 |
|
pszToken = lscp_strtok((char *) pszResult, pszSeps, &(pch)); |
102 |
|
while (pszToken) { |
103 |
|
if (strcasecmp(pszToken, "DRIVER") == 0) { |
104 |
|
pszToken = lscp_strtok(NULL, pszCrlf, &(pch)); |
105 |
|
if (pszToken) |
106 |
|
lscp_unquote_dup(&(pDeviceInfo->driver), &pszToken); |
107 |
|
} |
108 |
|
else { |
109 |
|
pszKey = pszToken; |
110 |
|
pszToken = lscp_strtok(NULL, pszCrlf, &(pch)); |
111 |
|
if (pszToken) |
112 |
|
lscp_plist_append(&(pDeviceInfo->params), pszKey, lscp_unquote(&pszToken, 0)); |
113 |
|
} |
114 |
|
pszToken = lscp_strtok(NULL, pszSeps, &(pch)); |
115 |
|
} |
116 |
|
} |
117 |
|
else pDeviceInfo = NULL; |
118 |
|
|
119 |
|
// Unlock this section down. |
120 |
|
lscp_mutex_unlock(pClient->mutex); |
121 |
|
|
122 |
|
return pDeviceInfo; |
123 |
|
} |
124 |
|
|
125 |
|
|
126 |
|
// Common device channel/port info query command. |
127 |
|
static lscp_device_port_info_t *_lscp_device_port_info_query ( lscp_client_t *pClient, lscp_device_port_info_t *pDevicePortInfo, char *pszQuery ) |
128 |
|
{ |
129 |
|
const char *pszResult; |
130 |
|
const char *pszSeps = ":"; |
131 |
|
const char *pszCrlf = "\r\n"; |
132 |
|
char *pszToken; |
133 |
|
char *pch; |
134 |
|
char *pszKey; |
135 |
|
char *pszVal; |
136 |
|
|
137 |
|
// Lock this section up. |
138 |
|
lscp_mutex_lock(pClient->mutex); |
139 |
|
|
140 |
|
lscp_device_port_info_reset(pDevicePortInfo); |
141 |
|
if (lscp_client_call(pClient, pszQuery, 1) == LSCP_OK) { |
142 |
|
pszResult = lscp_client_get_result(pClient); |
143 |
|
pszToken = lscp_strtok((char *) pszResult, pszSeps, &(pch)); |
144 |
|
while (pszToken) { |
145 |
|
pszKey = pszToken; |
146 |
|
pszToken = lscp_strtok(NULL, pszCrlf, &(pch)); |
147 |
|
if (pszKey && pszToken) { |
148 |
|
pszVal = lscp_unquote(&pszToken, 0); |
149 |
|
lscp_plist_append(&(pDevicePortInfo->params), pszKey, pszVal); |
150 |
|
if (strcasecmp(pszKey, "NAME") == 0) { |
151 |
|
// Free desteny string, if already there. |
152 |
|
if (pDevicePortInfo->name) |
153 |
|
free(pDevicePortInfo->name); |
154 |
|
pDevicePortInfo->name = NULL; |
155 |
|
if (pszVal) |
156 |
|
pDevicePortInfo->name = strdup(pszVal); |
157 |
|
} |
158 |
|
} |
159 |
|
pszToken = lscp_strtok(NULL, pszSeps, &(pch)); |
160 |
|
} |
161 |
|
} |
162 |
|
else pDevicePortInfo = NULL; |
163 |
|
|
164 |
|
// Unlock this section down. |
165 |
|
lscp_mutex_unlock(pClient->mutex); |
166 |
|
|
167 |
|
return pDevicePortInfo; |
168 |
|
} |
169 |
|
|
170 |
|
|
171 |
|
// Common parameter info query command. |
172 |
|
static lscp_param_info_t *_lscp_param_info_query ( lscp_client_t *pClient, lscp_param_info_t *pParamInfo, char *pszQuery, int cchMaxQuery, lscp_param_t *pDepList ) |
173 |
|
{ |
174 |
|
const char *pszResult; |
175 |
|
const char *pszSeps = ":"; |
176 |
|
const char *pszCrlf = "\r\n"; |
177 |
|
char *pszToken; |
178 |
|
char *pch; |
179 |
|
|
180 |
|
// Lock this section up. |
181 |
|
lscp_mutex_lock(pClient->mutex); |
182 |
|
|
183 |
|
lscp_param_info_reset(pParamInfo); |
184 |
|
lscp_param_concat(pszQuery, cchMaxQuery, pDepList); |
185 |
|
if (lscp_client_call(pClient, pszQuery, 1) == LSCP_OK) { |
186 |
|
pszResult = lscp_client_get_result(pClient); |
187 |
|
pszToken = lscp_strtok((char *) pszResult, pszSeps, &(pch)); |
188 |
|
while (pszToken) { |
189 |
|
if (strcasecmp(pszToken, "TYPE") == 0) { |
190 |
|
pszToken = lscp_strtok(NULL, pszCrlf, &(pch)); |
191 |
|
if (pszToken) { |
192 |
|
pszToken = lscp_unquote(&pszToken, 0); |
193 |
|
if (strcasecmp(pszToken, "BOOL") == 0) |
194 |
|
pParamInfo->type = LSCP_TYPE_BOOL; |
195 |
|
else if (strcasecmp(pszToken, "INT") == 0) |
196 |
|
pParamInfo->type = LSCP_TYPE_INT; |
197 |
|
else if (strcasecmp(pszToken, "FLOAT") == 0) |
198 |
|
pParamInfo->type = LSCP_TYPE_FLOAT; |
199 |
|
else if (strcasecmp(pszToken, "STRING") == 0) |
200 |
|
pParamInfo->type = LSCP_TYPE_STRING; |
201 |
|
} |
202 |
|
} |
203 |
|
else if (strcasecmp(pszToken, "DESCRIPTION") == 0) { |
204 |
|
pszToken = lscp_strtok(NULL, pszCrlf, &(pch)); |
205 |
|
if (pszToken) |
206 |
|
lscp_unquote_dup(&(pParamInfo->description), &pszToken); |
207 |
|
} |
208 |
|
else if (strcasecmp(pszToken, "MANDATORY") == 0) { |
209 |
|
pszToken = lscp_strtok(NULL, pszCrlf, &(pch)); |
210 |
|
if (pszToken) |
211 |
|
pParamInfo->mandatory = (strcasecmp(lscp_unquote(&pszToken, 0), "TRUE") == 0); |
212 |
|
} |
213 |
|
else if (strcasecmp(pszToken, "FIX") == 0) { |
214 |
|
pszToken = lscp_strtok(NULL, pszCrlf, &(pch)); |
215 |
|
if (pszToken) |
216 |
|
pParamInfo->fix = (strcasecmp(lscp_unquote(&pszToken, 0), "TRUE") == 0); |
217 |
|
} |
218 |
|
else if (strcasecmp(pszToken, "MULTIPLICITY") == 0) { |
219 |
|
pszToken = lscp_strtok(NULL, pszCrlf, &(pch)); |
220 |
|
if (pszToken) |
221 |
|
pParamInfo->multiplicity = (strcasecmp(lscp_unquote(&pszToken, 0), "TRUE") == 0); |
222 |
|
} |
223 |
|
else if (strcasecmp(pszToken, "DEPENDS") == 0) { |
224 |
|
pszToken = lscp_strtok(NULL, pszCrlf, &(pch)); |
225 |
|
if (pszToken) { |
226 |
|
if (pParamInfo->depends) |
227 |
|
lscp_szsplit_destroy(pParamInfo->depends); |
228 |
|
pParamInfo->depends = lscp_szsplit_create(pszToken, ","); |
229 |
|
} |
230 |
|
} |
231 |
|
else if (strcasecmp(pszToken, "DEFAULT") == 0) { |
232 |
|
pszToken = lscp_strtok(NULL, pszCrlf, &(pch)); |
233 |
|
if (pszToken) |
234 |
|
lscp_unquote_dup(&(pParamInfo->defaultv), &pszToken); |
235 |
|
} |
236 |
|
else if (strcasecmp(pszToken, "RANGE_MIN") == 0) { |
237 |
|
pszToken = lscp_strtok(NULL, pszCrlf, &(pch)); |
238 |
|
if (pszToken) |
239 |
|
lscp_unquote_dup(&(pParamInfo->range_min), &pszToken); |
240 |
|
} |
241 |
|
else if (strcasecmp(pszToken, "RANGE_MAX") == 0) { |
242 |
|
pszToken = lscp_strtok(NULL, pszCrlf, &(pch)); |
243 |
|
if (pszToken) |
244 |
|
lscp_unquote_dup(&(pParamInfo->range_max), &pszToken); |
245 |
|
} |
246 |
|
else if (strcasecmp(pszToken, "POSSIBILITIES") == 0) { |
247 |
|
pszToken = lscp_strtok(NULL, pszCrlf, &(pch)); |
248 |
|
if (pszToken) { |
249 |
|
if (pParamInfo->possibilities) |
250 |
|
lscp_szsplit_destroy(pParamInfo->possibilities); |
251 |
|
pParamInfo->possibilities = lscp_szsplit_create(pszToken, ","); |
252 |
|
} |
253 |
|
} |
254 |
|
pszToken = lscp_strtok(NULL, pszSeps, &(pch)); |
255 |
|
} |
256 |
|
} |
257 |
|
else pParamInfo = NULL; |
258 |
|
|
259 |
|
// Unlock this section down. |
260 |
|
lscp_mutex_unlock(pClient->mutex); |
261 |
|
|
262 |
return pDriverInfo; |
return pParamInfo; |
263 |
} |
} |
264 |
|
|
265 |
|
|
267 |
// Audio driver control functions. |
// Audio driver control functions. |
268 |
|
|
269 |
/** |
/** |
270 |
* Getting all available audio output drivers. |
* Getting all available audio output driver count. |
271 |
* GET AVAILABLE_AUDIO_OUTPUT_DRIVERS |
* GET AVAILABLE_AUDIO_OUTPUT_DRIVERS |
272 |
* |
* |
273 |
* @param pClient Pointer to client instance structure. |
* @param pClient Pointer to client instance structure. |
274 |
* |
* |
275 |
|
* @returns The current total number of audio output drivers on success, |
276 |
|
* -1 otherwise. |
277 |
|
*/ |
278 |
|
int lscp_get_available_audio_drivers ( lscp_client_t *pClient ) |
279 |
|
{ |
280 |
|
int iAudioDrivers = -1; |
281 |
|
|
282 |
|
if (pClient == NULL) |
283 |
|
return -1; |
284 |
|
|
285 |
|
// Lock this section up. |
286 |
|
lscp_mutex_lock(pClient->mutex); |
287 |
|
|
288 |
|
if (lscp_client_call(pClient, "GET AVAILABLE_AUDIO_OUTPUT_DRIVERS\r\n", 0) == LSCP_OK) |
289 |
|
iAudioDrivers = atoi(lscp_client_get_result(pClient)); |
290 |
|
|
291 |
|
// Unlock this section down. |
292 |
|
lscp_mutex_unlock(pClient->mutex); |
293 |
|
|
294 |
|
return iAudioDrivers; |
295 |
|
} |
296 |
|
|
297 |
|
|
298 |
|
/** |
299 |
|
* Getting all available audio output drivers. |
300 |
|
* LIST AVAILABLE_AUDIO_OUTPUT_DRIVERS |
301 |
|
* |
302 |
|
* @param pClient Pointer to client instance structure. |
303 |
|
* |
304 |
* @returns A NULL terminated array of audio output driver type |
* @returns A NULL terminated array of audio output driver type |
305 |
* name strings, or NULL in case of failure. |
* name strings, or NULL in case of failure. |
306 |
*/ |
*/ |
307 |
const char ** lscp_get_available_audio_drivers ( lscp_client_t *pClient ) |
const char ** lscp_list_available_audio_drivers ( lscp_client_t *pClient ) |
308 |
{ |
{ |
309 |
const char *pszSeps = ","; |
const char *pszSeps = ","; |
310 |
|
|
311 |
|
if (pClient == NULL) |
312 |
|
return NULL; |
313 |
|
|
314 |
|
// Lock this section up. |
315 |
|
lscp_mutex_lock(pClient->mutex); |
316 |
|
|
317 |
if (pClient->audio_drivers) { |
if (pClient->audio_drivers) { |
318 |
lscp_szsplit_destroy(pClient->audio_drivers); |
lscp_szsplit_destroy(pClient->audio_drivers); |
319 |
pClient->audio_drivers = NULL; |
pClient->audio_drivers = NULL; |
320 |
} |
} |
321 |
|
|
322 |
if (lscp_client_query(pClient, "GET AVAILABLE_AUDIO_OUTPUT_DRIVERS\r\n") == LSCP_OK) |
if (lscp_client_call(pClient, "LIST AVAILABLE_AUDIO_OUTPUT_DRIVERS\r\n", 0) == LSCP_OK) |
323 |
pClient->audio_drivers = lscp_szsplit_create(lscp_client_get_result(pClient), pszSeps); |
pClient->audio_drivers = lscp_szsplit_create(lscp_client_get_result(pClient), pszSeps); |
324 |
|
|
325 |
return (const char **) pClient->audio_drivers; |
// Unlock this section down. |
326 |
|
lscp_mutex_unlock(pClient->mutex); |
327 |
|
|
328 |
|
return (const char **) pClient->audio_drivers; |
329 |
} |
} |
330 |
|
|
331 |
|
|
341 |
*/ |
*/ |
342 |
lscp_driver_info_t* lscp_get_audio_driver_info ( lscp_client_t *pClient, const char *pszAudioDriver ) |
lscp_driver_info_t* lscp_get_audio_driver_info ( lscp_client_t *pClient, const char *pszAudioDriver ) |
343 |
{ |
{ |
344 |
char szQuery[LSCP_BUFSIZ]; |
char szQuery[LSCP_BUFSIZ]; |
345 |
|
|
346 |
if (pszAudioDriver == NULL) |
if (pszAudioDriver == NULL) |
347 |
return NULL; |
return NULL; |
348 |
|
|
349 |
sprintf(szQuery, "GET AUDIO_OUTPUT_DRIVER INFO %s\r\n", pszAudioDriver); |
sprintf(szQuery, "GET AUDIO_OUTPUT_DRIVER INFO %s\r\n", pszAudioDriver); |
350 |
return _lscp_driver_info_query(pClient, &(pClient->audio_info), szQuery); |
return _lscp_driver_info_query(pClient, &(pClient->audio_driver_info), szQuery); |
351 |
} |
} |
352 |
|
|
353 |
|
|
365 |
*/ |
*/ |
366 |
lscp_param_info_t *lscp_get_audio_driver_param_info ( lscp_client_t *pClient, const char *pszAudioDriver, const char *pszParam, lscp_param_t *pDepList ) |
lscp_param_info_t *lscp_get_audio_driver_param_info ( lscp_client_t *pClient, const char *pszAudioDriver, const char *pszParam, lscp_param_t *pDepList ) |
367 |
{ |
{ |
368 |
lscp_param_info_t *pParamInfo = NULL; |
char szQuery[LSCP_BUFSIZ]; |
369 |
|
|
370 |
if (pClient == NULL) |
if (pClient == NULL) |
371 |
return NULL; |
return NULL; |
372 |
if (pszAudioDriver == NULL) |
if (pszAudioDriver == NULL) |
373 |
return NULL; |
return NULL; |
374 |
if (pszParam == NULL) |
if (pszParam == NULL) |
375 |
return NULL; |
return NULL; |
|
if (pDepList == NULL) |
|
|
return NULL; |
|
376 |
|
|
377 |
return pParamInfo; |
sprintf(szQuery, "GET AUDIO_OUTPUT_DRIVER_PARAMETER INFO %s %s", pszAudioDriver, pszParam); |
378 |
|
return _lscp_param_info_query(pClient, &(pClient->audio_param_info), szQuery, sizeof(szQuery), pDepList); |
379 |
} |
} |
380 |
|
|
381 |
|
|
395 |
*/ |
*/ |
396 |
int lscp_create_audio_device ( lscp_client_t *pClient, const char *pszAudioDriver, lscp_param_t *pParams ) |
int lscp_create_audio_device ( lscp_client_t *pClient, const char *pszAudioDriver, lscp_param_t *pParams ) |
397 |
{ |
{ |
398 |
int iAudioDevice = -1; |
char szQuery[LSCP_BUFSIZ]; |
399 |
|
int iAudioDevice = -1; |
400 |
|
|
401 |
|
if (pClient == NULL) |
402 |
|
return -1; |
403 |
|
if (pszAudioDriver == NULL) |
404 |
|
return -1; |
405 |
|
|
406 |
|
// Lock this section up. |
407 |
|
lscp_mutex_lock(pClient->mutex); |
408 |
|
|
409 |
|
sprintf(szQuery, "CREATE AUDIO_OUTPUT_DEVICE %s", pszAudioDriver); |
410 |
|
lscp_param_concat(szQuery, sizeof(szQuery), pParams); |
411 |
|
if (lscp_client_call(pClient, szQuery, 0) == LSCP_OK) |
412 |
|
iAudioDevice = atoi(lscp_client_get_result(pClient)); |
413 |
|
|
414 |
if (pClient == NULL) |
// Unlock this section down. |
415 |
return -1; |
lscp_mutex_unlock(pClient->mutex); |
|
if (pszAudioDriver == NULL) |
|
|
return -1; |
|
|
if (pParams == NULL) |
|
|
return -1; |
|
416 |
|
|
417 |
return iAudioDevice; |
return iAudioDevice; |
418 |
} |
} |
419 |
|
|
420 |
|
|
429 |
*/ |
*/ |
430 |
lscp_status_t lscp_destroy_audio_device ( lscp_client_t *pClient, int iAudioDevice ) |
lscp_status_t lscp_destroy_audio_device ( lscp_client_t *pClient, int iAudioDevice ) |
431 |
{ |
{ |
432 |
lscp_status_t ret = LSCP_FAILED; |
lscp_status_t ret = LSCP_FAILED; |
433 |
|
char szQuery[LSCP_BUFSIZ]; |
434 |
|
|
435 |
if (pClient == NULL) |
if (pClient == NULL) |
436 |
return ret; |
return ret; |
437 |
if (iAudioDevice < 0) |
if (iAudioDevice < 0) |
438 |
return ret; |
return ret; |
439 |
|
|
440 |
return ret; |
sprintf(szQuery, "DESTROY AUDIO_OUTPUT_DEVICE %d\r\n", iAudioDevice); |
441 |
|
return lscp_client_query(pClient, szQuery); |
442 |
} |
} |
443 |
|
|
444 |
|
|
445 |
/** |
/** |
446 |
* Getting all created audio output devices. |
* Getting all created audio output device count. |
447 |
* GET AUDIO_OUTPUT_DEVICES |
* GET AUDIO_OUTPUT_DEVICES |
448 |
* |
* |
449 |
* @param pClient Pointer to client instance structure. |
* @param pClient Pointer to client instance structure. |
450 |
* |
* |
451 |
|
* @returns The current total number of audio devices on success, |
452 |
|
* -1 otherwise. |
453 |
|
*/ |
454 |
|
int lscp_get_audio_devices ( lscp_client_t *pClient ) |
455 |
|
{ |
456 |
|
int iAudioDevices = -1; |
457 |
|
|
458 |
|
if (pClient == NULL) |
459 |
|
return -1; |
460 |
|
|
461 |
|
// Lock this section up. |
462 |
|
lscp_mutex_lock(pClient->mutex); |
463 |
|
|
464 |
|
if (lscp_client_call(pClient, "GET AUDIO_OUTPUT_DEVICES\r\n", 0) == LSCP_OK) |
465 |
|
iAudioDevices = atoi(lscp_client_get_result(pClient)); |
466 |
|
|
467 |
|
// Unlock this section down. |
468 |
|
lscp_mutex_unlock(pClient->mutex); |
469 |
|
|
470 |
|
return iAudioDevices; |
471 |
|
} |
472 |
|
|
473 |
|
|
474 |
|
/** |
475 |
|
* Getting all created audio output device list. |
476 |
|
* LIST AUDIO_OUTPUT_DEVICES |
477 |
|
* |
478 |
|
* @param pClient Pointer to client instance structure. |
479 |
|
* |
480 |
* @returns An array of audio device number identifiers, |
* @returns An array of audio device number identifiers, |
481 |
* terminated with -1 on success, or NULL in case of failure. |
* terminated with -1 on success, or NULL in case of failure. |
482 |
*/ |
*/ |
483 |
int *lscp_get_audio_devices ( lscp_client_t *pClient ) |
int *lscp_list_audio_devices ( lscp_client_t *pClient ) |
484 |
{ |
{ |
485 |
int *piAudioDevices = NULL; |
const char *pszSeps = ","; |
486 |
|
|
487 |
|
if (pClient == NULL) |
488 |
|
return NULL; |
489 |
|
|
490 |
|
// Lock this section up. |
491 |
|
lscp_mutex_lock(pClient->mutex); |
492 |
|
|
493 |
if (pClient == NULL) |
if (pClient->audio_devices) { |
494 |
return NULL; |
lscp_isplit_destroy(pClient->audio_devices); |
495 |
|
pClient->audio_devices = NULL; |
496 |
|
} |
497 |
|
|
498 |
return piAudioDevices; |
if (lscp_client_call(pClient, "LIST AUDIO_OUTPUT_DEVICES\r\n", 0) == LSCP_OK) |
499 |
|
pClient->audio_devices = lscp_isplit_create(lscp_client_get_result(pClient), pszSeps); |
500 |
|
|
501 |
|
// Unlock this section down. |
502 |
|
lscp_mutex_unlock(pClient->mutex); |
503 |
|
|
504 |
|
return pClient->audio_devices; |
505 |
} |
} |
506 |
|
|
507 |
|
|
517 |
*/ |
*/ |
518 |
lscp_device_info_t *lscp_get_audio_device_info ( lscp_client_t *pClient, int iAudioDevice ) |
lscp_device_info_t *lscp_get_audio_device_info ( lscp_client_t *pClient, int iAudioDevice ) |
519 |
{ |
{ |
520 |
lscp_device_info_t *pDeviceInfo = NULL; |
char szQuery[LSCP_BUFSIZ]; |
521 |
|
|
522 |
if (pClient == NULL) |
if (pClient == NULL) |
523 |
return NULL; |
return NULL; |
524 |
if (iAudioDevice < 0) |
if (iAudioDevice < 0) |
525 |
return NULL; |
return NULL; |
526 |
|
|
527 |
return pDeviceInfo; |
sprintf(szQuery, "GET AUDIO_OUTPUT_DEVICE INFO %d\r\n", iAudioDevice); |
528 |
|
return _lscp_device_info_query(pClient, &(pClient->audio_device_info), szQuery); |
529 |
} |
} |
530 |
|
|
531 |
|
|
532 |
/** |
/** |
533 |
* Changing settings of audio output devices. |
* Changing settings of audio output devices. |
534 |
* SET AUDIO_OUTPUT_DEVICE_PARAMETER <audio-device-id> <param> <value> |
* SET AUDIO_OUTPUT_DEVICE_PARAMETER <audio-device-id> <param>=<value> |
535 |
* |
* |
536 |
* @param pClient Pointer to client instance structure. |
* @param pClient Pointer to client instance structure. |
537 |
* @param iAudioDevice Audio device number identifier. |
* @param iAudioDevice Audio device number identifier. |
541 |
*/ |
*/ |
542 |
lscp_status_t lscp_set_audio_device_param ( lscp_client_t *pClient, int iAudioDevice, lscp_param_t *pParam ) |
lscp_status_t lscp_set_audio_device_param ( lscp_client_t *pClient, int iAudioDevice, lscp_param_t *pParam ) |
543 |
{ |
{ |
544 |
lscp_status_t ret = LSCP_FAILED; |
char szQuery[LSCP_BUFSIZ]; |
545 |
|
|
546 |
if (pClient == NULL) |
if (pClient == NULL) |
547 |
return ret; |
return LSCP_FAILED; |
548 |
if (iAudioDevice < 0) |
if (iAudioDevice < 0) |
549 |
return ret; |
return LSCP_FAILED; |
550 |
if (pParam == NULL) |
if (pParam == NULL) |
551 |
return ret; |
return LSCP_FAILED; |
552 |
|
|
553 |
return ret; |
sprintf(szQuery, "SET AUDIO_OUTPUT_DEVICE_PARAMETER %d %s='%s'\r\n", iAudioDevice, pParam->key, pParam->value); |
554 |
|
return lscp_client_query(pClient, szQuery); |
555 |
} |
} |
556 |
|
|
557 |
|
|
563 |
* @param iAudioDevice Audio device number identifier. |
* @param iAudioDevice Audio device number identifier. |
564 |
* @param iAudioChannel Audio channel number. |
* @param iAudioChannel Audio channel number. |
565 |
* |
* |
566 |
* @returns A pointer to a @ref lscp_device_channel_info_t structure, |
* @returns A pointer to a @ref lscp_device_port_info_t structure, |
567 |
* with the given audio channel information, or NULL in case of failure. |
* with the given audio channel information, or NULL in case of failure. |
568 |
*/ |
*/ |
569 |
lscp_device_channel_info_t* lscp_get_audio_channel_info ( lscp_client_t *pClient, int iAudioDevice, int iAudioChannel ) |
lscp_device_port_info_t* lscp_get_audio_channel_info ( lscp_client_t *pClient, int iAudioDevice, int iAudioChannel ) |
570 |
{ |
{ |
571 |
lscp_device_channel_info_t *pDevChannelInfo = NULL; |
char szQuery[LSCP_BUFSIZ]; |
572 |
|
|
573 |
if (pClient == NULL) |
if (pClient == NULL) |
574 |
return NULL; |
return NULL; |
575 |
if (iAudioDevice < 0) |
if (iAudioDevice < 0) |
576 |
return NULL; |
return NULL; |
577 |
if (iAudioChannel < 0) |
if (iAudioChannel < 0) |
578 |
return NULL; |
return NULL; |
579 |
|
|
580 |
return pDevChannelInfo; |
sprintf(szQuery, "GET AUDIO_OUTPUT_CHANNEL INFO %d %d\r\n", iAudioDevice, iAudioChannel); |
581 |
|
return _lscp_device_port_info_query(pClient, &(pClient->audio_channel_info), szQuery); |
582 |
} |
} |
583 |
|
|
584 |
|
|
596 |
*/ |
*/ |
597 |
lscp_param_info_t* lscp_get_audio_channel_param_info ( lscp_client_t *pClient, int iAudioDevice, int iAudioChannel, const char *pszParam ) |
lscp_param_info_t* lscp_get_audio_channel_param_info ( lscp_client_t *pClient, int iAudioDevice, int iAudioChannel, const char *pszParam ) |
598 |
{ |
{ |
599 |
lscp_param_info_t *pParamInfo = NULL; |
char szQuery[LSCP_BUFSIZ]; |
600 |
|
|
601 |
if (pClient == NULL) |
if (pClient == NULL) |
602 |
return NULL; |
return NULL; |
603 |
if (iAudioDevice < 0) |
if (iAudioDevice < 0) |
604 |
return NULL; |
return NULL; |
605 |
if (iAudioChannel < 0) |
if (iAudioChannel < 0) |
606 |
return NULL; |
return NULL; |
607 |
if (pszParam == NULL) |
if (pszParam == NULL) |
608 |
return NULL; |
return NULL; |
609 |
|
|
610 |
return pParamInfo; |
sprintf(szQuery, "GET AUDIO_OUTPUT_CHANNEL_PARAMETER INFO %d %d %s", iAudioDevice, iAudioChannel, pszParam); |
611 |
|
return _lscp_param_info_query(pClient, &(pClient->audio_channel_param_info), szQuery, sizeof(szQuery), NULL); |
612 |
} |
} |
613 |
|
|
614 |
|
|
625 |
*/ |
*/ |
626 |
lscp_status_t lscp_set_audio_channel_param ( lscp_client_t *pClient, int iAudioDevice, int iAudioChannel, lscp_param_t *pParam ) |
lscp_status_t lscp_set_audio_channel_param ( lscp_client_t *pClient, int iAudioDevice, int iAudioChannel, lscp_param_t *pParam ) |
627 |
{ |
{ |
628 |
lscp_status_t ret = LSCP_FAILED; |
char szQuery[LSCP_BUFSIZ]; |
629 |
|
|
630 |
if (pClient == NULL) |
if (pClient == NULL) |
631 |
return ret; |
return LSCP_FAILED; |
632 |
if (iAudioDevice < 0) |
if (iAudioDevice < 0) |
633 |
return ret; |
return LSCP_FAILED; |
634 |
if (iAudioChannel < 0) |
if (iAudioChannel < 0) |
635 |
return ret; |
return LSCP_FAILED; |
636 |
if (pParam == NULL) |
if (pParam == NULL) |
637 |
return ret; |
return LSCP_FAILED; |
638 |
|
|
639 |
return ret; |
sprintf(szQuery, "SET AUDIO_OUTPUT_CHANNEL_PARAMETER %d %d %s='%s'\r\n", iAudioDevice, iAudioChannel, pParam->key, pParam->value); |
640 |
|
return lscp_client_query(pClient, szQuery); |
641 |
} |
} |
642 |
|
|
643 |
|
|
645 |
// MIDI driver control functions. |
// MIDI driver control functions. |
646 |
|
|
647 |
/** |
/** |
648 |
* Getting all available MIDI input drivers. |
* Getting all available MIDI input driver count. |
649 |
* GET AVAILABLE_MIDI_INPUT_DRIVERS |
* GET AVAILABLE_MIDI_INPUT_DRIVERS |
650 |
* |
* |
651 |
* @param pClient Pointer to client instance structure. |
* @param pClient Pointer to client instance structure. |
652 |
* |
* |
653 |
|
* @returns The current total number of MIDI input drivers on success, |
654 |
|
* -1 otherwise. |
655 |
|
*/ |
656 |
|
int lscp_get_available_midi_drivers ( lscp_client_t *pClient ) |
657 |
|
{ |
658 |
|
int iMidiDrivers = -1; |
659 |
|
|
660 |
|
if (pClient == NULL) |
661 |
|
return -1; |
662 |
|
|
663 |
|
// Lock this section up. |
664 |
|
lscp_mutex_lock(pClient->mutex); |
665 |
|
|
666 |
|
if (lscp_client_call(pClient, "GET AVAILABLE_MIDI_INPUT_DRIVERS\r\n", 0) == LSCP_OK) |
667 |
|
iMidiDrivers = atoi(lscp_client_get_result(pClient)); |
668 |
|
|
669 |
|
// Unlock this section up. |
670 |
|
lscp_mutex_unlock(pClient->mutex); |
671 |
|
|
672 |
|
return iMidiDrivers; |
673 |
|
} |
674 |
|
|
675 |
|
|
676 |
|
/** |
677 |
|
* Getting all available MIDI input drivers. |
678 |
|
* LIST AVAILABLE_MIDI_INPUT_DRIVERS |
679 |
|
* |
680 |
|
* @param pClient Pointer to client instance structure. |
681 |
|
* |
682 |
* @returns A NULL terminated array of MIDI input driver type |
* @returns A NULL terminated array of MIDI input driver type |
683 |
* name strings, or NULL in case of failure. |
* name strings, or NULL in case of failure. |
684 |
*/ |
*/ |
685 |
const char** lscp_get_available_midi_drivers ( lscp_client_t *pClient ) |
const char** lscp_list_available_midi_drivers ( lscp_client_t *pClient ) |
686 |
{ |
{ |
687 |
const char *pszSeps = ","; |
const char *pszSeps = ","; |
688 |
|
|
689 |
|
if (pClient == NULL) |
690 |
|
return NULL; |
691 |
|
|
692 |
|
// Lock this section up. |
693 |
|
lscp_mutex_lock(pClient->mutex); |
694 |
|
|
695 |
|
if (pClient->midi_drivers) { |
696 |
|
lscp_szsplit_destroy(pClient->midi_drivers); |
697 |
|
pClient->midi_drivers = NULL; |
698 |
|
} |
699 |
|
|
700 |
if (pClient->midi_drivers) { |
if (lscp_client_call(pClient, "LIST AVAILABLE_MIDI_INPUT_DRIVERS\r\n", 0) == LSCP_OK) |
701 |
lscp_szsplit_destroy(pClient->midi_drivers); |
pClient->midi_drivers = lscp_szsplit_create(lscp_client_get_result(pClient), pszSeps); |
|
pClient->midi_drivers = NULL; |
|
|
} |
|
702 |
|
|
703 |
if (lscp_client_query(pClient, "GET AVAILABLE_MIDI_INPUT_DRIVERS\r\n") == LSCP_OK) |
// Unlock this section up. |
704 |
pClient->midi_drivers = lscp_szsplit_create(lscp_client_get_result(pClient), pszSeps); |
lscp_mutex_unlock(pClient->mutex); |
705 |
|
|
706 |
return (const char **) pClient->midi_drivers; |
return (const char **) pClient->midi_drivers; |
707 |
} |
} |
708 |
|
|
709 |
|
|
719 |
*/ |
*/ |
720 |
lscp_driver_info_t* lscp_get_midi_driver_info ( lscp_client_t *pClient, const char *pszMidiDriver ) |
lscp_driver_info_t* lscp_get_midi_driver_info ( lscp_client_t *pClient, const char *pszMidiDriver ) |
721 |
{ |
{ |
722 |
char szQuery[LSCP_BUFSIZ]; |
char szQuery[LSCP_BUFSIZ]; |
723 |
|
|
724 |
if (pszMidiDriver == NULL) |
if (pszMidiDriver == NULL) |
725 |
return NULL; |
return NULL; |
726 |
|
|
727 |
sprintf(szQuery, "GET MIDI_INPUT_DRIVER INFO %s\r\n", pszMidiDriver); |
sprintf(szQuery, "GET MIDI_INPUT_DRIVER INFO %s\r\n", pszMidiDriver); |
728 |
return _lscp_driver_info_query(pClient, &(pClient->midi_info), szQuery); |
return _lscp_driver_info_query(pClient, &(pClient->midi_driver_info), szQuery); |
729 |
} |
} |
730 |
|
|
731 |
|
|
745 |
*/ |
*/ |
746 |
lscp_param_info_t *lscp_get_midi_driver_param_info ( lscp_client_t *pClient, const char *pszMidiDriver, const char *pszParam, lscp_param_t *pDepList ) |
lscp_param_info_t *lscp_get_midi_driver_param_info ( lscp_client_t *pClient, const char *pszMidiDriver, const char *pszParam, lscp_param_t *pDepList ) |
747 |
{ |
{ |
748 |
lscp_param_info_t *pParamInfo = NULL; |
char szQuery[LSCP_BUFSIZ]; |
749 |
|
|
750 |
if (pClient == NULL) |
if (pClient == NULL) |
751 |
return NULL; |
return NULL; |
752 |
if (pszMidiDriver == NULL) |
if (pszMidiDriver == NULL) |
753 |
return NULL; |
return NULL; |
754 |
if (pszParam == NULL) |
if (pszParam == NULL) |
755 |
return NULL; |
return NULL; |
|
if (pDepList == NULL) |
|
|
return NULL; |
|
756 |
|
|
757 |
return pParamInfo; |
sprintf(szQuery, "GET MIDI_INPUT_DRIVER_PARAMETER INFO %s %s", pszMidiDriver, pszParam); |
758 |
|
return _lscp_param_info_query(pClient, &(pClient->midi_param_info), szQuery, sizeof(szQuery), pDepList); |
759 |
} |
} |
760 |
|
|
761 |
|
|
775 |
*/ |
*/ |
776 |
int lscp_create_midi_device ( lscp_client_t *pClient, const char *pszMidiDriver, lscp_param_t *pParams ) |
int lscp_create_midi_device ( lscp_client_t *pClient, const char *pszMidiDriver, lscp_param_t *pParams ) |
777 |
{ |
{ |
778 |
int iMidiDevice = -1; |
char szQuery[LSCP_BUFSIZ]; |
779 |
|
int iMidiDevice = -1; |
780 |
|
|
781 |
if (pClient == NULL) |
if (pClient == NULL) |
782 |
return -1; |
return -1; |
783 |
if (pszMidiDriver == NULL) |
if (pszMidiDriver == NULL) |
784 |
return -1; |
return -1; |
785 |
if (pParams == NULL) |
|
786 |
return -1; |
// Lock this section up. |
787 |
|
lscp_mutex_lock(pClient->mutex); |
788 |
|
|
789 |
|
sprintf(szQuery, "CREATE MIDI_INPUT_DEVICE %s", pszMidiDriver); |
790 |
|
lscp_param_concat(szQuery, sizeof(szQuery), pParams); |
791 |
|
if (lscp_client_call(pClient, szQuery, 0) == LSCP_OK) |
792 |
|
iMidiDevice = atoi(lscp_client_get_result(pClient)); |
793 |
|
|
794 |
return iMidiDevice; |
// Unlock this section down. |
795 |
|
lscp_mutex_unlock(pClient->mutex); |
796 |
|
|
797 |
|
return iMidiDevice; |
798 |
} |
} |
799 |
|
|
800 |
|
|
809 |
*/ |
*/ |
810 |
lscp_status_t lscp_destroy_midi_device ( lscp_client_t *pClient, int iMidiDevice ) |
lscp_status_t lscp_destroy_midi_device ( lscp_client_t *pClient, int iMidiDevice ) |
811 |
{ |
{ |
812 |
lscp_status_t ret = LSCP_FAILED; |
lscp_status_t ret = LSCP_FAILED; |
813 |
|
char szQuery[LSCP_BUFSIZ]; |
814 |
|
|
815 |
if (pClient == NULL) |
if (pClient == NULL) |
816 |
return ret; |
return ret; |
817 |
if (iMidiDevice < 0) |
if (iMidiDevice < 0) |
818 |
return ret; |
return ret; |
819 |
|
|
820 |
return ret; |
sprintf(szQuery, "DESTROY MIDI_INPUT_DEVICE %d\r\n", iMidiDevice); |
821 |
|
return lscp_client_query(pClient, szQuery); |
822 |
} |
} |
823 |
|
|
824 |
|
|
825 |
/** |
/** |
826 |
* Getting all created MIDI input devices. |
* Getting all created MIDI intput device count. |
827 |
* GET MIDI_INPUT_DEVICES |
* GET MIDI_INPUT_DEVICES |
828 |
* |
* |
829 |
* @param pClient Pointer to client instance structure. |
* @param pClient Pointer to client instance structure. |
830 |
* |
* |
831 |
|
* @returns The current total number of MIDI devices on success, |
832 |
|
* -1 otherwise. |
833 |
|
*/ |
834 |
|
int lscp_get_midi_devices ( lscp_client_t *pClient ) |
835 |
|
{ |
836 |
|
int iMidiDevices = -1; |
837 |
|
|
838 |
|
if (pClient == NULL) |
839 |
|
return -1; |
840 |
|
|
841 |
|
// Lock this section up. |
842 |
|
lscp_mutex_lock(pClient->mutex); |
843 |
|
|
844 |
|
if (lscp_client_call(pClient, "GET MIDI_INPUT_DEVICES\r\n", 0) == LSCP_OK) |
845 |
|
iMidiDevices = atoi(lscp_client_get_result(pClient)); |
846 |
|
|
847 |
|
// Unlock this section down. |
848 |
|
lscp_mutex_unlock(pClient->mutex); |
849 |
|
|
850 |
|
return iMidiDevices; |
851 |
|
} |
852 |
|
|
853 |
|
|
854 |
|
/** |
855 |
|
* Getting all created MIDI intput device list. |
856 |
|
* LIST MIDI_INPUT_DEVICES |
857 |
|
* |
858 |
|
* @param pClient Pointer to client instance structure. |
859 |
|
* |
860 |
* @returns An array of MIDI device number identifiers, |
* @returns An array of MIDI device number identifiers, |
861 |
* terminated with -1 on success, or NULL in case of failure. |
* terminated with -1 on success, or NULL in case of failure. |
862 |
*/ |
*/ |
863 |
int *lscp_get_midi_devices ( lscp_client_t *pClient ) |
int *lscp_list_midi_devices ( lscp_client_t *pClient ) |
864 |
{ |
{ |
865 |
int *piMidiDevices = NULL; |
const char *pszSeps = ","; |
866 |
|
|
867 |
|
if (pClient == NULL) |
868 |
|
return NULL; |
869 |
|
|
870 |
|
// Lock this section up. |
871 |
|
lscp_mutex_lock(pClient->mutex); |
872 |
|
|
873 |
if (pClient == NULL) |
if (pClient->midi_devices) { |
874 |
return NULL; |
lscp_isplit_destroy(pClient->midi_devices); |
875 |
|
pClient->midi_devices = NULL; |
876 |
|
} |
877 |
|
|
878 |
return piMidiDevices; |
if (lscp_client_call(pClient, "LIST MIDI_INPUT_DEVICES\r\n", 0) == LSCP_OK) |
879 |
|
pClient->midi_devices = lscp_isplit_create(lscp_client_get_result(pClient), pszSeps); |
880 |
|
|
881 |
|
// Unlock this section down. |
882 |
|
lscp_mutex_unlock(pClient->mutex); |
883 |
|
|
884 |
|
return pClient->midi_devices; |
885 |
} |
} |
886 |
|
|
887 |
|
|
897 |
*/ |
*/ |
898 |
lscp_device_info_t* lscp_get_midi_device_info ( lscp_client_t *pClient, int iMidiDevice ) |
lscp_device_info_t* lscp_get_midi_device_info ( lscp_client_t *pClient, int iMidiDevice ) |
899 |
{ |
{ |
900 |
lscp_device_info_t *pDeviceInfo = NULL; |
char szQuery[LSCP_BUFSIZ]; |
901 |
|
|
902 |
if (pClient == NULL) |
if (pClient == NULL) |
903 |
return NULL; |
return NULL; |
904 |
if (iMidiDevice < 0) |
if (iMidiDevice < 0) |
905 |
return NULL; |
return NULL; |
906 |
|
|
907 |
return pDeviceInfo; |
sprintf(szQuery, "GET MIDI_INPUT_DEVICE INFO %d\r\n", iMidiDevice); |
908 |
|
return _lscp_device_info_query(pClient, &(pClient->midi_device_info), szQuery); |
909 |
} |
} |
910 |
|
|
911 |
|
|
912 |
/** |
/** |
913 |
* Changing settings of MIDI input devices. |
* Changing settings of MIDI input devices. |
914 |
* SET MIDI_INPUT_DEVICE_PARAMETER <midi-device-id> <param> <value> |
* SET MIDI_INPUT_DEVICE_PARAMETER <midi-device-id> <param>=<value> |
915 |
* |
* |
916 |
* @param pClient Pointer to client instance structure. |
* @param pClient Pointer to client instance structure. |
917 |
* @param iMidiDevice MIDI device number identifier. |
* @param iMidiDevice MIDI device number identifier. |
921 |
*/ |
*/ |
922 |
lscp_status_t lscp_set_midi_device_param ( lscp_client_t *pClient, int iMidiDevice, lscp_param_t *pParam ) |
lscp_status_t lscp_set_midi_device_param ( lscp_client_t *pClient, int iMidiDevice, lscp_param_t *pParam ) |
923 |
{ |
{ |
924 |
lscp_status_t ret = LSCP_FAILED; |
char szQuery[LSCP_BUFSIZ]; |
925 |
|
|
926 |
if (pClient == NULL) |
if (pClient == NULL) |
927 |
return ret; |
return LSCP_FAILED; |
928 |
if (iMidiDevice < 0) |
if (iMidiDevice < 0) |
929 |
return ret; |
return LSCP_FAILED; |
930 |
if (pParam == NULL) |
if (pParam == NULL) |
931 |
return ret; |
return LSCP_FAILED; |
932 |
|
|
933 |
return ret; |
sprintf(szQuery, "SET MIDI_INPUT_DEVICE_PARAMETER %d %s='%s'\r\n", iMidiDevice, pParam->key, pParam->value); |
934 |
|
return lscp_client_query(pClient, szQuery); |
935 |
} |
} |
936 |
|
|
937 |
|
|
943 |
* @param iMidiDevice MIDI device number identifier. |
* @param iMidiDevice MIDI device number identifier. |
944 |
* @param iMidiPort MIDI port number. |
* @param iMidiPort MIDI port number. |
945 |
* |
* |
946 |
* @returns A pointer to a @ref lscp_device_channel_info_t structure, |
* @returns A pointer to a @ref lscp_device_port_info_t structure, |
947 |
* with the given MIDI port information, or NULL in case of failure. |
* with the given MIDI port information, or NULL in case of failure. |
948 |
*/ |
*/ |
949 |
lscp_device_channel_info_t* lscp_get_midi_port_info ( lscp_client_t *pClient, int iMidiDevice, int iMidiPort ) |
lscp_device_port_info_t* lscp_get_midi_port_info ( lscp_client_t *pClient, int iMidiDevice, int iMidiPort ) |
950 |
{ |
{ |
951 |
lscp_device_channel_info_t *pDevChannelInfo = NULL; |
char szQuery[LSCP_BUFSIZ]; |
952 |
|
|
953 |
if (pClient == NULL) |
if (pClient == NULL) |
954 |
return NULL; |
return NULL; |
955 |
if (iMidiDevice < 0) |
if (iMidiDevice < 0) |
956 |
return NULL; |
return NULL; |
957 |
if (iMidiPort < 0) |
if (iMidiPort < 0) |
958 |
return NULL; |
return NULL; |
959 |
|
|
960 |
return pDevChannelInfo; |
sprintf(szQuery, "GET MIDI_INPUT_PORT INFO %d %d\r\n", iMidiDevice, iMidiPort); |
961 |
|
return _lscp_device_port_info_query(pClient, &(pClient->midi_port_info), szQuery); |
962 |
} |
} |
963 |
|
|
964 |
|
|
976 |
*/ |
*/ |
977 |
lscp_param_info_t* lscp_get_midi_port_param_info ( lscp_client_t *pClient, int iMidiDevice, int iMidiPort, const char *pszParam ) |
lscp_param_info_t* lscp_get_midi_port_param_info ( lscp_client_t *pClient, int iMidiDevice, int iMidiPort, const char *pszParam ) |
978 |
{ |
{ |
979 |
lscp_param_info_t *pParamInfo = NULL; |
char szQuery[LSCP_BUFSIZ]; |
980 |
|
|
981 |
if (pClient == NULL) |
if (pClient == NULL) |
982 |
return NULL; |
return NULL; |
983 |
if (iMidiDevice < 0) |
if (iMidiDevice < 0) |
984 |
return NULL; |
return NULL; |
985 |
if (iMidiPort < 0) |
if (iMidiPort < 0) |
986 |
return NULL; |
return NULL; |
987 |
if (pszParam == NULL) |
if (pszParam == NULL) |
988 |
return NULL; |
return NULL; |
989 |
|
|
990 |
return pParamInfo; |
sprintf(szQuery, "GET MIDI_INPUT_PORT_PARAMETER INFO %d %d %s", iMidiDevice, iMidiPort, pszParam); |
991 |
|
return _lscp_param_info_query(pClient, &(pClient->midi_port_param_info), szQuery, sizeof(szQuery), NULL); |
992 |
} |
} |
993 |
|
|
994 |
|
|
1005 |
*/ |
*/ |
1006 |
lscp_status_t lscp_set_midi_port_param ( lscp_client_t *pClient, int iMidiDevice, int iMidiPort, lscp_param_t *pParam ) |
lscp_status_t lscp_set_midi_port_param ( lscp_client_t *pClient, int iMidiDevice, int iMidiPort, lscp_param_t *pParam ) |
1007 |
{ |
{ |
1008 |
lscp_status_t ret = LSCP_FAILED; |
char szQuery[LSCP_BUFSIZ]; |
1009 |
|
|
1010 |
|
if (pClient == NULL) |
1011 |
|
return LSCP_FAILED; |
1012 |
|
if (iMidiDevice < 0) |
1013 |
|
return LSCP_FAILED; |
1014 |
|
if (iMidiPort < 0) |
1015 |
|
return LSCP_FAILED; |
1016 |
|
if (pParam == NULL) |
1017 |
|
return LSCP_FAILED; |
1018 |
|
|
1019 |
|
sprintf(szQuery, "SET MIDI_INPUT_PORT_PARAMETER %d %d %s='%s'\r\n", iMidiDevice, iMidiPort, pParam->key, pParam->value); |
1020 |
|
return lscp_client_query(pClient, szQuery); |
1021 |
|
} |
1022 |
|
|
|
if (pClient == NULL) |
|
|
return ret; |
|
|
if (iMidiDevice < 0) |
|
|
return ret; |
|
|
if (iMidiPort < 0) |
|
|
return ret; |
|
|
if (pParam == NULL) |
|
|
return ret; |
|
1023 |
|
|
1024 |
return ret; |
//------------------------------------------------------------------------- |
1025 |
|
// Generic parameter list functions. |
1026 |
|
|
1027 |
|
const char *lscp_get_param_value ( lscp_param_t *pParams, const char *pszParam ) |
1028 |
|
{ |
1029 |
|
int i; |
1030 |
|
|
1031 |
|
for (i = 0; pParams && pParams[i].key; i++) { |
1032 |
|
if (strcasecmp(pParams[i].key, pszParam) == 0) |
1033 |
|
return (const char *) pParams[i].value; |
1034 |
|
} |
1035 |
|
return NULL; |
1036 |
} |
} |
1037 |
|
|
1038 |
|
|
1039 |
// end of device.c |
// end of device.c |
1040 |
|
|