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... |
741 |
} |
} |
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 |