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-2005, 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 |
40 |
static void _lscp_client_evt_proc ( void *pvClient ) |
static void _lscp_client_evt_proc ( void *pvClient ) |
41 |
{ |
{ |
42 |
lscp_client_t *pClient = (lscp_client_t *) pvClient; |
lscp_client_t *pClient = (lscp_client_t *) pvClient; |
43 |
char achBuffer[LSCP_BUFSIZ]; |
|
44 |
int cchBuffer; |
fd_set fds; // File descriptor list for select(). |
45 |
|
int fd, fdmax; // Maximum file descriptor number. |
46 |
|
struct timeval tv; // For specifying a timeout value. |
47 |
|
int iSelect; // Holds select return status. |
48 |
|
int iTimeout; |
49 |
|
|
50 |
|
char achBuffer[LSCP_BUFSIZ]; |
51 |
|
int cchBuffer; |
52 |
const char *pszSeps = ":\r\n"; |
const char *pszSeps = ":\r\n"; |
53 |
char *pszToken; |
char * pszToken; |
54 |
char *pch; |
char * pch; |
55 |
int cchToken; |
int cchToken; |
56 |
lscp_event_t event; |
lscp_event_t event; |
57 |
|
|
58 |
#ifdef DEBUG |
#ifdef DEBUG |
60 |
#endif |
#endif |
61 |
|
|
62 |
while (pClient->evt.iState) { |
while (pClient->evt.iState) { |
63 |
|
|
64 |
|
// Prepare for waiting on select... |
65 |
|
fd = (int) pClient->evt.sock; |
66 |
|
FD_ZERO(&fds); |
67 |
|
FD_SET((unsigned int) fd, &fds); |
68 |
|
fdmax = fd; |
69 |
|
|
70 |
|
// Use the timeout (x10) select feature ... |
71 |
|
iTimeout = 10 * pClient->iTimeout; |
72 |
|
if (iTimeout > 1000) { |
73 |
|
tv.tv_sec = iTimeout / 1000; |
74 |
|
iTimeout -= tv.tv_sec * 1000; |
75 |
|
} |
76 |
|
else tv.tv_sec = 0; |
77 |
|
tv.tv_usec = iTimeout * 1000; |
78 |
|
|
79 |
// Wait for event... |
// Wait for event... |
80 |
cchBuffer = recv(pClient->evt.sock, achBuffer, sizeof(achBuffer), 0); |
iSelect = select(fdmax + 1, &fds, NULL, NULL, &tv); |
81 |
if (cchBuffer > 0) { |
if (iSelect > 0 && FD_ISSET(fd, &fds)) { |
82 |
// Make sure received buffer it's null terminated. |
// May recv now... |
83 |
achBuffer[cchBuffer] = (char) 0; |
cchBuffer = recv(pClient->evt.sock, achBuffer, sizeof(achBuffer), 0); |
84 |
// Parse for the notification event message... |
if (cchBuffer > 0) { |
85 |
pszToken = lscp_strtok(achBuffer, pszSeps, &(pch)); // Have "NOTIFY". |
// Make sure received buffer it's null terminated. |
86 |
if (strcasecmp(pszToken, "NOTIFY") == 0) { |
achBuffer[cchBuffer] = (char) 0; |
87 |
pszToken = lscp_strtok(NULL, pszSeps, &(pch)); |
// Parse for the notification event message... |
88 |
event = lscp_event_from_text(pszToken); |
pszToken = lscp_strtok(achBuffer, pszSeps, &(pch)); // Have "NOTIFY". |
89 |
// And pick the rest of data... |
if (strcasecmp(pszToken, "NOTIFY") == 0) { |
90 |
pszToken = lscp_strtok(NULL, pszSeps, &(pch)); |
pszToken = lscp_strtok(NULL, pszSeps, &(pch)); |
91 |
cchToken = (pszToken == NULL ? 0 : strlen(pszToken)); |
event = lscp_event_from_text(pszToken); |
92 |
// Double-check if we're really up to it... |
// And pick the rest of data... |
93 |
if (pClient->events & event) { |
pszToken = lscp_strtok(NULL, pszSeps, &(pch)); |
94 |
// Invoke the client event callback... |
cchToken = (pszToken == NULL ? 0 : strlen(pszToken)); |
95 |
if ((*pClient->pfnCallback)( |
// Double-check if we're really up to it... |
96 |
pClient, |
if (pClient->events & event) { |
97 |
event, |
// Invoke the client event callback... |
98 |
pszToken, |
if ((*pClient->pfnCallback)( |
99 |
cchToken, |
pClient, |
100 |
pClient->pvData) != LSCP_OK) { |
event, |
101 |
pClient->evt.iState = 0; |
pszToken, |
102 |
|
cchToken, |
103 |
|
pClient->pvData) != LSCP_OK) { |
104 |
|
pClient->evt.iState = 0; |
105 |
|
} |
106 |
} |
} |
107 |
} |
} |
108 |
|
} else { |
109 |
|
lscp_socket_perror("_lscp_client_evt_proc: recv"); |
110 |
|
pClient->evt.iState = 0; |
111 |
} |
} |
112 |
} else { |
} // Check if select has in error. |
113 |
lscp_socket_perror("_lscp_client_evt_proc: recv"); |
else if (iSelect < 0) { |
114 |
|
lscp_socket_perror("_lscp_client_evt_proc: select"); |
115 |
pClient->evt.iState = 0; |
pClient->evt.iState = 0; |
116 |
} |
} |
117 |
|
|
118 |
|
// Finally, always signal the event. |
119 |
|
lscp_cond_signal(pClient->cond); |
120 |
} |
} |
121 |
|
|
122 |
#ifdef DEBUG |
#ifdef DEBUG |
164 |
closesocket(sock); |
closesocket(sock); |
165 |
return LSCP_FAILED; |
return LSCP_FAILED; |
166 |
} |
} |
167 |
|
|
168 |
// Set our socket agent struct... |
// Set our socket agent struct... |
169 |
lscp_socket_agent_init(&(pClient->evt), sock, &addr, cAddr); |
lscp_socket_agent_init(&(pClient->evt), sock, &addr, cAddr); |
170 |
|
|
171 |
// And finally the service thread... |
// And finally the service thread... |
172 |
return lscp_socket_agent_start(&(pClient->evt), _lscp_client_evt_proc, pClient, 0); |
return lscp_socket_agent_start(&(pClient->evt), _lscp_client_evt_proc, pClient, 0); |
173 |
} |
} |
196 |
return LSCP_FAILED; |
return LSCP_FAILED; |
197 |
} |
} |
198 |
|
|
199 |
|
// Wait on response. |
200 |
|
lscp_cond_wait(pClient->cond, pClient->mutex); |
201 |
|
|
202 |
// Update as naively as we can... |
// Update as naively as we can... |
203 |
if (iSubscribe) |
if (iSubscribe) |
204 |
pClient->events |= event; |
pClient->events |= event; |
327 |
pClient->midi_devices = NULL; |
pClient->midi_devices = NULL; |
328 |
pClient->engines = NULL; |
pClient->engines = NULL; |
329 |
pClient->channels = NULL; |
pClient->channels = NULL; |
330 |
lscp_driver_info_init(&(pClient->audio_info)); |
lscp_driver_info_init(&(pClient->audio_driver_info)); |
331 |
lscp_driver_info_init(&(pClient->midi_info)); |
lscp_driver_info_init(&(pClient->midi_driver_info)); |
332 |
|
lscp_device_info_init(&(pClient->audio_device_info)); |
333 |
|
lscp_device_info_init(&(pClient->midi_device_info)); |
334 |
lscp_param_info_init(&(pClient->audio_param_info)); |
lscp_param_info_init(&(pClient->audio_param_info)); |
335 |
lscp_param_info_init(&(pClient->midi_param_info)); |
lscp_param_info_init(&(pClient->midi_param_info)); |
336 |
|
lscp_device_port_info_init(&(pClient->audio_channel_info)); |
337 |
|
lscp_device_port_info_init(&(pClient->midi_port_info)); |
338 |
|
lscp_param_info_init(&(pClient->audio_channel_param_info)); |
339 |
|
lscp_param_info_init(&(pClient->midi_port_param_info)); |
340 |
lscp_engine_info_init(&(pClient->engine_info)); |
lscp_engine_info_init(&(pClient->engine_info)); |
341 |
lscp_channel_info_init(&(pClient->channel_info)); |
lscp_channel_info_init(&(pClient->channel_info)); |
342 |
// Initialize error stuff. |
// Initialize error stuff. |
350 |
|
|
351 |
// Initialize the transaction mutex. |
// Initialize the transaction mutex. |
352 |
lscp_mutex_init(pClient->mutex); |
lscp_mutex_init(pClient->mutex); |
353 |
|
lscp_cond_init(pClient->cond); |
354 |
|
|
355 |
// Finally we've some success... |
// Finally we've some success... |
356 |
return pClient; |
return pClient; |
396 |
|
|
397 |
// Lock this section up. |
// Lock this section up. |
398 |
lscp_mutex_lock(pClient->mutex); |
lscp_mutex_lock(pClient->mutex); |
399 |
|
|
400 |
// Free up all cached members. |
// Free up all cached members. |
401 |
lscp_channel_info_reset(&(pClient->channel_info)); |
lscp_channel_info_free(&(pClient->channel_info)); |
402 |
lscp_engine_info_reset(&(pClient->engine_info)); |
lscp_engine_info_free(&(pClient->engine_info)); |
403 |
lscp_param_info_reset(&(pClient->midi_param_info)); |
lscp_param_info_free(&(pClient->midi_port_param_info)); |
404 |
lscp_param_info_reset(&(pClient->audio_param_info)); |
lscp_param_info_free(&(pClient->audio_channel_param_info)); |
405 |
lscp_driver_info_reset(&(pClient->midi_info)); |
lscp_device_port_info_free(&(pClient->midi_port_info)); |
406 |
lscp_driver_info_reset(&(pClient->audio_info)); |
lscp_device_port_info_free(&(pClient->audio_channel_info)); |
407 |
|
lscp_param_info_free(&(pClient->midi_param_info)); |
408 |
|
lscp_param_info_free(&(pClient->audio_param_info)); |
409 |
|
lscp_device_info_free(&(pClient->midi_device_info)); |
410 |
|
lscp_device_info_free(&(pClient->audio_device_info)); |
411 |
|
lscp_driver_info_free(&(pClient->midi_driver_info)); |
412 |
|
lscp_driver_info_free(&(pClient->audio_driver_info)); |
413 |
// Free available engine table. |
// Free available engine table. |
414 |
lscp_szsplit_destroy(pClient->audio_drivers); |
lscp_szsplit_destroy(pClient->audio_drivers); |
415 |
lscp_szsplit_destroy(pClient->midi_drivers); |
lscp_szsplit_destroy(pClient->midi_drivers); |
437 |
// Last but not least, free good ol'transaction mutex. |
// Last but not least, free good ol'transaction mutex. |
438 |
lscp_mutex_unlock(pClient->mutex); |
lscp_mutex_unlock(pClient->mutex); |
439 |
lscp_mutex_destroy(pClient->mutex); |
lscp_mutex_destroy(pClient->mutex); |
440 |
|
lscp_cond_destroy(pClient->cond); |
441 |
|
|
442 |
free(pClient); |
free(pClient); |
443 |
|
|
500 |
lscp_status_t lscp_client_query ( lscp_client_t *pClient, const char *pszQuery ) |
lscp_status_t lscp_client_query ( lscp_client_t *pClient, const char *pszQuery ) |
501 |
{ |
{ |
502 |
lscp_status_t ret; |
lscp_status_t ret; |
503 |
|
|
504 |
// Lock this section up. |
// Lock this section up. |
505 |
lscp_mutex_lock(pClient->mutex); |
lscp_mutex_lock(pClient->mutex); |
506 |
|
|
507 |
// Just make the now guarded call. |
// Just make the now guarded call. |
508 |
ret = lscp_client_call(pClient, pszQuery); |
ret = lscp_client_call(pClient, pszQuery); |
509 |
|
|
510 |
// Unlock this section down. |
// Unlock this section down. |
511 |
lscp_mutex_unlock(pClient->mutex); |
lscp_mutex_unlock(pClient->mutex); |
512 |
|
|
513 |
return ret; |
return ret; |
514 |
} |
} |
515 |
|
|
553 |
|
|
554 |
/** |
/** |
555 |
* Register frontend for receiving event messages: |
* Register frontend for receiving event messages: |
556 |
* SUBSCRIBE CHANNELS | VOICE_COUNT | STREAM_COUNT | BUFFER_FILL |
* SUBSCRIBE CHANNEL_COUNT | VOICE_COUNT | STREAM_COUNT | BUFFER_FILL |
557 |
* | CHANNEL_INFO | MISCELLANEOUS |
* | CHANNEL_INFO | MISCELLANEOUS |
558 |
* |
* |
559 |
* @param pClient Pointer to client instance structure. |
* @param pClient Pointer to client instance structure. |
574 |
// If applicable, start the alternate connection... |
// If applicable, start the alternate connection... |
575 |
if (pClient->events == LSCP_EVENT_NONE) |
if (pClient->events == LSCP_EVENT_NONE) |
576 |
ret = _lscp_client_evt_connect(pClient); |
ret = _lscp_client_evt_connect(pClient); |
577 |
|
|
578 |
// Send the subscription commands. |
// Send the subscription commands. |
579 |
if (ret == LSCP_OK && (events & LSCP_EVENT_CHANNELS)) |
if (ret == LSCP_OK && (events & LSCP_EVENT_CHANNEL_COUNT)) |
580 |
ret = _lscp_client_evt_request(pClient, 1, LSCP_EVENT_CHANNELS); |
ret = _lscp_client_evt_request(pClient, 1, LSCP_EVENT_CHANNEL_COUNT); |
581 |
if (ret == LSCP_OK && (events & LSCP_EVENT_VOICE_COUNT)) |
if (ret == LSCP_OK && (events & LSCP_EVENT_VOICE_COUNT)) |
582 |
ret = _lscp_client_evt_request(pClient, 1, LSCP_EVENT_VOICE_COUNT); |
ret = _lscp_client_evt_request(pClient, 1, LSCP_EVENT_VOICE_COUNT); |
583 |
if (ret == LSCP_OK && (events & LSCP_EVENT_STREAM_COUNT)) |
if (ret == LSCP_OK && (events & LSCP_EVENT_STREAM_COUNT)) |
598 |
|
|
599 |
/** |
/** |
600 |
* Deregister frontend from receiving UDP event messages anymore: |
* Deregister frontend from receiving UDP event messages anymore: |
601 |
* SUBSCRIBE CHANNELS | VOICE_COUNT | STREAM_COUNT | BUFFER_FILL |
* SUBSCRIBE CHANNEL_COUNT | VOICE_COUNT | STREAM_COUNT | BUFFER_FILL |
602 |
* | CHANNEL_INFO | MISCELLANEOUS |
* | CHANNEL_INFO | MISCELLANEOUS |
603 |
* |
* |
604 |
* @param pClient Pointer to client instance structure. |
* @param pClient Pointer to client instance structure. |
617 |
lscp_mutex_lock(pClient->mutex); |
lscp_mutex_lock(pClient->mutex); |
618 |
|
|
619 |
// Send the unsubscription commands. |
// Send the unsubscription commands. |
620 |
if (ret == LSCP_OK && (events & LSCP_EVENT_CHANNELS)) |
if (ret == LSCP_OK && (events & LSCP_EVENT_CHANNEL_COUNT)) |
621 |
ret = _lscp_client_evt_request(pClient, 0, LSCP_EVENT_CHANNELS); |
ret = _lscp_client_evt_request(pClient, 0, LSCP_EVENT_CHANNEL_COUNT); |
622 |
if (ret == LSCP_OK && (events & LSCP_EVENT_VOICE_COUNT)) |
if (ret == LSCP_OK && (events & LSCP_EVENT_VOICE_COUNT)) |
623 |
ret = _lscp_client_evt_request(pClient, 0, LSCP_EVENT_VOICE_COUNT); |
ret = _lscp_client_evt_request(pClient, 0, LSCP_EVENT_VOICE_COUNT); |
624 |
if (ret == LSCP_OK && (events & LSCP_EVENT_STREAM_COUNT)) |
if (ret == LSCP_OK && (events & LSCP_EVENT_STREAM_COUNT)) |
641 |
} |
} |
642 |
|
|
643 |
|
|
644 |
|
/** |
645 |
|
* Getting current subscribed events. |
646 |
|
* |
647 |
|
* @param pClient Pointer to client instance structure. |
648 |
|
* |
649 |
|
* @returns The current subscrived bit-wise OR'ed event flags. |
650 |
|
*/ |
651 |
|
lscp_event_t lscp_client_get_events ( lscp_client_t *pClient ) |
652 |
|
{ |
653 |
|
if (pClient == NULL) |
654 |
|
return LSCP_EVENT_NONE; |
655 |
|
|
656 |
|
return pClient->events; |
657 |
|
} |
658 |
|
|
659 |
|
|
660 |
//------------------------------------------------------------------------- |
//------------------------------------------------------------------------- |
661 |
// Client command protocol functions. |
// Client command protocol functions. |
662 |
|
|
769 |
|
|
770 |
if (pClient == NULL) |
if (pClient == NULL) |
771 |
return NULL; |
return NULL; |
772 |
|
|
773 |
// Lock this section up. |
// Lock this section up. |
774 |
lscp_mutex_lock(pClient->mutex); |
lscp_mutex_lock(pClient->mutex); |
775 |
|
|
806 |
|
|
807 |
if (lscp_client_call(pClient, "ADD CHANNEL\r\n") == LSCP_OK) |
if (lscp_client_call(pClient, "ADD CHANNEL\r\n") == LSCP_OK) |
808 |
iSamplerChannel = atoi(lscp_client_get_result(pClient)); |
iSamplerChannel = atoi(lscp_client_get_result(pClient)); |
809 |
|
|
810 |
// Unlock this section down. |
// Unlock this section down. |
811 |
lscp_mutex_unlock(pClient->mutex); |
lscp_mutex_unlock(pClient->mutex); |
812 |
|
|
836 |
|
|
837 |
|
|
838 |
/** |
/** |
839 |
* Getting all available engines: |
* Getting all available engines count: |
840 |
* GET AVAILABLE_ENGINES |
* GET AVAILABLE_ENGINES |
841 |
* |
* |
842 |
* @param pClient Pointer to client instance structure. |
* @param pClient Pointer to client instance structure. |
843 |
* |
* |
844 |
|
* @returns The current total number of sampler engines on success, |
845 |
|
* -1 otherwise. |
846 |
|
*/ |
847 |
|
int lscp_get_available_engines ( lscp_client_t *pClient ) |
848 |
|
{ |
849 |
|
int iAvailableEngines = -1; |
850 |
|
|
851 |
|
// Lock this section up. |
852 |
|
lscp_mutex_lock(pClient->mutex); |
853 |
|
|
854 |
|
if (lscp_client_call(pClient, "GET AVAILABLE_ENGINES\r\n") == LSCP_OK) |
855 |
|
iAvailableEngines = atoi(lscp_client_get_result(pClient)); |
856 |
|
|
857 |
|
// Unlock this section down. |
858 |
|
lscp_mutex_unlock(pClient->mutex); |
859 |
|
|
860 |
|
return iAvailableEngines; |
861 |
|
} |
862 |
|
|
863 |
|
|
864 |
|
/** |
865 |
|
* Getting all available engines: |
866 |
|
* LIST AVAILABLE_ENGINES |
867 |
|
* |
868 |
|
* @param pClient Pointer to client instance structure. |
869 |
|
* |
870 |
* @returns A NULL terminated array of engine name strings, |
* @returns A NULL terminated array of engine name strings, |
871 |
* or NULL in case of failure. |
* or NULL in case of failure. |
872 |
*/ |
*/ |
873 |
const char **lscp_get_available_engines ( lscp_client_t *pClient ) |
const char **lscp_list_available_engines ( lscp_client_t *pClient ) |
874 |
{ |
{ |
875 |
const char *pszSeps = ","; |
const char *pszSeps = ","; |
876 |
|
|
882 |
pClient->engines = NULL; |
pClient->engines = NULL; |
883 |
} |
} |
884 |
|
|
885 |
if (lscp_client_call(pClient, "GET AVAILABLE_ENGINES\r\n") == LSCP_OK) |
if (lscp_client_call(pClient, "LIST AVAILABLE_ENGINES\r\n") == LSCP_OK) |
886 |
pClient->engines = lscp_szsplit_create(lscp_client_get_result(pClient), pszSeps); |
pClient->engines = lscp_szsplit_create(lscp_client_get_result(pClient), pszSeps); |
887 |
|
|
888 |
// Unlock this section down. |
// Unlock this section down. |
929 |
if (strcasecmp(pszToken, "DESCRIPTION") == 0) { |
if (strcasecmp(pszToken, "DESCRIPTION") == 0) { |
930 |
pszToken = lscp_strtok(NULL, pszCrlf, &(pch)); |
pszToken = lscp_strtok(NULL, pszCrlf, &(pch)); |
931 |
if (pszToken) |
if (pszToken) |
932 |
pEngineInfo->description = lscp_unquote(&pszToken, 1); |
lscp_unquote_dup(&(pEngineInfo->description), &pszToken); |
933 |
} |
} |
934 |
else if (strcasecmp(pszToken, "VERSION") == 0) { |
else if (strcasecmp(pszToken, "VERSION") == 0) { |
935 |
pszToken = lscp_strtok(NULL, pszCrlf, &(pch)); |
pszToken = lscp_strtok(NULL, pszCrlf, &(pch)); |
936 |
if (pszToken) |
if (pszToken) |
937 |
pEngineInfo->version = lscp_unquote(&pszToken, 1); |
lscp_unquote_dup(&(pEngineInfo->version), &pszToken); |
938 |
} |
} |
939 |
pszToken = lscp_strtok(NULL, pszSeps, &(pch)); |
pszToken = lscp_strtok(NULL, pszSeps, &(pch)); |
940 |
} |
} |
941 |
} |
} |
942 |
else pEngineInfo = NULL; |
else pEngineInfo = NULL; |
943 |
|
|
944 |
// Unlock this section down. |
// Unlock this section down. |
945 |
lscp_mutex_unlock(pClient->mutex); |
lscp_mutex_unlock(pClient->mutex); |
946 |
|
|
973 |
|
|
974 |
// Lock this section up. |
// Lock this section up. |
975 |
lscp_mutex_lock(pClient->mutex); |
lscp_mutex_lock(pClient->mutex); |
976 |
|
|
977 |
pChannelInfo = &(pClient->channel_info); |
pChannelInfo = &(pClient->channel_info); |
978 |
lscp_channel_info_reset(pChannelInfo); |
lscp_channel_info_reset(pChannelInfo); |
979 |
|
|
985 |
if (strcasecmp(pszToken, "ENGINE_NAME") == 0) { |
if (strcasecmp(pszToken, "ENGINE_NAME") == 0) { |
986 |
pszToken = lscp_strtok(NULL, pszCrlf, &(pch)); |
pszToken = lscp_strtok(NULL, pszCrlf, &(pch)); |
987 |
if (pszToken) |
if (pszToken) |
988 |
pChannelInfo->engine_name = lscp_unquote(&pszToken, 1); |
lscp_unquote_dup(&(pChannelInfo->engine_name), &pszToken); |
989 |
} |
} |
990 |
else if (strcasecmp(pszToken, "AUDIO_OUTPUT_DEVICE") == 0) { |
else if (strcasecmp(pszToken, "AUDIO_OUTPUT_DEVICE") == 0) { |
991 |
pszToken = lscp_strtok(NULL, pszCrlf, &(pch)); |
pszToken = lscp_strtok(NULL, pszCrlf, &(pch)); |
999 |
} |
} |
1000 |
else if (strcasecmp(pszToken, "AUDIO_OUTPUT_ROUTING") == 0) { |
else if (strcasecmp(pszToken, "AUDIO_OUTPUT_ROUTING") == 0) { |
1001 |
pszToken = lscp_strtok(NULL, pszCrlf, &(pch)); |
pszToken = lscp_strtok(NULL, pszCrlf, &(pch)); |
1002 |
if (pszToken) |
if (pszToken) { |
1003 |
|
if (pChannelInfo->audio_routing) |
1004 |
|
lscp_szsplit_destroy(pChannelInfo->audio_routing); |
1005 |
pChannelInfo->audio_routing = lscp_szsplit_create(pszToken, ","); |
pChannelInfo->audio_routing = lscp_szsplit_create(pszToken, ","); |
1006 |
|
} |
1007 |
} |
} |
1008 |
else if (strcasecmp(pszToken, "INSTRUMENT_FILE") == 0) { |
else if (strcasecmp(pszToken, "INSTRUMENT_FILE") == 0) { |
1009 |
pszToken = lscp_strtok(NULL, pszCrlf, &(pch)); |
pszToken = lscp_strtok(NULL, pszCrlf, &(pch)); |
1010 |
if (pszToken) |
if (pszToken) |
1011 |
pChannelInfo->instrument_file = lscp_unquote(&pszToken, 1); |
lscp_unquote_dup(&(pChannelInfo->instrument_file), &pszToken); |
1012 |
} |
} |
1013 |
else if (strcasecmp(pszToken, "INSTRUMENT_NR") == 0) { |
else if (strcasecmp(pszToken, "INSTRUMENT_NR") == 0) { |
1014 |
pszToken = lscp_strtok(NULL, pszCrlf, &(pch)); |
pszToken = lscp_strtok(NULL, pszCrlf, &(pch)); |
1015 |
if (pszToken) |
if (pszToken) |
1016 |
pChannelInfo->instrument_nr = atoi(lscp_ltrim(pszToken)); |
pChannelInfo->instrument_nr = atoi(lscp_ltrim(pszToken)); |
1017 |
} |
} |
1018 |
|
else if (strcasecmp(pszToken, "INSTRUMENT_NAME") == 0) { |
1019 |
|
pszToken = lscp_strtok(NULL, pszCrlf, &(pch)); |
1020 |
|
if (pszToken) |
1021 |
|
lscp_unquote_dup(&(pChannelInfo->instrument_name), &pszToken); |
1022 |
|
} |
1023 |
else if (strcasecmp(pszToken, "INSTRUMENT_STATUS") == 0) { |
else if (strcasecmp(pszToken, "INSTRUMENT_STATUS") == 0) { |
1024 |
pszToken = lscp_strtok(NULL, pszCrlf, &(pch)); |
pszToken = lscp_strtok(NULL, pszCrlf, &(pch)); |
1025 |
if (pszToken) |
if (pszToken) |
1037 |
} |
} |
1038 |
else if (strcasecmp(pszToken, "MIDI_INPUT_CHANNEL") == 0) { |
else if (strcasecmp(pszToken, "MIDI_INPUT_CHANNEL") == 0) { |
1039 |
pszToken = lscp_strtok(NULL, pszCrlf, &(pch)); |
pszToken = lscp_strtok(NULL, pszCrlf, &(pch)); |
1040 |
if (pszToken) |
if (pszToken) { |
1041 |
pChannelInfo->midi_channel = atoi(lscp_ltrim(pszToken)); |
pszToken = lscp_ltrim(pszToken); |
1042 |
|
if (strcasecmp(pszToken, "ALL") == 0) |
1043 |
|
pChannelInfo->midi_channel = LSCP_MIDI_CHANNEL_ALL; |
1044 |
|
else |
1045 |
|
pChannelInfo->midi_channel = atoi(pszToken); |
1046 |
|
} |
1047 |
} |
} |
1048 |
else if (strcasecmp(pszToken, "VOLUME") == 0) { |
else if (strcasecmp(pszToken, "VOLUME") == 0) { |
1049 |
pszToken = lscp_strtok(NULL, pszCrlf, &(pch)); |
pszToken = lscp_strtok(NULL, pszCrlf, &(pch)); |
1054 |
} |
} |
1055 |
} |
} |
1056 |
else pChannelInfo = NULL; |
else pChannelInfo = NULL; |
1057 |
|
|
1058 |
// Unlock this section up. |
// Unlock this section up. |
1059 |
lscp_mutex_unlock(pClient->mutex); |
lscp_mutex_unlock(pClient->mutex); |
1060 |
|
|
1247 |
else while (iStream < pClient->iStreamCount) |
else while (iStream < pClient->iStreamCount) |
1248 |
pBufferFill[iStream++].stream_usage = 0; |
pBufferFill[iStream++].stream_usage = 0; |
1249 |
} |
} |
1250 |
|
|
1251 |
// Unlock this section down. |
// Unlock this section down. |
1252 |
lscp_mutex_unlock(pClient->mutex); |
lscp_mutex_unlock(pClient->mutex); |
1253 |
|
|
1313 |
if (iSamplerChannel < 0 || iAudioOut < 0 || iAudioIn < 0) |
if (iSamplerChannel < 0 || iAudioOut < 0 || iAudioIn < 0) |
1314 |
return LSCP_FAILED; |
return LSCP_FAILED; |
1315 |
|
|
1316 |
sprintf(szQuery, "SET CHANNEL AUDIO_OUTPUT_CHANNELS %d %d %d\r\n", iSamplerChannel, iAudioOut, iAudioIn); |
sprintf(szQuery, "SET CHANNEL AUDIO_OUTPUT_CHANNEL %d %d %d\r\n", iSamplerChannel, iAudioOut, iAudioIn); |
1317 |
return lscp_client_query(pClient, szQuery); |
return lscp_client_query(pClient, szQuery); |
1318 |
} |
} |
1319 |
|
|
1388 |
* |
* |
1389 |
* @param pClient Pointer to client instance structure. |
* @param pClient Pointer to client instance structure. |
1390 |
* @param iSamplerChannel Sampler channel number. |
* @param iSamplerChannel Sampler channel number. |
1391 |
* @param iMidiChannel MIDI channel number to listen (1-16) or |
* @param iMidiChannel MIDI channel address number to listen (0-15) or |
1392 |
* zero (0) to listen on all channels. |
* LSCP_MIDI_CHANNEL_ALL (16) to listen on all channels. |
1393 |
* |
* |
1394 |
* @returns LSCP_OK on success, LSCP_FAILED otherwise. |
* @returns LSCP_OK on success, LSCP_FAILED otherwise. |
1395 |
*/ |
*/ |
1400 |
if (iSamplerChannel < 0 || iMidiChannel < 0 || iMidiChannel > 16) |
if (iSamplerChannel < 0 || iMidiChannel < 0 || iMidiChannel > 16) |
1401 |
return LSCP_FAILED; |
return LSCP_FAILED; |
1402 |
|
|
1403 |
if (iMidiChannel > 0) |
if (iMidiChannel == LSCP_MIDI_CHANNEL_ALL) |
|
sprintf(szQuery, "SET CHANNEL MIDI_INPUT_CHANNEL %d %d\r\n", iSamplerChannel, iMidiChannel); |
|
|
else |
|
1404 |
sprintf(szQuery, "SET CHANNEL MIDI_INPUT_CHANNEL %d ALL\r\n", iSamplerChannel); |
sprintf(szQuery, "SET CHANNEL MIDI_INPUT_CHANNEL %d ALL\r\n", iSamplerChannel); |
1405 |
|
else |
1406 |
|
sprintf(szQuery, "SET CHANNEL MIDI_INPUT_CHANNEL %d %d\r\n", iSamplerChannel, iMidiChannel); |
1407 |
return lscp_client_query(pClient, szQuery); |
return lscp_client_query(pClient, szQuery); |
1408 |
} |
} |
1409 |
|
|
1453 |
} |
} |
1454 |
|
|
1455 |
|
|
1456 |
|
/** |
1457 |
|
* Resetting the sampler: |
1458 |
|
* RESET |
1459 |
|
* |
1460 |
|
* @param pClient Pointer to client instance structure. |
1461 |
|
* |
1462 |
|
* @returns LSCP_OK on success, LSCP_FAILED otherwise. |
1463 |
|
*/ |
1464 |
|
lscp_status_t lscp_reset_sampler ( lscp_client_t *pClient ) |
1465 |
|
{ |
1466 |
|
return lscp_client_query(pClient, "RESET\r\n"); |
1467 |
|
} |
1468 |
|
|
1469 |
|
|
1470 |
// end of client.c |
// end of client.c |