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 = ":"; |
44 |
char *pszToken; |
char *pszToken; |
45 |
char *pch; |
char *pch; |
46 |
|
|
47 |
|
// Lock this section up. |
48 |
|
lscp_mutex_lock(pClient->mutex); |
49 |
|
|
50 |
lscp_driver_info_reset(pDriverInfo); |
lscp_driver_info_reset(pDriverInfo); |
51 |
|
if (lscp_client_call(pClient, pszQuery) == LSCP_OK) { |
52 |
|
pszResult = lscp_client_get_result(pClient); |
53 |
|
pszToken = lscp_strtok((char *) pszResult, pszSeps, &(pch)); |
54 |
|
while (pszToken) { |
55 |
|
if (strcasecmp(pszToken, "DESCRIPTION") == 0) { |
56 |
|
pszToken = lscp_strtok(NULL, pszCrlf, &(pch)); |
57 |
|
if (pszToken) |
58 |
|
lscp_unquote_dup(&(pDriverInfo->description), &pszToken); |
59 |
|
} |
60 |
|
else if (strcasecmp(pszToken, "VERSION") == 0) { |
61 |
|
pszToken = lscp_strtok(NULL, pszCrlf, &(pch)); |
62 |
|
if (pszToken) |
63 |
|
lscp_unquote_dup(&(pDriverInfo->version), &pszToken); |
64 |
|
} |
65 |
|
else if (strcasecmp(pszToken, "PARAMETERS") == 0) { |
66 |
|
pszToken = lscp_strtok(NULL, pszCrlf, &(pch)); |
67 |
|
if (pszToken) { |
68 |
|
if (pDriverInfo->parameters) |
69 |
|
lscp_szsplit_destroy(pDriverInfo->parameters); |
70 |
|
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 |
if (lscp_client_query(pClient, pszQuery) != LSCP_OK) |
return pDriverInfo; |
82 |
return NULL; |
} |
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 |
pszResult = lscp_client_get_result(pClient); |
// Lock this section up. |
96 |
pszToken = lscp_strtok((char *) pszResult, pszSeps, &(pch)); |
lscp_mutex_lock(pClient->mutex); |
97 |
while (pszToken) { |
|
98 |
if (strcasecmp(pszToken, "DESCRIPTION") == 0) { |
lscp_device_info_reset(pDeviceInfo); |
99 |
pszToken = lscp_strtok(NULL, pszCrlf, &(pch)); |
if (lscp_client_call(pClient, pszQuery) == LSCP_OK) { |
100 |
if (pszToken) |
pszResult = lscp_client_get_result(pClient); |
101 |
pDriverInfo->description = lscp_unquote(&pszToken, 1); |
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 |
else if (strcasecmp(pszToken, "VERSION") == 0) { |
} |
117 |
pszToken = lscp_strtok(NULL, pszCrlf, &(pch)); |
else pDeviceInfo = NULL; |
118 |
if (pszToken) |
|
119 |
pDriverInfo->version = lscp_unquote(&pszToken, 1); |
// 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 |
|
|
136 |
|
// Lock this section up. |
137 |
|
lscp_mutex_lock(pClient->mutex); |
138 |
|
|
139 |
|
lscp_device_port_info_reset(pDevicePortInfo); |
140 |
|
if (lscp_client_call(pClient, pszQuery) == LSCP_OK) { |
141 |
|
pszResult = lscp_client_get_result(pClient); |
142 |
|
pszToken = lscp_strtok((char *) pszResult, pszSeps, &(pch)); |
143 |
|
while (pszToken) { |
144 |
|
if (strcasecmp(pszToken, "NAME") == 0) { |
145 |
|
pszToken = lscp_strtok(NULL, pszCrlf, &(pch)); |
146 |
|
if (pszToken) |
147 |
|
lscp_unquote_dup(&(pDevicePortInfo->name), &pszToken); |
148 |
|
} |
149 |
|
else { |
150 |
|
pszKey = pszToken; |
151 |
|
pszToken = lscp_strtok(NULL, pszCrlf, &(pch)); |
152 |
|
if (pszToken) |
153 |
|
lscp_plist_append(&(pDevicePortInfo->params), pszKey, lscp_unquote(&pszToken, 0)); |
154 |
|
} |
155 |
|
pszToken = lscp_strtok(NULL, pszSeps, &(pch)); |
156 |
} |
} |
157 |
else if (strcasecmp(pszToken, "PARAMETERS") == 0) { |
} |
158 |
pszToken = lscp_strtok(NULL, pszCrlf, &(pch)); |
else pDevicePortInfo = NULL; |
159 |
if (pszToken) |
|
160 |
pDriverInfo->parameters = lscp_szsplit_create(pszToken, ","); |
// Unlock this section down. |
161 |
|
lscp_mutex_unlock(pClient->mutex); |
162 |
|
|
163 |
|
return pDevicePortInfo; |
164 |
|
} |
165 |
|
|
166 |
|
|
167 |
|
// Common parameter info query command. |
168 |
|
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 ) |
169 |
|
{ |
170 |
|
const char *pszResult; |
171 |
|
const char *pszSeps = ":"; |
172 |
|
const char *pszCrlf = "\r\n"; |
173 |
|
char *pszToken; |
174 |
|
char *pch; |
175 |
|
|
176 |
|
// Lock this section up. |
177 |
|
lscp_mutex_lock(pClient->mutex); |
178 |
|
|
179 |
|
lscp_param_info_reset(pParamInfo); |
180 |
|
lscp_param_concat(pszQuery, cchMaxQuery, pDepList); |
181 |
|
if (lscp_client_call(pClient, pszQuery) == LSCP_OK) { |
182 |
|
pszResult = lscp_client_get_result(pClient); |
183 |
|
pszToken = lscp_strtok((char *) pszResult, pszSeps, &(pch)); |
184 |
|
while (pszToken) { |
185 |
|
if (strcasecmp(pszToken, "TYPE") == 0) { |
186 |
|
pszToken = lscp_strtok(NULL, pszCrlf, &(pch)); |
187 |
|
if (pszToken) { |
188 |
|
pszToken = lscp_unquote(&pszToken, 0); |
189 |
|
if (strcasecmp(pszToken, "BOOL") == 0) |
190 |
|
pParamInfo->type = LSCP_TYPE_BOOL; |
191 |
|
else if (strcasecmp(pszToken, "INT") == 0) |
192 |
|
pParamInfo->type = LSCP_TYPE_INT; |
193 |
|
else if (strcasecmp(pszToken, "FLOAT") == 0) |
194 |
|
pParamInfo->type = LSCP_TYPE_FLOAT; |
195 |
|
else if (strcasecmp(pszToken, "STRING") == 0) |
196 |
|
pParamInfo->type = LSCP_TYPE_STRING; |
197 |
|
} |
198 |
|
} |
199 |
|
else if (strcasecmp(pszToken, "DESCRIPTION") == 0) { |
200 |
|
pszToken = lscp_strtok(NULL, pszCrlf, &(pch)); |
201 |
|
if (pszToken) |
202 |
|
lscp_unquote_dup(&(pParamInfo->description), &pszToken); |
203 |
|
} |
204 |
|
else if (strcasecmp(pszToken, "MANDATORY") == 0) { |
205 |
|
pszToken = lscp_strtok(NULL, pszCrlf, &(pch)); |
206 |
|
if (pszToken) |
207 |
|
pParamInfo->mandatory = (strcasecmp(lscp_unquote(&pszToken, 0), "TRUE") == 0); |
208 |
|
} |
209 |
|
else if (strcasecmp(pszToken, "FIX") == 0) { |
210 |
|
pszToken = lscp_strtok(NULL, pszCrlf, &(pch)); |
211 |
|
if (pszToken) |
212 |
|
pParamInfo->fix = (strcasecmp(lscp_unquote(&pszToken, 0), "TRUE") == 0); |
213 |
|
} |
214 |
|
else if (strcasecmp(pszToken, "MULTIPLICITY") == 0) { |
215 |
|
pszToken = lscp_strtok(NULL, pszCrlf, &(pch)); |
216 |
|
if (pszToken) |
217 |
|
pParamInfo->multiplicity = (strcasecmp(lscp_unquote(&pszToken, 0), "TRUE") == 0); |
218 |
|
} |
219 |
|
else if (strcasecmp(pszToken, "DEPENDS") == 0) { |
220 |
|
pszToken = lscp_strtok(NULL, pszCrlf, &(pch)); |
221 |
|
if (pszToken) { |
222 |
|
if (pParamInfo->depends) |
223 |
|
lscp_szsplit_destroy(pParamInfo->depends); |
224 |
|
pParamInfo->depends = lscp_szsplit_create(pszToken, ","); |
225 |
|
} |
226 |
|
} |
227 |
|
else if (strcasecmp(pszToken, "DEFAULT") == 0) { |
228 |
|
pszToken = lscp_strtok(NULL, pszCrlf, &(pch)); |
229 |
|
if (pszToken) |
230 |
|
lscp_unquote_dup(&(pParamInfo->defaultv), &pszToken); |
231 |
|
} |
232 |
|
else if (strcasecmp(pszToken, "RANGE_MIN") == 0) { |
233 |
|
pszToken = lscp_strtok(NULL, pszCrlf, &(pch)); |
234 |
|
if (pszToken) |
235 |
|
lscp_unquote_dup(&(pParamInfo->range_min), &pszToken); |
236 |
|
} |
237 |
|
else if (strcasecmp(pszToken, "RANGE_MAX") == 0) { |
238 |
|
pszToken = lscp_strtok(NULL, pszCrlf, &(pch)); |
239 |
|
if (pszToken) |
240 |
|
lscp_unquote_dup(&(pParamInfo->range_max), &pszToken); |
241 |
|
} |
242 |
|
else if (strcasecmp(pszToken, "POSSIBILITIES") == 0) { |
243 |
|
pszToken = lscp_strtok(NULL, pszCrlf, &(pch)); |
244 |
|
if (pszToken) { |
245 |
|
if (pParamInfo->possibilities) |
246 |
|
lscp_szsplit_destroy(pParamInfo->possibilities); |
247 |
|
pParamInfo->possibilities = lscp_szsplit_create(pszToken, ","); |
248 |
|
} |
249 |
|
} |
250 |
|
pszToken = lscp_strtok(NULL, pszSeps, &(pch)); |
251 |
} |
} |
|
pszToken = lscp_strtok(NULL, pszSeps, &(pch)); |
|
252 |
} |
} |
253 |
|
else pParamInfo = NULL; |
254 |
|
|
255 |
return pDriverInfo; |
// Unlock this section down. |
256 |
|
lscp_mutex_unlock(pClient->mutex); |
257 |
|
|
258 |
|
return pParamInfo; |
259 |
} |
} |
260 |
|
|
261 |
|
|
275 |
{ |
{ |
276 |
const char *pszSeps = ","; |
const char *pszSeps = ","; |
277 |
|
|
278 |
|
// Lock this section up. |
279 |
|
lscp_mutex_lock(pClient->mutex); |
280 |
|
|
281 |
if (pClient->audio_drivers) { |
if (pClient->audio_drivers) { |
282 |
lscp_szsplit_destroy(pClient->audio_drivers); |
lscp_szsplit_destroy(pClient->audio_drivers); |
283 |
pClient->audio_drivers = NULL; |
pClient->audio_drivers = NULL; |
284 |
} |
} |
285 |
|
|
286 |
if (lscp_client_query(pClient, "GET AVAILABLE_AUDIO_OUTPUT_DRIVERS\r\n") == LSCP_OK) |
if (lscp_client_call(pClient, "GET AVAILABLE_AUDIO_OUTPUT_DRIVERS\r\n") == LSCP_OK) |
287 |
pClient->audio_drivers = lscp_szsplit_create(lscp_client_get_result(pClient), pszSeps); |
pClient->audio_drivers = lscp_szsplit_create(lscp_client_get_result(pClient), pszSeps); |
288 |
|
|
289 |
|
// Unlock this section down. |
290 |
|
lscp_mutex_unlock(pClient->mutex); |
291 |
|
|
292 |
return (const char **) pClient->audio_drivers; |
return (const char **) pClient->audio_drivers; |
293 |
} |
} |
294 |
|
|
311 |
return NULL; |
return NULL; |
312 |
|
|
313 |
sprintf(szQuery, "GET AUDIO_OUTPUT_DRIVER INFO %s\r\n", pszAudioDriver); |
sprintf(szQuery, "GET AUDIO_OUTPUT_DRIVER INFO %s\r\n", pszAudioDriver); |
314 |
return _lscp_driver_info_query(pClient, &(pClient->audio_info), szQuery); |
return _lscp_driver_info_query(pClient, &(pClient->audio_driver_info), szQuery); |
315 |
} |
} |
316 |
|
|
317 |
|
|
329 |
*/ |
*/ |
330 |
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 ) |
331 |
{ |
{ |
332 |
lscp_param_info_t *pParamInfo = NULL; |
char szQuery[LSCP_BUFSIZ]; |
333 |
|
|
334 |
if (pClient == NULL) |
if (pClient == NULL) |
335 |
return NULL; |
return NULL; |
337 |
return NULL; |
return NULL; |
338 |
if (pszParam == NULL) |
if (pszParam == NULL) |
339 |
return NULL; |
return NULL; |
|
if (pDepList == NULL) |
|
|
return NULL; |
|
340 |
|
|
341 |
return pParamInfo; |
sprintf(szQuery, "GET AUDIO_OUTPUT_DRIVER_PARAMETER INFO %s %s", pszAudioDriver, pszParam); |
342 |
|
return _lscp_param_info_query(pClient, &(pClient->audio_param_info), szQuery, sizeof(szQuery), pDepList); |
343 |
} |
} |
344 |
|
|
345 |
|
|
359 |
*/ |
*/ |
360 |
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 ) |
361 |
{ |
{ |
362 |
|
char szQuery[LSCP_BUFSIZ]; |
363 |
int iAudioDevice = -1; |
int iAudioDevice = -1; |
364 |
|
|
365 |
if (pClient == NULL) |
if (pClient == NULL) |
366 |
return -1; |
return iAudioDevice; |
367 |
if (pszAudioDriver == NULL) |
if (pszAudioDriver == NULL) |
368 |
return -1; |
return iAudioDevice; |
369 |
if (pParams == NULL) |
|
370 |
return -1; |
// Lock this section up. |
371 |
|
lscp_mutex_lock(pClient->mutex); |
372 |
|
|
373 |
|
sprintf(szQuery, "CREATE AUDIO_OUTPUT_DEVICE %s", pszAudioDriver); |
374 |
|
lscp_param_concat(szQuery, sizeof(szQuery), pParams); |
375 |
|
if (lscp_client_call(pClient, szQuery) == LSCP_OK) |
376 |
|
iAudioDevice = atoi(lscp_client_get_result(pClient)); |
377 |
|
|
378 |
|
// Unlock this section down. |
379 |
|
lscp_mutex_unlock(pClient->mutex); |
380 |
|
|
381 |
return iAudioDevice; |
return iAudioDevice; |
382 |
} |
} |
394 |
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 ) |
395 |
{ |
{ |
396 |
lscp_status_t ret = LSCP_FAILED; |
lscp_status_t ret = LSCP_FAILED; |
397 |
|
char szQuery[LSCP_BUFSIZ]; |
398 |
|
|
399 |
if (pClient == NULL) |
if (pClient == NULL) |
400 |
return ret; |
return ret; |
401 |
if (iAudioDevice < 0) |
if (iAudioDevice < 0) |
402 |
return ret; |
return ret; |
403 |
|
|
404 |
return ret; |
sprintf(szQuery, "DESTROY AUDIO_OUTPUT_DEVICE %d\r\n", iAudioDevice); |
405 |
|
return lscp_client_query(pClient, szQuery); |
406 |
} |
} |
407 |
|
|
408 |
|
|
418 |
int lscp_get_audio_devices ( lscp_client_t *pClient ) |
int lscp_get_audio_devices ( lscp_client_t *pClient ) |
419 |
{ |
{ |
420 |
int iAudioDevices = -1; |
int iAudioDevices = -1; |
421 |
if (lscp_client_query(pClient, "GET AUDIO_OUTPUT_DEVICES\r\n") == LSCP_OK) |
|
422 |
|
// Lock this section up. |
423 |
|
lscp_mutex_lock(pClient->mutex); |
424 |
|
|
425 |
|
if (lscp_client_call(pClient, "GET AUDIO_OUTPUT_DEVICES\r\n") == LSCP_OK) |
426 |
iAudioDevices = atoi(lscp_client_get_result(pClient)); |
iAudioDevices = atoi(lscp_client_get_result(pClient)); |
427 |
|
|
428 |
|
// Unlock this section down. |
429 |
|
lscp_mutex_unlock(pClient->mutex); |
430 |
|
|
431 |
return iAudioDevices; |
return iAudioDevices; |
432 |
} |
} |
433 |
|
|
448 |
if (pClient == NULL) |
if (pClient == NULL) |
449 |
return NULL; |
return NULL; |
450 |
|
|
451 |
|
// Lock this section up. |
452 |
|
lscp_mutex_lock(pClient->mutex); |
453 |
|
|
454 |
if (pClient->audio_devices) { |
if (pClient->audio_devices) { |
455 |
lscp_isplit_destroy(pClient->audio_devices); |
lscp_isplit_destroy(pClient->audio_devices); |
456 |
pClient->audio_devices = NULL; |
pClient->audio_devices = NULL; |
457 |
} |
} |
458 |
|
|
459 |
if (lscp_client_query(pClient, "LIST AUDIO_OUTPUT_DEVICES\r\n") == LSCP_OK) |
if (lscp_client_call(pClient, "LIST AUDIO_OUTPUT_DEVICES\r\n") == LSCP_OK) |
460 |
pClient->audio_devices = lscp_isplit_create(lscp_client_get_result(pClient), pszSeps); |
pClient->audio_devices = lscp_isplit_create(lscp_client_get_result(pClient), pszSeps); |
461 |
|
|
462 |
|
// Unlock this section down. |
463 |
|
lscp_mutex_unlock(pClient->mutex); |
464 |
|
|
465 |
return pClient->audio_devices; |
return pClient->audio_devices; |
466 |
} |
} |
467 |
|
|
478 |
*/ |
*/ |
479 |
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 ) |
480 |
{ |
{ |
481 |
lscp_device_info_t *pDeviceInfo = NULL; |
char szQuery[LSCP_BUFSIZ]; |
482 |
|
|
483 |
if (pClient == NULL) |
if (pClient == NULL) |
484 |
return NULL; |
return NULL; |
485 |
if (iAudioDevice < 0) |
if (iAudioDevice < 0) |
486 |
return NULL; |
return NULL; |
487 |
|
|
488 |
return pDeviceInfo; |
sprintf(szQuery, "GET AUDIO_OUTPUT_DEVICE INFO %d\r\n", iAudioDevice); |
489 |
|
return _lscp_device_info_query(pClient, &(pClient->audio_device_info), szQuery); |
490 |
} |
} |
491 |
|
|
492 |
|
|
493 |
/** |
/** |
494 |
* Changing settings of audio output devices. |
* Changing settings of audio output devices. |
495 |
* SET AUDIO_OUTPUT_DEVICE_PARAMETER <audio-device-id> <param> <value> |
* SET AUDIO_OUTPUT_DEVICE_PARAMETER <audio-device-id> <param>=<value> |
496 |
* |
* |
497 |
* @param pClient Pointer to client instance structure. |
* @param pClient Pointer to client instance structure. |
498 |
* @param iAudioDevice Audio device number identifier. |
* @param iAudioDevice Audio device number identifier. |
502 |
*/ |
*/ |
503 |
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 ) |
504 |
{ |
{ |
505 |
lscp_status_t ret = LSCP_FAILED; |
char szQuery[LSCP_BUFSIZ]; |
506 |
|
|
507 |
if (pClient == NULL) |
if (pClient == NULL) |
508 |
return ret; |
return LSCP_FAILED; |
509 |
if (iAudioDevice < 0) |
if (iAudioDevice < 0) |
510 |
return ret; |
return LSCP_FAILED; |
511 |
if (pParam == NULL) |
if (pParam == NULL) |
512 |
return ret; |
return LSCP_FAILED; |
513 |
|
|
514 |
return ret; |
sprintf(szQuery, "SET AUDIO_OUTPUT_DEVICE_PARAMETER %d", iAudioDevice); |
515 |
|
lscp_param_concat(szQuery, sizeof(szQuery), pParam); |
516 |
|
return lscp_client_query(pClient, szQuery); |
517 |
} |
} |
518 |
|
|
519 |
|
|
525 |
* @param iAudioDevice Audio device number identifier. |
* @param iAudioDevice Audio device number identifier. |
526 |
* @param iAudioChannel Audio channel number. |
* @param iAudioChannel Audio channel number. |
527 |
* |
* |
528 |
* @returns A pointer to a @ref lscp_device_channel_info_t structure, |
* @returns A pointer to a @ref lscp_device_port_info_t structure, |
529 |
* with the given audio channel information, or NULL in case of failure. |
* with the given audio channel information, or NULL in case of failure. |
530 |
*/ |
*/ |
531 |
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 ) |
532 |
{ |
{ |
533 |
lscp_device_channel_info_t *pDevChannelInfo = NULL; |
char szQuery[LSCP_BUFSIZ]; |
534 |
|
|
535 |
if (pClient == NULL) |
if (pClient == NULL) |
536 |
return NULL; |
return NULL; |
539 |
if (iAudioChannel < 0) |
if (iAudioChannel < 0) |
540 |
return NULL; |
return NULL; |
541 |
|
|
542 |
return pDevChannelInfo; |
sprintf(szQuery, "GET AUDIO_OUTPUT_CHANNEL INFO %d %d\r\n", iAudioDevice, iAudioChannel); |
543 |
|
return _lscp_device_port_info_query(pClient, &(pClient->audio_channel_info), szQuery); |
544 |
} |
} |
545 |
|
|
546 |
|
|
558 |
*/ |
*/ |
559 |
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 ) |
560 |
{ |
{ |
561 |
lscp_param_info_t *pParamInfo = NULL; |
char szQuery[LSCP_BUFSIZ]; |
562 |
|
|
563 |
if (pClient == NULL) |
if (pClient == NULL) |
564 |
return NULL; |
return NULL; |
569 |
if (pszParam == NULL) |
if (pszParam == NULL) |
570 |
return NULL; |
return NULL; |
571 |
|
|
572 |
return pParamInfo; |
sprintf(szQuery, "GET AUDIO_OUTPUT_CHANNEL_PARAMETER INFO %d %d %s", iAudioDevice, iAudioChannel, pszParam); |
573 |
|
return _lscp_param_info_query(pClient, &(pClient->audio_channel_param_info), szQuery, sizeof(szQuery), NULL); |
574 |
} |
} |
575 |
|
|
576 |
|
|
587 |
*/ |
*/ |
588 |
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 ) |
589 |
{ |
{ |
590 |
lscp_status_t ret = LSCP_FAILED; |
char szQuery[LSCP_BUFSIZ]; |
591 |
|
|
592 |
if (pClient == NULL) |
if (pClient == NULL) |
593 |
return ret; |
return LSCP_FAILED; |
594 |
if (iAudioDevice < 0) |
if (iAudioDevice < 0) |
595 |
return ret; |
return LSCP_FAILED; |
596 |
if (iAudioChannel < 0) |
if (iAudioChannel < 0) |
597 |
return ret; |
return LSCP_FAILED; |
598 |
if (pParam == NULL) |
if (pParam == NULL) |
599 |
return ret; |
return LSCP_FAILED; |
600 |
|
|
601 |
return ret; |
sprintf(szQuery, "SET AUDIO_OUTPUT_CHANNEL_PARAMETER %d %d", iAudioDevice, iAudioChannel); |
602 |
|
lscp_param_concat(szQuery, sizeof(szQuery), pParam); |
603 |
|
return lscp_client_query(pClient, szQuery); |
604 |
} |
} |
605 |
|
|
606 |
|
|
620 |
{ |
{ |
621 |
const char *pszSeps = ","; |
const char *pszSeps = ","; |
622 |
|
|
623 |
|
// Lock this section up. |
624 |
|
lscp_mutex_lock(pClient->mutex); |
625 |
|
|
626 |
if (pClient->midi_drivers) { |
if (pClient->midi_drivers) { |
627 |
lscp_szsplit_destroy(pClient->midi_drivers); |
lscp_szsplit_destroy(pClient->midi_drivers); |
628 |
pClient->midi_drivers = NULL; |
pClient->midi_drivers = NULL; |
629 |
} |
} |
630 |
|
|
631 |
if (lscp_client_query(pClient, "GET AVAILABLE_MIDI_INPUT_DRIVERS\r\n") == LSCP_OK) |
if (lscp_client_call(pClient, "GET AVAILABLE_MIDI_INPUT_DRIVERS\r\n") == LSCP_OK) |
632 |
pClient->midi_drivers = lscp_szsplit_create(lscp_client_get_result(pClient), pszSeps); |
pClient->midi_drivers = lscp_szsplit_create(lscp_client_get_result(pClient), pszSeps); |
633 |
|
|
634 |
|
// Unlock this section up. |
635 |
|
lscp_mutex_unlock(pClient->mutex); |
636 |
|
|
637 |
return (const char **) pClient->midi_drivers; |
return (const char **) pClient->midi_drivers; |
638 |
} |
} |
639 |
|
|
656 |
return NULL; |
return NULL; |
657 |
|
|
658 |
sprintf(szQuery, "GET MIDI_INPUT_DRIVER INFO %s\r\n", pszMidiDriver); |
sprintf(szQuery, "GET MIDI_INPUT_DRIVER INFO %s\r\n", pszMidiDriver); |
659 |
return _lscp_driver_info_query(pClient, &(pClient->midi_info), szQuery); |
return _lscp_driver_info_query(pClient, &(pClient->midi_driver_info), szQuery); |
660 |
} |
} |
661 |
|
|
662 |
|
|
676 |
*/ |
*/ |
677 |
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 ) |
678 |
{ |
{ |
679 |
lscp_param_info_t *pParamInfo = NULL; |
char szQuery[LSCP_BUFSIZ]; |
680 |
|
|
681 |
if (pClient == NULL) |
if (pClient == NULL) |
682 |
return NULL; |
return NULL; |
684 |
return NULL; |
return NULL; |
685 |
if (pszParam == NULL) |
if (pszParam == NULL) |
686 |
return NULL; |
return NULL; |
|
if (pDepList == NULL) |
|
|
return NULL; |
|
687 |
|
|
688 |
return pParamInfo; |
sprintf(szQuery, "GET MIDI_INPUT_DRIVER_PARAMETER INFO %s %s", pszMidiDriver, pszParam); |
689 |
|
return _lscp_param_info_query(pClient, &(pClient->midi_param_info), szQuery, sizeof(szQuery), pDepList); |
690 |
} |
} |
691 |
|
|
692 |
|
|
706 |
*/ |
*/ |
707 |
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 ) |
708 |
{ |
{ |
709 |
|
char szQuery[LSCP_BUFSIZ]; |
710 |
int iMidiDevice = -1; |
int iMidiDevice = -1; |
711 |
|
|
712 |
if (pClient == NULL) |
if (pClient == NULL) |
713 |
return -1; |
return iMidiDevice; |
714 |
if (pszMidiDriver == NULL) |
if (pszMidiDriver == NULL) |
715 |
return -1; |
return iMidiDevice; |
716 |
if (pParams == NULL) |
|
717 |
return -1; |
// Lock this section up. |
718 |
|
lscp_mutex_lock(pClient->mutex); |
719 |
|
|
720 |
|
sprintf(szQuery, "CREATE MIDI_INPUT_DEVICE %s", pszMidiDriver); |
721 |
|
lscp_param_concat(szQuery, sizeof(szQuery), pParams); |
722 |
|
if (lscp_client_call(pClient, szQuery) == LSCP_OK) |
723 |
|
iMidiDevice = atoi(lscp_client_get_result(pClient)); |
724 |
|
|
725 |
|
// Unlock this section down. |
726 |
|
lscp_mutex_unlock(pClient->mutex); |
727 |
|
|
728 |
return iMidiDevice; |
return iMidiDevice; |
729 |
} |
} |
741 |
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 ) |
742 |
{ |
{ |
743 |
lscp_status_t ret = LSCP_FAILED; |
lscp_status_t ret = LSCP_FAILED; |
744 |
|
char szQuery[LSCP_BUFSIZ]; |
745 |
|
|
746 |
if (pClient == NULL) |
if (pClient == NULL) |
747 |
return ret; |
return ret; |
748 |
if (iMidiDevice < 0) |
if (iMidiDevice < 0) |
749 |
return ret; |
return ret; |
750 |
|
|
751 |
return ret; |
sprintf(szQuery, "DESTROY MIDI_INPUT_DEVICE %d\r\n", iMidiDevice); |
752 |
|
return lscp_client_query(pClient, szQuery); |
753 |
} |
} |
754 |
|
|
755 |
|
|
765 |
int lscp_get_midi_devices ( lscp_client_t *pClient ) |
int lscp_get_midi_devices ( lscp_client_t *pClient ) |
766 |
{ |
{ |
767 |
int iMidiDevices = -1; |
int iMidiDevices = -1; |
768 |
if (lscp_client_query(pClient, "GET MIDI_INPUT_DEVICES\r\n") == LSCP_OK) |
|
769 |
|
// Lock this section up. |
770 |
|
lscp_mutex_lock(pClient->mutex); |
771 |
|
|
772 |
|
if (lscp_client_call(pClient, "GET MIDI_INPUT_DEVICES\r\n") == LSCP_OK) |
773 |
iMidiDevices = atoi(lscp_client_get_result(pClient)); |
iMidiDevices = atoi(lscp_client_get_result(pClient)); |
774 |
|
|
775 |
|
// Unlock this section down. |
776 |
|
lscp_mutex_unlock(pClient->mutex); |
777 |
|
|
778 |
return iMidiDevices; |
return iMidiDevices; |
779 |
} |
} |
780 |
|
|
795 |
if (pClient == NULL) |
if (pClient == NULL) |
796 |
return NULL; |
return NULL; |
797 |
|
|
798 |
|
// Lock this section up. |
799 |
|
lscp_mutex_lock(pClient->mutex); |
800 |
|
|
801 |
if (pClient->midi_devices) { |
if (pClient->midi_devices) { |
802 |
lscp_isplit_destroy(pClient->midi_devices); |
lscp_isplit_destroy(pClient->midi_devices); |
803 |
pClient->midi_devices = NULL; |
pClient->midi_devices = NULL; |
804 |
} |
} |
805 |
|
|
806 |
if (lscp_client_query(pClient, "LIST MIDI_INPUT_DEVICES\r\n") == LSCP_OK) |
if (lscp_client_call(pClient, "LIST MIDI_INPUT_DEVICES\r\n") == LSCP_OK) |
807 |
pClient->midi_devices = lscp_isplit_create(lscp_client_get_result(pClient), pszSeps); |
pClient->midi_devices = lscp_isplit_create(lscp_client_get_result(pClient), pszSeps); |
808 |
|
|
809 |
|
// Unlock this section down. |
810 |
|
lscp_mutex_unlock(pClient->mutex); |
811 |
|
|
812 |
return pClient->midi_devices; |
return pClient->midi_devices; |
813 |
} |
} |
814 |
|
|
825 |
*/ |
*/ |
826 |
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 ) |
827 |
{ |
{ |
828 |
lscp_device_info_t *pDeviceInfo = NULL; |
char szQuery[LSCP_BUFSIZ]; |
829 |
|
|
830 |
if (pClient == NULL) |
if (pClient == NULL) |
831 |
return NULL; |
return NULL; |
832 |
if (iMidiDevice < 0) |
if (iMidiDevice < 0) |
833 |
return NULL; |
return NULL; |
834 |
|
|
835 |
return pDeviceInfo; |
sprintf(szQuery, "GET MIDI_INPUT_DEVICE INFO %d\r\n", iMidiDevice); |
836 |
|
return _lscp_device_info_query(pClient, &(pClient->midi_device_info), szQuery); |
837 |
} |
} |
838 |
|
|
839 |
|
|
840 |
/** |
/** |
841 |
* Changing settings of MIDI input devices. |
* Changing settings of MIDI input devices. |
842 |
* SET MIDI_INPUT_DEVICE_PARAMETER <midi-device-id> <param> <value> |
* SET MIDI_INPUT_DEVICE_PARAMETER <midi-device-id> <param>=<value> |
843 |
* |
* |
844 |
* @param pClient Pointer to client instance structure. |
* @param pClient Pointer to client instance structure. |
845 |
* @param iMidiDevice MIDI device number identifier. |
* @param iMidiDevice MIDI device number identifier. |
849 |
*/ |
*/ |
850 |
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 ) |
851 |
{ |
{ |
852 |
lscp_status_t ret = LSCP_FAILED; |
char szQuery[LSCP_BUFSIZ]; |
853 |
|
|
854 |
if (pClient == NULL) |
if (pClient == NULL) |
855 |
return ret; |
return LSCP_FAILED; |
856 |
if (iMidiDevice < 0) |
if (iMidiDevice < 0) |
857 |
return ret; |
return LSCP_FAILED; |
858 |
if (pParam == NULL) |
if (pParam == NULL) |
859 |
return ret; |
return LSCP_FAILED; |
860 |
|
|
861 |
return ret; |
sprintf(szQuery, "SET MIDI_INPUT_DEVICE_PARAMETER %d", iMidiDevice); |
862 |
|
lscp_param_concat(szQuery, sizeof(szQuery), pParam); |
863 |
|
return lscp_client_query(pClient, szQuery); |
864 |
} |
} |
865 |
|
|
866 |
|
|
872 |
* @param iMidiDevice MIDI device number identifier. |
* @param iMidiDevice MIDI device number identifier. |
873 |
* @param iMidiPort MIDI port number. |
* @param iMidiPort MIDI port number. |
874 |
* |
* |
875 |
* @returns A pointer to a @ref lscp_device_channel_info_t structure, |
* @returns A pointer to a @ref lscp_device_port_info_t structure, |
876 |
* with the given MIDI port information, or NULL in case of failure. |
* with the given MIDI port information, or NULL in case of failure. |
877 |
*/ |
*/ |
878 |
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 ) |
879 |
{ |
{ |
880 |
lscp_device_channel_info_t *pDevChannelInfo = NULL; |
char szQuery[LSCP_BUFSIZ]; |
881 |
|
|
882 |
if (pClient == NULL) |
if (pClient == NULL) |
883 |
return NULL; |
return NULL; |
886 |
if (iMidiPort < 0) |
if (iMidiPort < 0) |
887 |
return NULL; |
return NULL; |
888 |
|
|
889 |
return pDevChannelInfo; |
sprintf(szQuery, "GET MIDI_INPUT_PORT INFO %d %d\r\n", iMidiDevice, iMidiPort); |
890 |
|
return _lscp_device_port_info_query(pClient, &(pClient->midi_port_info), szQuery); |
891 |
} |
} |
892 |
|
|
893 |
|
|
905 |
*/ |
*/ |
906 |
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 ) |
907 |
{ |
{ |
908 |
lscp_param_info_t *pParamInfo = NULL; |
char szQuery[LSCP_BUFSIZ]; |
909 |
|
|
910 |
if (pClient == NULL) |
if (pClient == NULL) |
911 |
return NULL; |
return NULL; |
916 |
if (pszParam == NULL) |
if (pszParam == NULL) |
917 |
return NULL; |
return NULL; |
918 |
|
|
919 |
return pParamInfo; |
sprintf(szQuery, "GET MIDI_INPUT_PORT_PARAMETER INFO %d %d %s", iMidiDevice, iMidiPort, pszParam); |
920 |
|
return _lscp_param_info_query(pClient, &(pClient->midi_port_param_info), szQuery, sizeof(szQuery), NULL); |
921 |
} |
} |
922 |
|
|
923 |
|
|
934 |
*/ |
*/ |
935 |
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 ) |
936 |
{ |
{ |
937 |
lscp_status_t ret = LSCP_FAILED; |
char szQuery[LSCP_BUFSIZ]; |
938 |
|
|
939 |
if (pClient == NULL) |
if (pClient == NULL) |
940 |
return ret; |
return LSCP_FAILED; |
941 |
if (iMidiDevice < 0) |
if (iMidiDevice < 0) |
942 |
return ret; |
return LSCP_FAILED; |
943 |
if (iMidiPort < 0) |
if (iMidiPort < 0) |
944 |
return ret; |
return LSCP_FAILED; |
945 |
if (pParam == NULL) |
if (pParam == NULL) |
946 |
return ret; |
return LSCP_FAILED; |
947 |
|
|
948 |
|
sprintf(szQuery, "SET MIDI_INPUT_PORT_PARAMETER %d %d", iMidiDevice, iMidiPort); |
949 |
|
lscp_param_concat(szQuery, sizeof(szQuery), pParam); |
950 |
|
return lscp_client_query(pClient, szQuery); |
951 |
|
} |
952 |
|
|
953 |
|
|
954 |
|
//------------------------------------------------------------------------- |
955 |
|
// Generic parameter list functions. |
956 |
|
|
957 |
return ret; |
const char *lscp_get_param_value ( lscp_param_t *pParams, const char *pszParam ) |
958 |
|
{ |
959 |
|
int i; |
960 |
|
|
961 |
|
for (i = 0; pParams && pParams[i].key; i++) { |
962 |
|
if (strcasecmp(pParams[i].key, pszParam) == 0) |
963 |
|
return (const char *) pParams[i].value; |
964 |
|
} |
965 |
|
return NULL; |
966 |
} |
} |
967 |
|
|
968 |
|
|
969 |
// end of device.c |
// end of device.c |
970 |
|
|