164 |
|
|
165 |
pHost = gethostbyname(pszHost); |
pHost = gethostbyname(pszHost); |
166 |
if (pHost == NULL) { |
if (pHost == NULL) { |
167 |
lscp_socket_perror("lscp_client_create: gethostbyname"); |
lscp_socket_herror("lscp_client_create: gethostbyname"); |
168 |
return NULL; |
return NULL; |
169 |
} |
} |
170 |
|
|
271 |
// Initialize cached members. |
// Initialize cached members. |
272 |
pClient->audio_drivers = NULL; |
pClient->audio_drivers = NULL; |
273 |
pClient->midi_drivers = NULL; |
pClient->midi_drivers = NULL; |
274 |
|
pClient->audio_devices = NULL; |
275 |
|
pClient->midi_devices = NULL; |
276 |
pClient->engines = NULL; |
pClient->engines = NULL; |
277 |
|
pClient->channels = NULL; |
278 |
lscp_driver_info_init(&(pClient->audio_info)); |
lscp_driver_info_init(&(pClient->audio_info)); |
279 |
lscp_driver_info_init(&(pClient->midi_info)); |
lscp_driver_info_init(&(pClient->midi_info)); |
280 |
lscp_engine_info_init(&(pClient->engine_info)); |
lscp_engine_info_init(&(pClient->engine_info)); |
355 |
// Free available engine table. |
// Free available engine table. |
356 |
lscp_szsplit_destroy(pClient->audio_drivers); |
lscp_szsplit_destroy(pClient->audio_drivers); |
357 |
lscp_szsplit_destroy(pClient->midi_drivers); |
lscp_szsplit_destroy(pClient->midi_drivers); |
358 |
|
lscp_isplit_destroy(pClient->audio_devices); |
359 |
|
lscp_isplit_destroy(pClient->midi_devices); |
360 |
lscp_szsplit_destroy(pClient->engines); |
lscp_szsplit_destroy(pClient->engines); |
361 |
|
lscp_isplit_destroy(pClient->channels); |
362 |
// Make them null. |
// Make them null. |
363 |
pClient->audio_drivers = NULL; |
pClient->audio_drivers = NULL; |
364 |
pClient->midi_drivers = NULL; |
pClient->midi_drivers = NULL; |
469 |
cchQuery = strlen(pszQuery); |
cchQuery = strlen(pszQuery); |
470 |
if (send(pClient->tcp.sock, pszQuery, cchQuery, 0) < cchQuery) { |
if (send(pClient->tcp.sock, pszQuery, cchQuery, 0) < cchQuery) { |
471 |
lscp_socket_perror("lscp_client_query: send"); |
lscp_socket_perror("lscp_client_query: send"); |
472 |
|
pszResult = "Failure during send operation"; |
473 |
|
_lscp_client_set_result(pClient, pszResult, iErrno); |
474 |
lscp_mutex_unlock(pClient->mutex); |
lscp_mutex_unlock(pClient->mutex); |
475 |
return ret; |
return ret; |
476 |
} |
} |
537 |
} |
} |
538 |
else if (cchResult == 0) { |
else if (cchResult == 0) { |
539 |
// Fake a result message. |
// Fake a result message. |
|
pszResult = "Server terminated the connection"; |
|
540 |
ret = LSCP_QUIT; |
ret = LSCP_QUIT; |
541 |
|
pszResult = "Server terminated the connection"; |
542 |
|
iErrno = (int) ret; |
543 |
|
} else { |
544 |
|
// What's down? |
545 |
|
lscp_socket_perror("lscp_client_query: recv"); |
546 |
|
pszResult = "Failure during receive operation"; |
547 |
} |
} |
|
else lscp_socket_perror("lscp_client_query: recv"); |
|
548 |
} // Check if select has timed out. |
} // Check if select has timed out. |
549 |
else if (iSelect == 0) { |
else if (iSelect == 0) { |
550 |
// Fake a result message. |
// Fake a result message. |
|
pszResult = "Timeout during receive operation"; |
|
551 |
ret = LSCP_TIMEOUT; |
ret = LSCP_TIMEOUT; |
552 |
} |
pszResult = "Timeout during receive operation"; |
553 |
|
iErrno = (int) ret; |
554 |
|
} |
555 |
else lscp_socket_perror("lscp_client_query: select"); |
else lscp_socket_perror("lscp_client_query: select"); |
556 |
|
|
557 |
// Make the result official... |
// Make the result official... |
630 |
fprintf(stderr, "lscp_client_subscribe: %s\n", pszResult); |
fprintf(stderr, "lscp_client_subscribe: %s\n", pszResult); |
631 |
#endif |
#endif |
632 |
// Check for the session-id on "OK[sessid]" response. |
// Check for the session-id on "OK[sessid]" response. |
633 |
pszToken = lscp_strtok(pszResult, pszSeps, &(pch)); |
pszToken = lscp_strtok((char *) pszResult, pszSeps, &(pch)); |
634 |
if (pszToken && strcasecmp(pszToken, "OK") == 0) { |
if (pszToken && strcasecmp(pszToken, "OK") == 0) { |
635 |
pszToken = lscp_strtok(NULL, pszSeps, &(pch)); |
pszToken = lscp_strtok(NULL, pszSeps, &(pch)); |
636 |
if (pszToken) |
if (pszToken) |
742 |
|
|
743 |
|
|
744 |
/** |
/** |
745 |
|
* List current sampler channels number identifiers: |
746 |
|
* LIST CHANNELS |
747 |
|
* |
748 |
|
* @param pClient Pointer to client instance structure. |
749 |
|
* |
750 |
|
* @returns An array of the sampler channels identifiers as positive integers, |
751 |
|
* terminated with -1 on success, NULL otherwise. |
752 |
|
*/ |
753 |
|
int *lscp_list_channels ( lscp_client_t *pClient ) |
754 |
|
{ |
755 |
|
const char *pszSeps = ","; |
756 |
|
|
757 |
|
if (pClient == NULL) |
758 |
|
return NULL; |
759 |
|
|
760 |
|
if (pClient->channels) { |
761 |
|
lscp_isplit_destroy(pClient->channels); |
762 |
|
pClient->channels = NULL; |
763 |
|
} |
764 |
|
|
765 |
|
if (lscp_client_query(pClient, "LIST CHANNELS\r\n") == LSCP_OK) |
766 |
|
pClient->channels = lscp_isplit_create(lscp_client_get_result(pClient), pszSeps); |
767 |
|
|
768 |
|
return pClient->channels; |
769 |
|
} |
770 |
|
|
771 |
|
|
772 |
|
/** |
773 |
* Adding a new sampler channel: |
* Adding a new sampler channel: |
774 |
* ADD CHANNEL |
* ADD CHANNEL |
775 |
* |
* |
864 |
return NULL; |
return NULL; |
865 |
|
|
866 |
pszResult = lscp_client_get_result(pClient); |
pszResult = lscp_client_get_result(pClient); |
867 |
pszToken = lscp_strtok(pszResult, pszSeps, &(pch)); |
pszToken = lscp_strtok((char *) pszResult, pszSeps, &(pch)); |
868 |
while (pszToken) { |
while (pszToken) { |
869 |
if (strcasecmp(pszToken, "DESCRIPTION") == 0) { |
if (strcasecmp(pszToken, "DESCRIPTION") == 0) { |
870 |
pszToken = lscp_strtok(NULL, pszCrlf, &(pch)); |
pszToken = lscp_strtok(NULL, pszCrlf, &(pch)); |
914 |
return NULL; |
return NULL; |
915 |
|
|
916 |
pszResult = lscp_client_get_result(pClient); |
pszResult = lscp_client_get_result(pClient); |
917 |
pszToken = lscp_strtok(pszResult, pszSeps, &(pch)); |
pszToken = lscp_strtok((char *) pszResult, pszSeps, &(pch)); |
918 |
while (pszToken) { |
while (pszToken) { |
919 |
if (strcasecmp(pszToken, "ENGINE_NAME") == 0) { |
if (strcasecmp(pszToken, "ENGINE_NAME") == 0) { |
920 |
pszToken = lscp_strtok(NULL, pszCrlf, &(pch)); |
pszToken = lscp_strtok(NULL, pszCrlf, &(pch)); |
1067 |
sprintf(szQuery, "GET CHANNEL BUFFER_FILL %s %d\r\n", pszUsageType, iSamplerChannel); |
sprintf(szQuery, "GET CHANNEL BUFFER_FILL %s %d\r\n", pszUsageType, iSamplerChannel); |
1068 |
if (lscp_client_query(pClient, szQuery) == LSCP_OK) { |
if (lscp_client_query(pClient, szQuery) == LSCP_OK) { |
1069 |
pszResult = lscp_client_get_result(pClient); |
pszResult = lscp_client_get_result(pClient); |
1070 |
pszToken = lscp_strtok(pszResult, pszSeps, &(pch)); |
pszToken = lscp_strtok((char *) pszResult, pszSeps, &(pch)); |
1071 |
while (pszToken && iStream < pClient->iStreamCount) { |
while (pszToken && iStream < pClient->iStreamCount) { |
1072 |
if (*pszToken) { |
if (*pszToken) { |
1073 |
pBufferFill[iStream].stream_id = atol(pszToken); |
pBufferFill[iStream].stream_id = atol(pszToken); |