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 14have received a copy of the GNU Lesser General Public |
18 |
License along with this library; if not, write to the Free Software |
License along with this library; if not, write to the Free Software |
19 |
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA |
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA |
20 |
|
|
69 |
|
|
70 |
// Use the timeout (x10) select feature ... |
// Use the timeout (x10) select feature ... |
71 |
iTimeout = 10 * pClient->iTimeout; |
iTimeout = 10 * pClient->iTimeout; |
72 |
if (iTimeout > 1000) { |
if (iTimeout >= 1000) { |
73 |
tv.tv_sec = iTimeout / 1000; |
tv.tv_sec = iTimeout / 1000; |
74 |
iTimeout -= tv.tv_sec * 1000; |
iTimeout -= tv.tv_sec * 1000; |
75 |
} |
} |
337 |
lscp_device_port_info_init(&(pClient->midi_port_info)); |
lscp_device_port_info_init(&(pClient->midi_port_info)); |
338 |
lscp_param_info_init(&(pClient->audio_channel_param_info)); |
lscp_param_info_init(&(pClient->audio_channel_param_info)); |
339 |
lscp_param_info_init(&(pClient->midi_port_param_info)); |
lscp_param_info_init(&(pClient->midi_port_param_info)); |
340 |
|
lscp_server_info_init(&(pClient->server_info)); |
341 |
lscp_engine_info_init(&(pClient->engine_info)); |
lscp_engine_info_init(&(pClient->engine_info)); |
342 |
lscp_channel_info_init(&(pClient->channel_info)); |
lscp_channel_info_init(&(pClient->channel_info)); |
343 |
// Initialize error stuff. |
// Initialize error stuff. |
348 |
pClient->iStreamCount = 0; |
pClient->iStreamCount = 0; |
349 |
// Default timeout value. |
// Default timeout value. |
350 |
pClient->iTimeout = LSCP_TIMEOUT_MSECS; |
pClient->iTimeout = LSCP_TIMEOUT_MSECS; |
351 |
|
pClient->iTimeoutCount = 0; |
352 |
|
|
353 |
// Initialize the transaction mutex. |
// Initialize the transaction mutex. |
354 |
lscp_mutex_init(pClient->mutex); |
lscp_mutex_init(pClient->mutex); |
402 |
// Free up all cached members. |
// Free up all cached members. |
403 |
lscp_channel_info_free(&(pClient->channel_info)); |
lscp_channel_info_free(&(pClient->channel_info)); |
404 |
lscp_engine_info_free(&(pClient->engine_info)); |
lscp_engine_info_free(&(pClient->engine_info)); |
405 |
|
lscp_server_info_free(&(pClient->server_info)); |
406 |
lscp_param_info_free(&(pClient->midi_port_param_info)); |
lscp_param_info_free(&(pClient->midi_port_param_info)); |
407 |
lscp_param_info_free(&(pClient->audio_channel_param_info)); |
lscp_param_info_free(&(pClient->audio_channel_param_info)); |
408 |
lscp_device_port_info_free(&(pClient->midi_port_info)); |
lscp_device_port_info_free(&(pClient->midi_port_info)); |
1053 |
if (pszToken) |
if (pszToken) |
1054 |
pChannelInfo->volume = (float) atof(lscp_ltrim(pszToken)); |
pChannelInfo->volume = (float) atof(lscp_ltrim(pszToken)); |
1055 |
} |
} |
1056 |
|
else if (strcasecmp(pszToken, "MUTE") == 0) { |
1057 |
|
pszToken = lscp_strtok(NULL, pszCrlf, &(pch)); |
1058 |
|
if (pszToken) |
1059 |
|
pChannelInfo->mute = (strcasecmp(lscp_unquote(&pszToken, 0), "TRUE") == 0); |
1060 |
|
} |
1061 |
|
else if (strcasecmp(pszToken, "SOLO") == 0) { |
1062 |
|
pszToken = lscp_strtok(NULL, pszCrlf, &(pch)); |
1063 |
|
if (pszToken) |
1064 |
|
pChannelInfo->solo = (strcasecmp(lscp_unquote(&pszToken, 0), "TRUE") == 0); |
1065 |
|
} |
1066 |
pszToken = lscp_strtok(NULL, pszSeps, &(pch)); |
pszToken = lscp_strtok(NULL, pszSeps, &(pch)); |
1067 |
} |
} |
1068 |
} |
} |
1446 |
|
|
1447 |
|
|
1448 |
/** |
/** |
1449 |
|
* Muting a sampler channel: |
1450 |
|
* SET CHANNEL MUTE <sampler-channel> <mute> |
1451 |
|
* |
1452 |
|
* @param pClient Pointer to client instance structure. |
1453 |
|
* @param iSamplerChannel Sampler channel number. |
1454 |
|
* @param iMute Sampler channel mute state as a boolean value, |
1455 |
|
* either 1 (one) to mute the channel or 0 (zero) |
1456 |
|
* to unmute the channel. |
1457 |
|
* |
1458 |
|
* @returns LSCP_OK on success, LSCP_FAILED otherwise. |
1459 |
|
*/ |
1460 |
|
lscp_status_t lscp_set_channel_mute ( lscp_client_t *pClient, int iSamplerChannel, int iMute ) |
1461 |
|
{ |
1462 |
|
char szQuery[LSCP_BUFSIZ]; |
1463 |
|
|
1464 |
|
if (iSamplerChannel < 0 || iMute < 0 || iMute > 1) |
1465 |
|
return LSCP_FAILED; |
1466 |
|
|
1467 |
|
sprintf(szQuery, "SET CHANNEL MUTE %d %d\r\n", iSamplerChannel, iMute); |
1468 |
|
return lscp_client_query(pClient, szQuery); |
1469 |
|
} |
1470 |
|
|
1471 |
|
|
1472 |
|
/** |
1473 |
|
* Soloing a sampler channel: |
1474 |
|
* SET CHANNEL SOLO <sampler-channel> <solo> |
1475 |
|
* |
1476 |
|
* @param pClient Pointer to client instance structure. |
1477 |
|
* @param iSamplerChannel Sampler channel number. |
1478 |
|
* @param iSolo Sampler channel solo state as a boolean value, |
1479 |
|
* either 1 (one) to solo the channel or 0 (zero) |
1480 |
|
* to unsolo the channel. |
1481 |
|
* |
1482 |
|
* @returns LSCP_OK on success, LSCP_FAILED otherwise. |
1483 |
|
*/ |
1484 |
|
lscp_status_t lscp_set_channel_solo ( lscp_client_t *pClient, int iSamplerChannel, int iSolo ) |
1485 |
|
{ |
1486 |
|
char szQuery[LSCP_BUFSIZ]; |
1487 |
|
|
1488 |
|
if (iSamplerChannel < 0 || iSolo < 0 || iSolo > 1) |
1489 |
|
return LSCP_FAILED; |
1490 |
|
|
1491 |
|
sprintf(szQuery, "SET CHANNEL SOLO %d %d\r\n", iSamplerChannel, iSolo); |
1492 |
|
return lscp_client_query(pClient, szQuery); |
1493 |
|
} |
1494 |
|
|
1495 |
|
|
1496 |
|
/** |
1497 |
* Resetting a sampler channel: |
* Resetting a sampler channel: |
1498 |
* RESET CHANNEL <sampler-channel> |
* RESET CHANNEL <sampler-channel> |
1499 |
* |
* |
1528 |
} |
} |
1529 |
|
|
1530 |
|
|
1531 |
|
/** |
1532 |
|
* Getting information about the server. |
1533 |
|
* GET SERVER INFO |
1534 |
|
* |
1535 |
|
* @param pClient Pointer to client instance structure. |
1536 |
|
* |
1537 |
|
* @returns A pointer to a @ref lscp_server_info_t structure, with all the |
1538 |
|
* information of the current connected server, or NULL in case of failure. |
1539 |
|
*/ |
1540 |
|
lscp_server_info_t *lscp_get_server_info ( lscp_client_t *pClient ) |
1541 |
|
{ |
1542 |
|
lscp_server_info_t *pServerInfo; |
1543 |
|
const char *pszResult; |
1544 |
|
const char *pszSeps = ":"; |
1545 |
|
const char *pszCrlf = "\r\n"; |
1546 |
|
char *pszToken; |
1547 |
|
char *pch; |
1548 |
|
|
1549 |
|
// Lock this section up. |
1550 |
|
lscp_mutex_lock(pClient->mutex); |
1551 |
|
|
1552 |
|
pServerInfo = &(pClient->server_info); |
1553 |
|
lscp_server_info_reset(pServerInfo); |
1554 |
|
|
1555 |
|
if (lscp_client_call(pClient, "GET SERVER INFO\r\n") == LSCP_OK) { |
1556 |
|
pszResult = lscp_client_get_result(pClient); |
1557 |
|
pszToken = lscp_strtok((char *) pszResult, pszSeps, &(pch)); |
1558 |
|
while (pszToken) { |
1559 |
|
if (strcasecmp(pszToken, "DESCRIPTION") == 0) { |
1560 |
|
pszToken = lscp_strtok(NULL, pszCrlf, &(pch)); |
1561 |
|
if (pszToken) |
1562 |
|
lscp_unquote_dup(&(pServerInfo->description), &pszToken); |
1563 |
|
} |
1564 |
|
else if (strcasecmp(pszToken, "VERSION") == 0) { |
1565 |
|
pszToken = lscp_strtok(NULL, pszCrlf, &(pch)); |
1566 |
|
if (pszToken) |
1567 |
|
lscp_unquote_dup(&(pServerInfo->version), &pszToken); |
1568 |
|
} |
1569 |
|
pszToken = lscp_strtok(NULL, pszSeps, &(pch)); |
1570 |
|
} |
1571 |
|
} |
1572 |
|
else pServerInfo = NULL; |
1573 |
|
|
1574 |
|
// Unlock this section down. |
1575 |
|
lscp_mutex_unlock(pClient->mutex); |
1576 |
|
|
1577 |
|
return pServerInfo; |
1578 |
|
} |
1579 |
|
|
1580 |
|
|
1581 |
// end of client.c |
// end of client.c |