28 |
|
|
29 |
// Local prototypes. |
// Local prototypes. |
30 |
|
|
31 |
static void _lscp_client_set_result (lscp_client_t *pClient, char *pszResult, int iErrno); |
static void _lscp_client_evt_proc (void *pvClient); |
|
static void _lscp_client_udp_proc (void *pvClient); |
|
32 |
|
|
33 |
|
static lscp_status_t _lscp_client_evt_connect (lscp_client_t *pClient); |
34 |
//------------------------------------------------------------------------- |
static lscp_status_t _lscp_client_evt_request (lscp_client_t *pClient, int iSubscribe, lscp_event_t event); |
|
// Helper functions. |
|
|
|
|
|
// Result buffer internal settler. |
|
|
static void _lscp_client_set_result ( lscp_client_t *pClient, char *pszResult, int iErrno ) |
|
|
{ |
|
|
if (pClient->pszResult) |
|
|
free(pClient->pszResult); |
|
|
pClient->pszResult = NULL; |
|
|
|
|
|
pClient->iErrno = iErrno; |
|
|
|
|
|
if (pszResult) |
|
|
pClient->pszResult = strdup(lscp_ltrim(pszResult)); |
|
|
} |
|
35 |
|
|
36 |
|
|
37 |
//------------------------------------------------------------------------- |
//------------------------------------------------------------------------- |
38 |
// UDP service (datagram oriented). |
// Event service (datagram oriented). |
39 |
|
|
40 |
static void _lscp_client_udp_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 |
struct sockaddr_in addr; |
|
44 |
int cAddr; |
fd_set fds; // File descriptor list for select(). |
45 |
char achBuffer[LSCP_BUFSIZ]; |
int fd, fdmax; // Maximum file descriptor number. |
46 |
int cchBuffer; |
struct timeval tv; // For specifying a timeout value. |
47 |
const char *pszSeps = " \r\n"; |
int iSelect; // Holds select return status. |
48 |
char *pszToken; |
int iTimeout; |
49 |
char *pch; |
|
50 |
|
char achBuffer[LSCP_BUFSIZ]; |
51 |
|
int cchBuffer; |
52 |
|
const char *pszSeps = ":\r\n"; |
53 |
|
char * pszToken; |
54 |
|
char * pch; |
55 |
|
int cchToken; |
56 |
|
lscp_event_t event; |
57 |
|
|
58 |
#ifdef DEBUG |
#ifdef DEBUG |
59 |
fprintf(stderr, "_lscp_client_udp_proc: Client waiting for events.\n"); |
fprintf(stderr, "_lscp_client_evt_proc: Client waiting for events.\n"); |
60 |
#endif |
#endif |
61 |
|
|
62 |
while (pClient->udp.iState) { |
while (pClient->evt.iState) { |
63 |
cAddr = sizeof(struct sockaddr_in); |
|
64 |
cchBuffer = recvfrom(pClient->udp.sock, achBuffer, sizeof(achBuffer), 0, (struct sockaddr *) &addr, &cAddr); |
// Prepare for waiting on select... |
65 |
if (cchBuffer > 0) { |
fd = (int) pClient->evt.sock; |
66 |
#ifdef DEBUG |
FD_ZERO(&fds); |
67 |
lscp_socket_trace("_lscp_client_udp_proc: recvfrom", &addr, achBuffer, cchBuffer); |
FD_SET((unsigned int) fd, &fds); |
68 |
#endif |
fdmax = fd; |
69 |
if (strncasecmp(achBuffer, "PING ", 5) == 0) { |
|
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... |
80 |
|
iSelect = select(fdmax + 1, &fds, NULL, NULL, &tv); |
81 |
|
if (iSelect > 0 && FD_ISSET(fd, &fds)) { |
82 |
|
// May recv now... |
83 |
|
cchBuffer = recv(pClient->evt.sock, achBuffer, sizeof(achBuffer), 0); |
84 |
|
if (cchBuffer > 0) { |
85 |
// Make sure received buffer it's null terminated. |
// Make sure received buffer it's null terminated. |
86 |
achBuffer[cchBuffer] = (char) 0; |
achBuffer[cchBuffer] = (char) 0; |
87 |
lscp_strtok(achBuffer, pszSeps, &(pch)); // Skip "PING" |
// Parse for the notification event message... |
88 |
lscp_strtok(NULL, pszSeps, &(pch)); // Skip port (must be the same as in addr) |
pszToken = lscp_strtok(achBuffer, pszSeps, &(pch)); // Have "NOTIFY". |
89 |
pszToken = lscp_strtok(NULL, pszSeps, &(pch)); // Have session-id. |
if (strcasecmp(pszToken, "NOTIFY") == 0) { |
90 |
if (pszToken) { |
pszToken = lscp_strtok(NULL, pszSeps, &(pch)); |
91 |
// Set now client's session-id, if not already |
event = lscp_event_from_text(pszToken); |
92 |
if (pClient->sessid == NULL) |
// And pick the rest of data... |
93 |
pClient->sessid = strdup(pszToken); |
pszToken = lscp_strtok(NULL, pszSeps, &(pch)); |
94 |
if (pClient->sessid && strcmp(pszToken, pClient->sessid) == 0) { |
cchToken = (pszToken == NULL ? 0 : strlen(pszToken)); |
95 |
sprintf(achBuffer, "PONG %s\r\n", pClient->sessid); |
// Double-check if we're really up to it... |
96 |
cchBuffer = strlen(achBuffer); |
if (pClient->events & event) { |
97 |
if (sendto(pClient->udp.sock, achBuffer, cchBuffer, 0, (struct sockaddr *) &addr, cAddr) < cchBuffer) |
// Invoke the client event callback... |
98 |
lscp_socket_perror("_lscp_client_udp_proc: sendto"); |
if ((*pClient->pfnCallback)( |
99 |
#ifdef DEBUG |
pClient, |
100 |
fprintf(stderr, "> %s", achBuffer); |
event, |
101 |
#endif |
pszToken, |
102 |
|
cchToken, |
103 |
|
pClient->pvData) != LSCP_OK) { |
104 |
|
pClient->evt.iState = 0; |
105 |
|
} |
106 |
} |
} |
107 |
} |
} |
|
// Done with life proof. |
|
108 |
} else { |
} else { |
109 |
// |
lscp_socket_perror("_lscp_client_evt_proc: recv"); |
110 |
if ((*pClient->pfnCallback)( |
pClient->evt.iState = 0; |
|
pClient, |
|
|
achBuffer, |
|
|
cchBuffer, |
|
|
pClient->pvData) != LSCP_OK) { |
|
|
pClient->udp.iState = 0; |
|
|
} |
|
111 |
} |
} |
112 |
} else { |
} // Check if select has in error. |
113 |
lscp_socket_perror("_lscp_client_udp_proc: recvfrom"); |
else if (iSelect < 0) { |
114 |
pClient->udp.iState = 0; |
lscp_socket_perror("_lscp_client_call: select"); |
115 |
|
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 |
123 |
fprintf(stderr, "_lscp_client_udp_proc: Client closing.\n"); |
fprintf(stderr, "_lscp_client_evt_proc: Client closing.\n"); |
124 |
#endif |
#endif |
125 |
} |
} |
126 |
|
|
127 |
|
|
128 |
//------------------------------------------------------------------------- |
//------------------------------------------------------------------------- |
129 |
|
// Event subscription helpers. |
130 |
|
|
131 |
|
// Open the event service socket connection. |
132 |
|
static lscp_status_t _lscp_client_evt_connect ( lscp_client_t *pClient ) |
133 |
|
{ |
134 |
|
lscp_socket_t sock; |
135 |
|
struct sockaddr_in addr; |
136 |
|
int cAddr; |
137 |
|
#if defined(WIN32) |
138 |
|
int iSockOpt = (-1); |
139 |
|
#endif |
140 |
|
|
141 |
|
// Prepare the event connection socket... |
142 |
|
sock = socket(AF_INET, SOCK_STREAM, 0); |
143 |
|
if (sock == INVALID_SOCKET) { |
144 |
|
lscp_socket_perror("_lscp_client_evt_connect: socket"); |
145 |
|
return LSCP_FAILED; |
146 |
|
} |
147 |
|
|
148 |
|
#if defined(WIN32) |
149 |
|
if (setsockopt(sock, SOL_SOCKET, SO_DONTLINGER, (char *) &iSockOpt, sizeof(int)) == SOCKET_ERROR) |
150 |
|
lscp_socket_perror("lscp_client_evt_connect: setsockopt(SO_DONTLINGER)"); |
151 |
|
#endif |
152 |
|
|
153 |
|
#ifdef DEBUG |
154 |
|
lscp_socket_getopts("_lscp_client_evt_connect:", sock); |
155 |
|
#endif |
156 |
|
|
157 |
|
// Use same address of the command connection. |
158 |
|
cAddr = sizeof(struct sockaddr_in); |
159 |
|
memmove((char *) &addr, &(pClient->cmd.addr), cAddr); |
160 |
|
|
161 |
|
// Start the connection... |
162 |
|
if (connect(sock, (struct sockaddr *) &addr, cAddr) == SOCKET_ERROR) { |
163 |
|
lscp_socket_perror("_lscp_client_evt_connect: connect"); |
164 |
|
closesocket(sock); |
165 |
|
return LSCP_FAILED; |
166 |
|
} |
167 |
|
|
168 |
|
// Set our socket agent struct... |
169 |
|
lscp_socket_agent_init(&(pClient->evt), sock, &addr, cAddr); |
170 |
|
|
171 |
|
// And finally the service thread... |
172 |
|
return lscp_socket_agent_start(&(pClient->evt), _lscp_client_evt_proc, pClient, 0); |
173 |
|
} |
174 |
|
|
175 |
|
|
176 |
|
// Subscribe to a single event. |
177 |
|
static lscp_status_t _lscp_client_evt_request ( lscp_client_t *pClient, int iSubscribe, lscp_event_t event ) |
178 |
|
{ |
179 |
|
const char *pszEvent; |
180 |
|
char szQuery[LSCP_BUFSIZ]; |
181 |
|
int cchQuery; |
182 |
|
|
183 |
|
if (pClient == NULL) |
184 |
|
return LSCP_FAILED; |
185 |
|
|
186 |
|
// Which (single) event? |
187 |
|
pszEvent = lscp_event_to_text(event); |
188 |
|
if (pszEvent == NULL) |
189 |
|
return LSCP_FAILED; |
190 |
|
|
191 |
|
// Build the query string... |
192 |
|
cchQuery = sprintf(szQuery, "%sSUBSCRIBE %s\n\n", (iSubscribe == 0 ? "UN" : ""), pszEvent); |
193 |
|
// Just send data, forget result... |
194 |
|
if (send(pClient->evt.sock, szQuery, cchQuery, 0) < cchQuery) { |
195 |
|
lscp_socket_perror("_lscp_client_evt_request: send"); |
196 |
|
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... |
203 |
|
if (iSubscribe) |
204 |
|
pClient->events |= event; |
205 |
|
else |
206 |
|
pClient->events &= ~event; |
207 |
|
|
208 |
|
return LSCP_OK; |
209 |
|
} |
210 |
|
|
211 |
|
|
212 |
|
//------------------------------------------------------------------------- |
213 |
// Client versioning teller fuunction. |
// Client versioning teller fuunction. |
214 |
|
|
215 |
|
|
247 |
lscp_socket_t sock; |
lscp_socket_t sock; |
248 |
struct sockaddr_in addr; |
struct sockaddr_in addr; |
249 |
int cAddr; |
int cAddr; |
250 |
|
#if defined(WIN32) |
251 |
int iSockOpt = (-1); |
int iSockOpt = (-1); |
252 |
|
#endif |
253 |
|
|
254 |
if (pfnCallback == NULL) { |
if (pfnCallback == NULL) { |
255 |
fprintf(stderr, "lscp_client_create: Invalid client callback function.\n"); |
fprintf(stderr, "lscp_client_create: Invalid client callback function.\n"); |
258 |
|
|
259 |
pHost = gethostbyname(pszHost); |
pHost = gethostbyname(pszHost); |
260 |
if (pHost == NULL) { |
if (pHost == NULL) { |
261 |
lscp_socket_perror("lscp_client_create: gethostbyname"); |
lscp_socket_herror("lscp_client_create: gethostbyname"); |
262 |
return NULL; |
return NULL; |
263 |
} |
} |
264 |
|
|
278 |
fprintf(stderr, "lscp_client_create: pClient=%p: pszHost=%s iPort=%d.\n", pClient, pszHost, iPort); |
fprintf(stderr, "lscp_client_create: pClient=%p: pszHost=%s iPort=%d.\n", pClient, pszHost, iPort); |
279 |
#endif |
#endif |
280 |
|
|
281 |
// Prepare the TCP connection socket... |
// Prepare the command connection socket... |
282 |
|
|
283 |
sock = socket(AF_INET, SOCK_STREAM, 0); |
sock = socket(AF_INET, SOCK_STREAM, 0); |
284 |
if (sock == INVALID_SOCKET) { |
if (sock == INVALID_SOCKET) { |
285 |
lscp_socket_perror("lscp_client_create: tcp: socket"); |
lscp_socket_perror("lscp_client_create: cmd: socket"); |
286 |
free(pClient); |
free(pClient); |
287 |
return NULL; |
return NULL; |
288 |
} |
} |
289 |
|
|
290 |
#if defined(WIN32) |
#if defined(WIN32) |
291 |
if (setsockopt(sock, SOL_SOCKET, SO_DONTLINGER, (char *) &iSockOpt, sizeof(int)) == SOCKET_ERROR) |
if (setsockopt(sock, SOL_SOCKET, SO_DONTLINGER, (char *) &iSockOpt, sizeof(int)) == SOCKET_ERROR) |
292 |
lscp_socket_perror("lscp_client_create: tcp: setsockopt(SO_DONTLINGER)"); |
lscp_socket_perror("lscp_client_create: cmd: setsockopt(SO_DONTLINGER)"); |
293 |
#endif |
#endif |
294 |
|
|
295 |
#ifdef DEBUG |
#ifdef DEBUG |
296 |
lscp_socket_getopts("lscp_client_create: tcp", sock); |
lscp_socket_getopts("lscp_client_create: cmd", sock); |
297 |
#endif |
#endif |
298 |
|
|
299 |
cAddr = sizeof(struct sockaddr_in); |
cAddr = sizeof(struct sockaddr_in); |
303 |
addr.sin_port = htons((short) iPort); |
addr.sin_port = htons((short) iPort); |
304 |
|
|
305 |
if (connect(sock, (struct sockaddr *) &addr, cAddr) == SOCKET_ERROR) { |
if (connect(sock, (struct sockaddr *) &addr, cAddr) == SOCKET_ERROR) { |
306 |
lscp_socket_perror("lscp_client_create: tcp: connect"); |
lscp_socket_perror("lscp_client_create: cmd: connect"); |
|
closesocket(sock); |
|
|
free(pClient); |
|
|
return NULL; |
|
|
} |
|
|
|
|
|
lscp_socket_agent_init(&(pClient->tcp), sock, &addr, cAddr); |
|
|
|
|
|
#ifdef DEBUG |
|
|
fprintf(stderr, "lscp_client_create: tcp: pClient=%p: sock=%d addr=%s port=%d.\n", pClient, pClient->tcp.sock, inet_ntoa(pClient->tcp.addr.sin_addr), ntohs(pClient->tcp.addr.sin_port)); |
|
|
#endif |
|
|
|
|
|
// Prepare the UDP datagram service socket... |
|
|
|
|
|
sock = socket(AF_INET, SOCK_DGRAM, 0); |
|
|
if (sock == INVALID_SOCKET) { |
|
|
lscp_socket_perror("lscp_client_create: udp: socket"); |
|
|
lscp_socket_agent_free(&(pClient->tcp)); |
|
|
free(pClient); |
|
|
return NULL; |
|
|
} |
|
|
|
|
|
if (setsockopt(sock, SOL_SOCKET, SO_REUSEADDR, (char *) &iSockOpt, sizeof(int)) == SOCKET_ERROR) |
|
|
lscp_socket_perror("lscp_client_create: udp: setsockopt(SO_REUSEADDR)"); |
|
|
|
|
|
#ifdef DEBUG |
|
|
lscp_socket_getopts("lscp_client_create: udp", sock); |
|
|
#endif |
|
|
|
|
|
cAddr = sizeof(struct sockaddr_in); |
|
|
memset((char *) &addr, 0, cAddr); |
|
|
addr.sin_family = AF_INET; |
|
|
addr.sin_addr.s_addr = htonl(INADDR_ANY); |
|
|
addr.sin_port = htons(0); |
|
|
|
|
|
if (bind(sock, (const struct sockaddr *) &addr, cAddr) == SOCKET_ERROR) { |
|
|
lscp_socket_perror("lscp_client_create: udp: bind"); |
|
|
lscp_socket_agent_free(&(pClient->tcp)); |
|
307 |
closesocket(sock); |
closesocket(sock); |
308 |
free(pClient); |
free(pClient); |
309 |
return NULL; |
return NULL; |
310 |
} |
} |
311 |
|
|
312 |
if (getsockname(sock, (struct sockaddr *) &addr, &cAddr) == SOCKET_ERROR) { |
// Initialize the command socket agent struct... |
313 |
lscp_socket_perror("lscp_client_create: udp: getsockname"); |
lscp_socket_agent_init(&(pClient->cmd), sock, &addr, cAddr); |
|
lscp_socket_agent_free(&(pClient->tcp)); |
|
|
closesocket(sock); |
|
|
free(pClient); |
|
|
return NULL; |
|
|
} |
|
|
|
|
|
lscp_socket_agent_init(&(pClient->udp), sock, &addr, cAddr); |
|
314 |
|
|
315 |
#ifdef DEBUG |
#ifdef DEBUG |
316 |
fprintf(stderr, "lscp_client_create: udp: pClient=%p: sock=%d addr=%s port=%d.\n", pClient, pClient->udp.sock, inet_ntoa(pClient->udp.addr.sin_addr), ntohs(pClient->udp.addr.sin_port)); |
fprintf(stderr, "lscp_client_create: cmd: pClient=%p: sock=%d addr=%s port=%d.\n", pClient, pClient->cmd.sock, inet_ntoa(pClient->cmd.addr.sin_addr), ntohs(pClient->cmd.addr.sin_port)); |
317 |
#endif |
#endif |
318 |
|
|
319 |
// No session id, yet. |
// Initialize the event service socket struct... |
320 |
pClient->sessid = NULL; |
lscp_socket_agent_init(&(pClient->evt), INVALID_SOCKET, NULL, 0); |
321 |
|
// No events subscribed, yet. |
322 |
|
pClient->events = LSCP_EVENT_NONE; |
323 |
// Initialize cached members. |
// Initialize cached members. |
324 |
pClient->audio_drivers = NULL; |
pClient->audio_drivers = NULL; |
325 |
pClient->midi_drivers = NULL; |
pClient->midi_drivers = NULL; |
326 |
|
pClient->audio_devices = NULL; |
327 |
|
pClient->midi_devices = NULL; |
328 |
pClient->engines = NULL; |
pClient->engines = NULL; |
329 |
lscp_driver_info_init(&(pClient->audio_info)); |
pClient->channels = NULL; |
330 |
lscp_driver_info_init(&(pClient->midi_info)); |
lscp_driver_info_init(&(pClient->audio_driver_info)); |
331 |
|
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)); |
335 |
|
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); |
|
// Now's finally time to startup threads... |
|
|
// UDP service thread... |
|
|
if (lscp_socket_agent_start(&(pClient->udp), _lscp_client_udp_proc, pClient, 0) != LSCP_OK) { |
|
|
lscp_socket_agent_free(&(pClient->tcp)); |
|
|
lscp_socket_agent_free(&(pClient->udp)); |
|
|
lscp_mutex_destroy(pClient->mutex); |
|
|
free(pClient); |
|
|
return NULL; |
|
|
} |
|
354 |
|
|
355 |
// Finally we've some success... |
// Finally we've some success... |
356 |
return pClient; |
return pClient; |
371 |
fprintf(stderr, "lscp_client_join: pClient=%p.\n", pClient); |
fprintf(stderr, "lscp_client_join: pClient=%p.\n", pClient); |
372 |
#endif |
#endif |
373 |
|
|
374 |
// lscp_socket_agent_join(&(pClient->udp)); |
// lscp_socket_agent_join(&(pClient->evt)); |
375 |
lscp_socket_agent_join(&(pClient->tcp)); |
lscp_socket_agent_join(&(pClient->cmd)); |
376 |
|
|
377 |
return LSCP_OK; |
return LSCP_OK; |
378 |
} |
} |
394 |
fprintf(stderr, "lscp_client_destroy: pClient=%p.\n", pClient); |
fprintf(stderr, "lscp_client_destroy: pClient=%p.\n", pClient); |
395 |
#endif |
#endif |
396 |
|
|
397 |
// Free session-id, if any. |
// Lock this section up. |
398 |
if (pClient->sessid) |
lscp_mutex_lock(pClient->mutex); |
399 |
free(pClient->sessid); |
|
|
pClient->sessid = NULL; |
|
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_driver_info_reset(&(pClient->midi_info)); |
lscp_param_info_free(&(pClient->midi_port_param_info)); |
404 |
lscp_driver_info_reset(&(pClient->audio_info)); |
lscp_param_info_free(&(pClient->audio_channel_param_info)); |
405 |
|
lscp_device_port_info_free(&(pClient->midi_port_info)); |
406 |
|
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); |
416 |
|
lscp_isplit_destroy(pClient->audio_devices); |
417 |
|
lscp_isplit_destroy(pClient->midi_devices); |
418 |
lscp_szsplit_destroy(pClient->engines); |
lscp_szsplit_destroy(pClient->engines); |
419 |
|
lscp_isplit_destroy(pClient->channels); |
420 |
// Make them null. |
// Make them null. |
421 |
pClient->audio_drivers = NULL; |
pClient->audio_drivers = NULL; |
422 |
pClient->midi_drivers = NULL; |
pClient->midi_drivers = NULL; |
423 |
pClient->engines = NULL; |
pClient->engines = NULL; |
424 |
// Free result error stuff. |
// Free result error stuff. |
425 |
_lscp_client_set_result(pClient, NULL, 0); |
lscp_client_set_result(pClient, NULL, 0); |
426 |
// Frre stream usage stuff. |
// Free stream usage stuff. |
427 |
if (pClient->buffer_fill) |
if (pClient->buffer_fill) |
428 |
free(pClient->buffer_fill); |
free(pClient->buffer_fill); |
429 |
pClient->buffer_fill = NULL; |
pClient->buffer_fill = NULL; |
431 |
pClient->iTimeout = 0; |
pClient->iTimeout = 0; |
432 |
|
|
433 |
// Free socket agents. |
// Free socket agents. |
434 |
lscp_socket_agent_free(&(pClient->udp)); |
lscp_socket_agent_free(&(pClient->evt)); |
435 |
lscp_socket_agent_free(&(pClient->tcp)); |
lscp_socket_agent_free(&(pClient->cmd)); |
436 |
|
|
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); |
439 |
lscp_mutex_destroy(pClient->mutex); |
lscp_mutex_destroy(pClient->mutex); |
440 |
|
lscp_cond_destroy(pClient->cond); |
441 |
|
|
442 |
free(pClient); |
free(pClient); |
443 |
|
|
484 |
//------------------------------------------------------------------------- |
//------------------------------------------------------------------------- |
485 |
// Client common protocol functions. |
// Client common protocol functions. |
486 |
|
|
|
|
|
487 |
/** |
/** |
488 |
* Submit a command query line string to the server. The query string |
* Submit a command query line string to the server. The query string |
489 |
* must be cr/lf and null terminated. Besides the return code, the |
* must be cr/lf and null terminated. Besides the return code, the |
499 |
*/ |
*/ |
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 |
fd_set fds; // File descriptor list for select(). |
lscp_status_t ret; |
503 |
int fd, fdmax; // Maximum file descriptor number. |
|
|
struct timeval tv; // For specifying a timeout value. |
|
|
int iSelect; // Holds select return status. |
|
|
int iTimeout; |
|
|
int cchQuery; |
|
|
char achResult[LSCP_BUFSIZ]; |
|
|
int cchResult; |
|
|
const char *pszSeps = ":[]"; |
|
|
char *pszResult; |
|
|
char *pszToken; |
|
|
char *pch; |
|
|
int iErrno; |
|
|
|
|
|
lscp_status_t ret = LSCP_FAILED; |
|
|
|
|
|
if (pClient == NULL) |
|
|
return ret; |
|
|
|
|
504 |
// Lock this section up. |
// Lock this section up. |
505 |
lscp_mutex_lock(pClient->mutex); |
lscp_mutex_lock(pClient->mutex); |
506 |
|
|
507 |
pszResult = NULL; |
// Just make the now guarded call. |
508 |
iErrno = -1; |
ret = lscp_client_call(pClient, pszQuery); |
509 |
|
|
510 |
// Send data, and then, wait for the result... |
// Unlock this section down. |
|
cchQuery = strlen(pszQuery); |
|
|
if (send(pClient->tcp.sock, pszQuery, cchQuery, 0) < cchQuery) { |
|
|
lscp_socket_perror("lscp_client_query: send"); |
|
|
lscp_mutex_unlock(pClient->mutex); |
|
|
return ret; |
|
|
} |
|
|
|
|
|
// Prepare for waiting on select... |
|
|
fd = (int) pClient->tcp.sock; |
|
|
FD_ZERO(&fds); |
|
|
FD_SET((unsigned int) fd, &fds); |
|
|
fdmax = fd; |
|
|
|
|
|
// Use the timeout select feature... |
|
|
iTimeout = pClient->iTimeout; |
|
|
if (iTimeout > 1000) { |
|
|
tv.tv_sec = iTimeout / 1000; |
|
|
iTimeout -= tv.tv_sec * 1000; |
|
|
} |
|
|
else tv.tv_sec = 0; |
|
|
tv.tv_usec = iTimeout * 1000; |
|
|
|
|
|
// Wait for event... |
|
|
iSelect = select(fdmax + 1, &fds, NULL, NULL, &tv); |
|
|
if (iSelect > 0 && FD_ISSET(fd, &fds)) { |
|
|
// May recv now... |
|
|
cchResult = recv(pClient->tcp.sock, achResult, sizeof(achResult), 0); |
|
|
if (cchResult > 0) { |
|
|
// Assume early success. |
|
|
ret = LSCP_OK; |
|
|
// Always force the result to be null terminated (and trim trailing CRLFs)! |
|
|
while (cchResult > 0 && (achResult[cchResult - 1] == '\n' || achResult[cchResult- 1] == '\r')) |
|
|
cchResult--; |
|
|
achResult[cchResult] = (char) 0; |
|
|
// Check if the response it's an error or warning message. |
|
|
if (strncasecmp(achResult, "WRN:", 4) == 0) |
|
|
ret = LSCP_WARNING; |
|
|
else if (strncasecmp(achResult, "ERR:", 4) == 0) |
|
|
ret = LSCP_ERROR; |
|
|
// So we got a result... |
|
|
if (ret == LSCP_OK) { |
|
|
// Reset errno in case of success. |
|
|
iErrno = 0; |
|
|
// Is it a special successful response? |
|
|
if (strncasecmp(achResult, "OK[", 3) == 0) { |
|
|
// Parse the OK message, get the return string under brackets... |
|
|
pszToken = lscp_strtok(achResult, pszSeps, &(pch)); |
|
|
if (pszToken) |
|
|
pszResult = lscp_strtok(NULL, pszSeps, &(pch)); |
|
|
} |
|
|
else pszResult = achResult; |
|
|
// The result string is now set to the command response, if any. |
|
|
} else { |
|
|
// Parse the error/warning message, skip first colon... |
|
|
pszToken = lscp_strtok(achResult, pszSeps, &(pch)); |
|
|
if (pszToken) { |
|
|
// Get the error number... |
|
|
pszToken = lscp_strtok(NULL, pszSeps, &(pch)); |
|
|
if (pszToken) { |
|
|
iErrno = atoi(pszToken); |
|
|
// And make the message text our final result. |
|
|
pszResult = lscp_strtok(NULL, pszSeps, &(pch)); |
|
|
} |
|
|
} |
|
|
// The result string is set to the error/warning message text. |
|
|
} |
|
|
} |
|
|
else if (cchResult == 0) { |
|
|
// Fake a result message. |
|
|
pszResult = "Server terminated the connection"; |
|
|
ret = LSCP_QUIT; |
|
|
} |
|
|
else lscp_socket_perror("lscp_client_query: recv"); |
|
|
} // Check if select has timed out. |
|
|
else if (iSelect == 0) { |
|
|
// Fake a result message. |
|
|
pszResult = "Timeout during receive operation"; |
|
|
ret = LSCP_TIMEOUT; |
|
|
} |
|
|
else lscp_socket_perror("lscp_client_query: select"); |
|
|
|
|
|
// Make the result official... |
|
|
_lscp_client_set_result(pClient, pszResult, iErrno); |
|
|
|
|
|
// Can go on with it... |
|
511 |
lscp_mutex_unlock(pClient->mutex); |
lscp_mutex_unlock(pClient->mutex); |
512 |
|
|
513 |
return ret; |
return ret; |
514 |
} |
} |
515 |
|
|
|
|
|
516 |
/** |
/** |
517 |
* Get the last received result string. In case of error or warning, |
* Get the last received result string. In case of error or warning, |
518 |
* this is the text of the error or warning message issued. |
* this is the text of the error or warning message issued. |
552 |
// Client registration protocol functions. |
// Client registration protocol functions. |
553 |
|
|
554 |
/** |
/** |
555 |
* Register frontend for receiving UDP event messages: |
* Register frontend for receiving event messages: |
556 |
* SUBSCRIBE NOTIFICATION <udp-port> |
* SUBSCRIBE CHANNELS | VOICE_COUNT | STREAM_COUNT | BUFFER_FILL |
557 |
|
* | CHANNEL_INFO | MISCELLANEOUS |
558 |
* |
* |
559 |
* @param pClient Pointer to client instance structure. |
* @param pClient Pointer to client instance structure. |
560 |
|
* @param events Bit-wise OR'ed event flags to subscribe. |
561 |
* |
* |
562 |
* @returns LSCP_OK on success, LSCP_FAILED otherwise. |
* @returns LSCP_OK on success, LSCP_FAILED otherwise. |
563 |
*/ |
*/ |
564 |
lscp_status_t lscp_client_subscribe ( lscp_client_t *pClient ) |
lscp_status_t lscp_client_subscribe ( lscp_client_t *pClient, lscp_event_t events ) |
565 |
{ |
{ |
566 |
lscp_status_t ret; |
lscp_status_t ret = LSCP_FAILED; |
|
char szQuery[LSCP_BUFSIZ]; |
|
|
const char *pszResult; |
|
|
const char *pszSeps = "[]"; |
|
|
char *pszToken; |
|
|
char *pch; |
|
567 |
|
|
568 |
if (pClient == NULL || pClient->sessid) |
if (pClient == NULL) |
569 |
return LSCP_FAILED; |
return LSCP_FAILED; |
570 |
|
|
571 |
sprintf(szQuery, "SUBSCRIBE NOTIFICATION %d\r\n", ntohs(pClient->udp.addr.sin_port)); |
// Lock this section up. |
572 |
ret = lscp_client_query(pClient, szQuery); |
lscp_mutex_lock(pClient->mutex); |
573 |
if (ret == LSCP_OK) { |
|
574 |
pszResult = lscp_client_get_result(pClient); |
// If applicable, start the alternate connection... |
575 |
#ifdef DEBUG |
if (pClient->events == LSCP_EVENT_NONE) |
576 |
fprintf(stderr, "lscp_client_subscribe: %s\n", pszResult); |
ret = _lscp_client_evt_connect(pClient); |
577 |
#endif |
|
578 |
// Check for the session-id on "OK[sessid]" response. |
// Send the subscription commands. |
579 |
pszToken = lscp_strtok(pszResult, pszSeps, &(pch)); |
if (ret == LSCP_OK && (events & LSCP_EVENT_CHANNELS)) |
580 |
if (pszToken && strcasecmp(pszToken, "OK") == 0) { |
ret = _lscp_client_evt_request(pClient, 1, LSCP_EVENT_CHANNELS); |
581 |
pszToken = lscp_strtok(NULL, pszSeps, &(pch)); |
if (ret == LSCP_OK && (events & LSCP_EVENT_VOICE_COUNT)) |
582 |
if (pszToken) |
ret = _lscp_client_evt_request(pClient, 1, LSCP_EVENT_VOICE_COUNT); |
583 |
pClient->sessid = strdup(pszToken); |
if (ret == LSCP_OK && (events & LSCP_EVENT_STREAM_COUNT)) |
584 |
} |
ret = _lscp_client_evt_request(pClient, 1, LSCP_EVENT_STREAM_COUNT); |
585 |
} |
if (ret == LSCP_OK && (events & LSCP_EVENT_BUFFER_FILL)) |
586 |
|
ret = _lscp_client_evt_request(pClient, 1, LSCP_EVENT_BUFFER_FILL); |
587 |
|
if (ret == LSCP_OK && (events & LSCP_EVENT_CHANNEL_INFO)) |
588 |
|
ret = _lscp_client_evt_request(pClient, 1, LSCP_EVENT_CHANNEL_INFO); |
589 |
|
if (ret == LSCP_OK && (events & LSCP_EVENT_MISCELLANEOUS)) |
590 |
|
ret = _lscp_client_evt_request(pClient, 1, LSCP_EVENT_MISCELLANEOUS); |
591 |
|
|
592 |
|
// Unlock this section down. |
593 |
|
lscp_mutex_unlock(pClient->mutex); |
594 |
|
|
595 |
return ret; |
return ret; |
596 |
} |
} |
597 |
|
|
598 |
|
|
599 |
/** |
/** |
600 |
* Deregister frontend for not receiving UDP event messages anymore: |
* Deregister frontend from receiving UDP event messages anymore: |
601 |
* UNSUBSCRIBE NOTIFICATION <session-id> |
* SUBSCRIBE CHANNELS | VOICE_COUNT | STREAM_COUNT | BUFFER_FILL |
602 |
|
* | CHANNEL_INFO | MISCELLANEOUS |
603 |
* |
* |
604 |
* @param pClient Pointer to client instance structure. |
* @param pClient Pointer to client instance structure. |
605 |
|
* @param events Bit-wise OR'ed event flags to unsubscribe. |
606 |
* |
* |
607 |
* @returns LSCP_OK on success, LSCP_FAILED otherwise. |
* @returns LSCP_OK on success, LSCP_FAILED otherwise. |
608 |
*/ |
*/ |
609 |
lscp_status_t lscp_client_unsubscribe ( lscp_client_t *pClient ) |
lscp_status_t lscp_client_unsubscribe ( lscp_client_t *pClient, lscp_event_t events ) |
610 |
{ |
{ |
611 |
lscp_status_t ret; |
lscp_status_t ret = LSCP_OK; |
|
char szQuery[LSCP_BUFSIZ]; |
|
612 |
|
|
613 |
if (pClient == NULL) |
if (pClient == NULL) |
614 |
return LSCP_FAILED; |
return LSCP_FAILED; |
|
if (pClient->sessid == NULL) |
|
|
return LSCP_FAILED; |
|
615 |
|
|
616 |
sprintf(szQuery, "UNSUBSCRIBE NOTIFICATION %s\n\n", pClient->sessid); |
// Lock this section up. |
617 |
ret = lscp_client_query(pClient, szQuery); |
lscp_mutex_lock(pClient->mutex); |
618 |
if (ret == LSCP_OK) { |
|
619 |
#ifdef DEBUG |
// Send the unsubscription commands. |
620 |
fprintf(stderr, "lscp_client_unsubscribe: %s\n", lscp_client_get_result(pClient)); |
if (ret == LSCP_OK && (events & LSCP_EVENT_CHANNELS)) |
621 |
#endif |
ret = _lscp_client_evt_request(pClient, 0, LSCP_EVENT_CHANNELS); |
622 |
// Bail out session-id string. |
if (ret == LSCP_OK && (events & LSCP_EVENT_VOICE_COUNT)) |
623 |
free(pClient->sessid); |
ret = _lscp_client_evt_request(pClient, 0, LSCP_EVENT_VOICE_COUNT); |
624 |
pClient->sessid = NULL; |
if (ret == LSCP_OK && (events & LSCP_EVENT_STREAM_COUNT)) |
625 |
} |
ret = _lscp_client_evt_request(pClient, 0, LSCP_EVENT_STREAM_COUNT); |
626 |
|
if (ret == LSCP_OK && (events & LSCP_EVENT_BUFFER_FILL)) |
627 |
|
ret = _lscp_client_evt_request(pClient, 0, LSCP_EVENT_BUFFER_FILL); |
628 |
|
if (ret == LSCP_OK && (events & LSCP_EVENT_CHANNEL_INFO)) |
629 |
|
ret = _lscp_client_evt_request(pClient, 0, LSCP_EVENT_CHANNEL_INFO); |
630 |
|
if (ret == LSCP_OK && (events & LSCP_EVENT_MISCELLANEOUS)) |
631 |
|
ret = _lscp_client_evt_request(pClient, 0, LSCP_EVENT_MISCELLANEOUS); |
632 |
|
|
633 |
|
// If necessary, close the alternate connection... |
634 |
|
if (pClient->events == LSCP_EVENT_NONE) |
635 |
|
lscp_socket_agent_free(&(pClient->evt)); |
636 |
|
|
637 |
|
// Unlock this section down. |
638 |
|
lscp_mutex_unlock(pClient->mutex); |
639 |
|
|
640 |
return ret; |
return ret; |
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 |
|
|
678 |
if (pszFileName == NULL || iSamplerChannel < 0) |
if (pszFileName == NULL || iSamplerChannel < 0) |
679 |
return LSCP_FAILED; |
return LSCP_FAILED; |
680 |
|
|
681 |
sprintf(szQuery, "LOAD INSTRUMENT %s %d %d\r\n", pszFileName, iInstrIndex, iSamplerChannel); |
sprintf(szQuery, "LOAD INSTRUMENT '%s' %d %d\r\n", pszFileName, iInstrIndex, iSamplerChannel); |
682 |
|
return lscp_client_query(pClient, szQuery); |
683 |
|
} |
684 |
|
|
685 |
|
|
686 |
|
/** |
687 |
|
* Loading an instrument in the background (non modal): |
688 |
|
* LOAD INSTRUMENT NON_MODAL <filename> <instr-index> <sampler-channel> |
689 |
|
* |
690 |
|
* @param pClient Pointer to client instance structure. |
691 |
|
* @param pszFileName Instrument file name. |
692 |
|
* @param iInstrIndex Instrument index number. |
693 |
|
* @param iSamplerChannel Sampler Channel. |
694 |
|
* |
695 |
|
* @returns LSCP_OK on success, LSCP_FAILED otherwise. |
696 |
|
*/ |
697 |
|
lscp_status_t lscp_load_instrument_non_modal ( lscp_client_t *pClient, const char *pszFileName, int iInstrIndex, int iSamplerChannel ) |
698 |
|
{ |
699 |
|
char szQuery[LSCP_BUFSIZ]; |
700 |
|
|
701 |
|
if (pszFileName == NULL || iSamplerChannel < 0) |
702 |
|
return LSCP_FAILED; |
703 |
|
|
704 |
|
sprintf(szQuery, "LOAD INSTRUMENT NON_MODAL '%s' %d %d\r\n", pszFileName, iInstrIndex, iSamplerChannel); |
705 |
return lscp_client_query(pClient, szQuery); |
return lscp_client_query(pClient, szQuery); |
706 |
} |
} |
707 |
|
|
740 |
int lscp_get_channels ( lscp_client_t *pClient ) |
int lscp_get_channels ( lscp_client_t *pClient ) |
741 |
{ |
{ |
742 |
int iChannels = -1; |
int iChannels = -1; |
743 |
if (lscp_client_query(pClient, "GET CHANNELS\r\n") == LSCP_OK) |
|
744 |
|
// Lock this section up. |
745 |
|
lscp_mutex_lock(pClient->mutex); |
746 |
|
|
747 |
|
if (lscp_client_call(pClient, "GET CHANNELS\r\n") == LSCP_OK) |
748 |
iChannels = atoi(lscp_client_get_result(pClient)); |
iChannels = atoi(lscp_client_get_result(pClient)); |
749 |
|
|
750 |
|
// Unlock this section doen. |
751 |
|
lscp_mutex_unlock(pClient->mutex); |
752 |
|
|
753 |
return iChannels; |
return iChannels; |
754 |
} |
} |
755 |
|
|
756 |
|
|
757 |
/** |
/** |
758 |
|
* List current sampler channels number identifiers: |
759 |
|
* LIST CHANNELS |
760 |
|
* |
761 |
|
* @param pClient Pointer to client instance structure. |
762 |
|
* |
763 |
|
* @returns An array of the sampler channels identifiers as positive integers, |
764 |
|
* terminated with -1 on success, NULL otherwise. |
765 |
|
*/ |
766 |
|
int *lscp_list_channels ( lscp_client_t *pClient ) |
767 |
|
{ |
768 |
|
const char *pszSeps = ","; |
769 |
|
|
770 |
|
if (pClient == NULL) |
771 |
|
return NULL; |
772 |
|
|
773 |
|
// Lock this section up. |
774 |
|
lscp_mutex_lock(pClient->mutex); |
775 |
|
|
776 |
|
if (pClient->channels) { |
777 |
|
lscp_isplit_destroy(pClient->channels); |
778 |
|
pClient->channels = NULL; |
779 |
|
} |
780 |
|
|
781 |
|
if (lscp_client_call(pClient, "LIST CHANNELS\r\n") == LSCP_OK) |
782 |
|
pClient->channels = lscp_isplit_create(lscp_client_get_result(pClient), pszSeps); |
783 |
|
|
784 |
|
// Unlock this section down. |
785 |
|
lscp_mutex_unlock(pClient->mutex); |
786 |
|
|
787 |
|
return pClient->channels; |
788 |
|
} |
789 |
|
|
790 |
|
|
791 |
|
/** |
792 |
* Adding a new sampler channel: |
* Adding a new sampler channel: |
793 |
* ADD CHANNEL |
* ADD CHANNEL |
794 |
* |
* |
800 |
int lscp_add_channel ( lscp_client_t *pClient ) |
int lscp_add_channel ( lscp_client_t *pClient ) |
801 |
{ |
{ |
802 |
int iSamplerChannel = -1; |
int iSamplerChannel = -1; |
803 |
if (lscp_client_query(pClient, "ADD CHANNEL\r\n") == LSCP_OK) |
|
804 |
|
// Lock this section up. |
805 |
|
lscp_mutex_lock(pClient->mutex); |
806 |
|
|
807 |
|
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. |
811 |
|
lscp_mutex_unlock(pClient->mutex); |
812 |
|
|
813 |
return iSamplerChannel; |
return iSamplerChannel; |
814 |
} |
} |
815 |
|
|
848 |
{ |
{ |
849 |
const char *pszSeps = ","; |
const char *pszSeps = ","; |
850 |
|
|
851 |
|
// Lock this section up. |
852 |
|
lscp_mutex_lock(pClient->mutex); |
853 |
|
|
854 |
if (pClient->engines) { |
if (pClient->engines) { |
855 |
lscp_szsplit_destroy(pClient->engines); |
lscp_szsplit_destroy(pClient->engines); |
856 |
pClient->engines = NULL; |
pClient->engines = NULL; |
857 |
} |
} |
858 |
|
|
859 |
if (lscp_client_query(pClient, "GET AVAILABLE_ENGINES\r\n") == LSCP_OK) |
if (lscp_client_call(pClient, "GET AVAILABLE_ENGINES\r\n") == LSCP_OK) |
860 |
pClient->engines = lscp_szsplit_create(lscp_client_get_result(pClient), pszSeps); |
pClient->engines = lscp_szsplit_create(lscp_client_get_result(pClient), pszSeps); |
861 |
|
|
862 |
|
// Unlock this section down. |
863 |
|
lscp_mutex_unlock(pClient->mutex); |
864 |
|
|
865 |
return (const char **) pClient->engines; |
return (const char **) pClient->engines; |
866 |
} |
} |
867 |
|
|
889 |
if (pszEngineName == NULL) |
if (pszEngineName == NULL) |
890 |
return NULL; |
return NULL; |
891 |
|
|
892 |
|
// Lock this section up. |
893 |
|
lscp_mutex_lock(pClient->mutex); |
894 |
|
|
895 |
pEngineInfo = &(pClient->engine_info); |
pEngineInfo = &(pClient->engine_info); |
896 |
lscp_engine_info_reset(pEngineInfo); |
lscp_engine_info_reset(pEngineInfo); |
897 |
|
|
898 |
sprintf(szQuery, "GET ENGINE INFO %s\r\n", pszEngineName); |
sprintf(szQuery, "GET ENGINE INFO %s\r\n", pszEngineName); |
899 |
if (lscp_client_query(pClient, szQuery) != LSCP_OK) |
if (lscp_client_call(pClient, szQuery) == LSCP_OK) { |
900 |
return NULL; |
pszResult = lscp_client_get_result(pClient); |
901 |
|
pszToken = lscp_strtok((char *) pszResult, pszSeps, &(pch)); |
902 |
pszResult = lscp_client_get_result(pClient); |
while (pszToken) { |
903 |
pszToken = lscp_strtok(pszResult, pszSeps, &(pch)); |
if (strcasecmp(pszToken, "DESCRIPTION") == 0) { |
904 |
while (pszToken) { |
pszToken = lscp_strtok(NULL, pszCrlf, &(pch)); |
905 |
if (strcasecmp(pszToken, "DESCRIPTION") == 0) { |
if (pszToken) |
906 |
pszToken = lscp_strtok(NULL, pszCrlf, &(pch)); |
lscp_unquote_dup(&(pEngineInfo->description), &pszToken); |
907 |
if (pszToken) |
} |
908 |
pEngineInfo->description = lscp_unquote(&pszToken, 1); |
else if (strcasecmp(pszToken, "VERSION") == 0) { |
909 |
} |
pszToken = lscp_strtok(NULL, pszCrlf, &(pch)); |
910 |
else if (strcasecmp(pszToken, "VERSION") == 0) { |
if (pszToken) |
911 |
pszToken = lscp_strtok(NULL, pszCrlf, &(pch)); |
lscp_unquote_dup(&(pEngineInfo->version), &pszToken); |
912 |
if (pszToken) |
} |
913 |
pEngineInfo->version = lscp_unquote(&pszToken, 1); |
pszToken = lscp_strtok(NULL, pszSeps, &(pch)); |
914 |
} |
} |
|
pszToken = lscp_strtok(NULL, pszSeps, &(pch)); |
|
915 |
} |
} |
916 |
|
else pEngineInfo = NULL; |
917 |
|
|
918 |
|
// Unlock this section down. |
919 |
|
lscp_mutex_unlock(pClient->mutex); |
920 |
|
|
921 |
return pEngineInfo; |
return pEngineInfo; |
922 |
} |
} |
945 |
if (iSamplerChannel < 0) |
if (iSamplerChannel < 0) |
946 |
return NULL; |
return NULL; |
947 |
|
|
948 |
|
// Lock this section up. |
949 |
|
lscp_mutex_lock(pClient->mutex); |
950 |
|
|
951 |
pChannelInfo = &(pClient->channel_info); |
pChannelInfo = &(pClient->channel_info); |
952 |
lscp_channel_info_reset(pChannelInfo); |
lscp_channel_info_reset(pChannelInfo); |
953 |
|
|
954 |
sprintf(szQuery, "GET CHANNEL INFO %d\r\n", iSamplerChannel); |
sprintf(szQuery, "GET CHANNEL INFO %d\r\n", iSamplerChannel); |
955 |
if (lscp_client_query(pClient, szQuery) != LSCP_OK) |
if (lscp_client_call(pClient, szQuery) == LSCP_OK) { |
956 |
return NULL; |
pszResult = lscp_client_get_result(pClient); |
957 |
|
pszToken = lscp_strtok((char *) pszResult, pszSeps, &(pch)); |
958 |
pszResult = lscp_client_get_result(pClient); |
while (pszToken) { |
959 |
pszToken = lscp_strtok(pszResult, pszSeps, &(pch)); |
if (strcasecmp(pszToken, "ENGINE_NAME") == 0) { |
960 |
while (pszToken) { |
pszToken = lscp_strtok(NULL, pszCrlf, &(pch)); |
961 |
if (strcasecmp(pszToken, "ENGINE_NAME") == 0) { |
if (pszToken) |
962 |
pszToken = lscp_strtok(NULL, pszCrlf, &(pch)); |
lscp_unquote_dup(&(pChannelInfo->engine_name), &pszToken); |
963 |
if (pszToken) |
} |
964 |
pChannelInfo->engine_name = lscp_unquote(&pszToken, 1); |
else if (strcasecmp(pszToken, "AUDIO_OUTPUT_DEVICE") == 0) { |
965 |
} |
pszToken = lscp_strtok(NULL, pszCrlf, &(pch)); |
966 |
else if (strcasecmp(pszToken, "AUDIO_OUTPUT_DEVICE") == 0) { |
if (pszToken) |
967 |
pszToken = lscp_strtok(NULL, pszCrlf, &(pch)); |
pChannelInfo->audio_device = atoi(lscp_ltrim(pszToken)); |
968 |
if (pszToken) |
} |
969 |
pChannelInfo->audio_device = atoi(lscp_ltrim(pszToken)); |
else if (strcasecmp(pszToken, "AUDIO_OUTPUT_CHANNELS") == 0) { |
970 |
} |
pszToken = lscp_strtok(NULL, pszCrlf, &(pch)); |
971 |
else if (strcasecmp(pszToken, "AUDIO_OUTPUT_CHANNELS") == 0) { |
if (pszToken) |
972 |
pszToken = lscp_strtok(NULL, pszCrlf, &(pch)); |
pChannelInfo->audio_channels = atoi(lscp_ltrim(pszToken)); |
973 |
if (pszToken) |
} |
974 |
pChannelInfo->audio_channels = atoi(lscp_ltrim(pszToken)); |
else if (strcasecmp(pszToken, "AUDIO_OUTPUT_ROUTING") == 0) { |
975 |
} |
pszToken = lscp_strtok(NULL, pszCrlf, &(pch)); |
976 |
else if (strcasecmp(pszToken, "AUDIO_OUTPUT_ROUTING") == 0) { |
if (pszToken) { |
977 |
pszToken = lscp_strtok(NULL, pszCrlf, &(pch)); |
if (pChannelInfo->audio_routing) |
978 |
if (pszToken) |
lscp_szsplit_destroy(pChannelInfo->audio_routing); |
979 |
pChannelInfo->audio_routing = lscp_szsplit_create(pszToken, ","); |
pChannelInfo->audio_routing = lscp_szsplit_create(pszToken, ","); |
980 |
} |
} |
981 |
else if (strcasecmp(pszToken, "INSTRUMENT_FILE") == 0) { |
} |
982 |
pszToken = lscp_strtok(NULL, pszCrlf, &(pch)); |
else if (strcasecmp(pszToken, "INSTRUMENT_FILE") == 0) { |
983 |
if (pszToken) |
pszToken = lscp_strtok(NULL, pszCrlf, &(pch)); |
984 |
pChannelInfo->instrument_file = lscp_unquote(&pszToken, 1); |
if (pszToken) |
985 |
} |
lscp_unquote_dup(&(pChannelInfo->instrument_file), &pszToken); |
986 |
else if (strcasecmp(pszToken, "INSTRUMENT_NR") == 0) { |
} |
987 |
pszToken = lscp_strtok(NULL, pszCrlf, &(pch)); |
else if (strcasecmp(pszToken, "INSTRUMENT_NR") == 0) { |
988 |
if (pszToken) |
pszToken = lscp_strtok(NULL, pszCrlf, &(pch)); |
989 |
pChannelInfo->instrument_nr = atoi(lscp_ltrim(pszToken)); |
if (pszToken) |
990 |
} |
pChannelInfo->instrument_nr = atoi(lscp_ltrim(pszToken)); |
991 |
else if (strcasecmp(pszToken, "MIDI_INPUT_DEVICE") == 0) { |
} |
992 |
pszToken = lscp_strtok(NULL, pszCrlf, &(pch)); |
else if (strcasecmp(pszToken, "INSTRUMENT_STATUS") == 0) { |
993 |
if (pszToken) |
pszToken = lscp_strtok(NULL, pszCrlf, &(pch)); |
994 |
pChannelInfo->midi_device = atoi(lscp_ltrim(pszToken)); |
if (pszToken) |
995 |
} |
pChannelInfo->instrument_status = atoi(lscp_ltrim(pszToken)); |
996 |
else if (strcasecmp(pszToken, "MIDI_INPUT_PORT") == 0) { |
} |
997 |
pszToken = lscp_strtok(NULL, pszCrlf, &(pch)); |
else if (strcasecmp(pszToken, "MIDI_INPUT_DEVICE") == 0) { |
998 |
if (pszToken) |
pszToken = lscp_strtok(NULL, pszCrlf, &(pch)); |
999 |
pChannelInfo->midi_port = atoi(lscp_ltrim(pszToken)); |
if (pszToken) |
1000 |
} |
pChannelInfo->midi_device = atoi(lscp_ltrim(pszToken)); |
1001 |
else if (strcasecmp(pszToken, "MIDI_INPUT_CHANNEL") == 0) { |
} |
1002 |
pszToken = lscp_strtok(NULL, pszCrlf, &(pch)); |
else if (strcasecmp(pszToken, "MIDI_INPUT_PORT") == 0) { |
1003 |
if (pszToken) |
pszToken = lscp_strtok(NULL, pszCrlf, &(pch)); |
1004 |
pChannelInfo->midi_channel = atoi(lscp_ltrim(pszToken)); |
if (pszToken) |
1005 |
} |
pChannelInfo->midi_port = atoi(lscp_ltrim(pszToken)); |
1006 |
else if (strcasecmp(pszToken, "VOLUME") == 0) { |
} |
1007 |
pszToken = lscp_strtok(NULL, pszCrlf, &(pch)); |
else if (strcasecmp(pszToken, "MIDI_INPUT_CHANNEL") == 0) { |
1008 |
if (pszToken) |
pszToken = lscp_strtok(NULL, pszCrlf, &(pch)); |
1009 |
pChannelInfo->volume = (float) atof(lscp_ltrim(pszToken)); |
if (pszToken) |
1010 |
|
pChannelInfo->midi_channel = atoi(lscp_ltrim(pszToken)); |
1011 |
|
} |
1012 |
|
else if (strcasecmp(pszToken, "VOLUME") == 0) { |
1013 |
|
pszToken = lscp_strtok(NULL, pszCrlf, &(pch)); |
1014 |
|
if (pszToken) |
1015 |
|
pChannelInfo->volume = (float) atof(lscp_ltrim(pszToken)); |
1016 |
|
} |
1017 |
|
pszToken = lscp_strtok(NULL, pszSeps, &(pch)); |
1018 |
} |
} |
|
pszToken = lscp_strtok(NULL, pszSeps, &(pch)); |
|
1019 |
} |
} |
1020 |
|
else pChannelInfo = NULL; |
1021 |
|
|
1022 |
|
// Unlock this section up. |
1023 |
|
lscp_mutex_unlock(pClient->mutex); |
1024 |
|
|
1025 |
return pChannelInfo; |
return pChannelInfo; |
1026 |
} |
} |
1043 |
if (iSamplerChannel < 0) |
if (iSamplerChannel < 0) |
1044 |
return iVoiceCount; |
return iVoiceCount; |
1045 |
|
|
1046 |
|
// Lock this section up. |
1047 |
|
lscp_mutex_lock(pClient->mutex); |
1048 |
|
|
1049 |
sprintf(szQuery, "GET CHANNEL VOICE_COUNT %d\r\n", iSamplerChannel); |
sprintf(szQuery, "GET CHANNEL VOICE_COUNT %d\r\n", iSamplerChannel); |
1050 |
if (lscp_client_query(pClient, szQuery) == LSCP_OK) |
if (lscp_client_call(pClient, szQuery) == LSCP_OK) |
1051 |
iVoiceCount = atoi(lscp_client_get_result(pClient)); |
iVoiceCount = atoi(lscp_client_get_result(pClient)); |
1052 |
|
|
1053 |
|
// Unlock this section down. |
1054 |
|
lscp_mutex_unlock(pClient->mutex); |
1055 |
|
|
1056 |
return iVoiceCount; |
return iVoiceCount; |
1057 |
} |
} |
1058 |
|
|
1061 |
* Current number of active disk streams: |
* Current number of active disk streams: |
1062 |
* GET CHANNEL STREAM_COUNT <sampler-channel> |
* GET CHANNEL STREAM_COUNT <sampler-channel> |
1063 |
* |
* |
1064 |
|
* @param pClient Pointer to client instance structure. |
1065 |
|
* @param iSamplerChannel Sampler channel number. |
1066 |
|
* |
1067 |
* @returns The number of active disk streams on success, -1 otherwise. |
* @returns The number of active disk streams on success, -1 otherwise. |
1068 |
*/ |
*/ |
1069 |
int lscp_get_channel_stream_count ( lscp_client_t *pClient, int iSamplerChannel ) |
int lscp_get_channel_stream_count ( lscp_client_t *pClient, int iSamplerChannel ) |
1074 |
if (iSamplerChannel < 0) |
if (iSamplerChannel < 0) |
1075 |
return iStreamCount; |
return iStreamCount; |
1076 |
|
|
1077 |
|
// Lock this section up. |
1078 |
|
lscp_mutex_lock(pClient->mutex); |
1079 |
|
|
1080 |
sprintf(szQuery, "GET CHANNEL STREAM_COUNT %d\r\n", iSamplerChannel); |
sprintf(szQuery, "GET CHANNEL STREAM_COUNT %d\r\n", iSamplerChannel); |
1081 |
if (lscp_client_query(pClient, szQuery) == LSCP_OK) |
if (lscp_client_call(pClient, szQuery) == LSCP_OK) |
1082 |
iStreamCount = atoi(lscp_client_get_result(pClient)); |
iStreamCount = atoi(lscp_client_get_result(pClient)); |
1083 |
|
|
1084 |
|
// Unlock this section down. |
1085 |
|
lscp_mutex_unlock(pClient->mutex); |
1086 |
|
|
1087 |
return iStreamCount; |
return iStreamCount; |
1088 |
} |
} |
1089 |
|
|
1090 |
|
|
1091 |
/** |
/** |
1092 |
|
* Current least usage of active disk streams. |
1093 |
|
* |
1094 |
|
* @param pClient Pointer to client instance structure. |
1095 |
|
* @param iSamplerChannel Sampler channel number. |
1096 |
|
* |
1097 |
|
* @returns The usage percentage of the least filled active disk stream |
1098 |
|
* on success, -1 otherwise. |
1099 |
|
*/ |
1100 |
|
int lscp_get_channel_stream_usage ( lscp_client_t *pClient, int iSamplerChannel ) |
1101 |
|
{ |
1102 |
|
char szQuery[LSCP_BUFSIZ]; |
1103 |
|
int iStreamUsage = -1; |
1104 |
|
const char *pszResult; |
1105 |
|
const char *pszSeps = "[]%,"; |
1106 |
|
char *pszToken; |
1107 |
|
char *pch; |
1108 |
|
int iStream; |
1109 |
|
int iPercent; |
1110 |
|
|
1111 |
|
if (iSamplerChannel < 0) |
1112 |
|
return iStreamUsage; |
1113 |
|
|
1114 |
|
// Lock this section up. |
1115 |
|
lscp_mutex_lock(pClient->mutex); |
1116 |
|
|
1117 |
|
iStream = 0; |
1118 |
|
sprintf(szQuery, "GET CHANNEL BUFFER_FILL PERCENTAGE %d\r\n", iSamplerChannel); |
1119 |
|
if (lscp_client_call(pClient, szQuery) == LSCP_OK) { |
1120 |
|
pszResult = lscp_client_get_result(pClient); |
1121 |
|
pszToken = lscp_strtok((char *) pszResult, pszSeps, &(pch)); |
1122 |
|
while (pszToken) { |
1123 |
|
if (*pszToken) { |
1124 |
|
// Skip stream id. |
1125 |
|
pszToken = lscp_strtok(NULL, pszSeps, &(pch)); |
1126 |
|
if (pszToken == NULL) |
1127 |
|
break; |
1128 |
|
// Get least buffer fill percentage. |
1129 |
|
iPercent = atol(pszToken); |
1130 |
|
if (iStreamUsage > iPercent || iStream == 0) |
1131 |
|
iStreamUsage = iPercent; |
1132 |
|
iStream++; |
1133 |
|
} |
1134 |
|
pszToken = lscp_strtok(NULL, pszSeps, &(pch)); |
1135 |
|
} |
1136 |
|
} |
1137 |
|
|
1138 |
|
// Unlock this section down. |
1139 |
|
lscp_mutex_unlock(pClient->mutex); |
1140 |
|
|
1141 |
|
return iStreamUsage; |
1142 |
|
} |
1143 |
|
|
1144 |
|
|
1145 |
|
/** |
1146 |
* Current fill state of disk stream buffers: |
* Current fill state of disk stream buffers: |
1147 |
* GET CHANNEL BUFFER_FILL {BYTES|PERCENTAGE} <sampler-channel> |
* GET CHANNEL BUFFER_FILL {BYTES|PERCENTAGE} <sampler-channel> |
1148 |
* |
* |
1168 |
char *pch; |
char *pch; |
1169 |
int iStream; |
int iStream; |
1170 |
|
|
1171 |
|
// Retrieve a channel stream estimation. |
1172 |
iStreamCount = lscp_get_channel_stream_count(pClient, iSamplerChannel); |
iStreamCount = lscp_get_channel_stream_count(pClient, iSamplerChannel); |
1173 |
|
if (pClient->iStreamCount < 0) |
1174 |
|
return NULL; |
1175 |
|
|
1176 |
|
// Lock this section up. |
1177 |
|
lscp_mutex_lock(pClient->mutex); |
1178 |
|
|
1179 |
|
// Check if we need to reallocate the stream usage array. |
1180 |
if (pClient->iStreamCount != iStreamCount) { |
if (pClient->iStreamCount != iStreamCount) { |
1181 |
if (pClient->buffer_fill) |
if (pClient->buffer_fill) |
1182 |
free(pClient->buffer_fill); |
free(pClient->buffer_fill); |
1187 |
pClient->iStreamCount = iStreamCount; |
pClient->iStreamCount = iStreamCount; |
1188 |
} |
} |
1189 |
|
|
|
if (pClient->iStreamCount < 1) |
|
|
return NULL; |
|
|
|
|
|
iStream = 0; |
|
|
pBufferFill = pClient->buffer_fill; |
|
|
|
|
1190 |
// Get buffer fill usage... |
// Get buffer fill usage... |
1191 |
sprintf(szQuery, "GET CHANNEL BUFFER_FILL %s %d\r\n", pszUsageType, iSamplerChannel); |
pBufferFill = pClient->buffer_fill; |
1192 |
if (lscp_client_query(pClient, szQuery) == LSCP_OK) { |
if (pBufferFill && iStreamCount > 0) { |
1193 |
pszResult = lscp_client_get_result(pClient); |
iStream = 0; |
1194 |
pszToken = lscp_strtok(pszResult, pszSeps, &(pch)); |
pBufferFill = pClient->buffer_fill; |
1195 |
while (pszToken && iStream < pClient->iStreamCount) { |
sprintf(szQuery, "GET CHANNEL BUFFER_FILL %s %d\r\n", pszUsageType, iSamplerChannel); |
1196 |
if (*pszToken) { |
if (lscp_client_call(pClient, szQuery) == LSCP_OK) { |
1197 |
pBufferFill[iStream].stream_id = atol(pszToken); |
pszResult = lscp_client_get_result(pClient); |
1198 |
|
pszToken = lscp_strtok((char *) pszResult, pszSeps, &(pch)); |
1199 |
|
while (pszToken && iStream < pClient->iStreamCount) { |
1200 |
|
if (*pszToken) { |
1201 |
|
pBufferFill[iStream].stream_id = atol(pszToken); |
1202 |
|
pszToken = lscp_strtok(NULL, pszSeps, &(pch)); |
1203 |
|
if (pszToken == NULL) |
1204 |
|
break; |
1205 |
|
pBufferFill[iStream].stream_usage = atol(pszToken); |
1206 |
|
iStream++; |
1207 |
|
} |
1208 |
pszToken = lscp_strtok(NULL, pszSeps, &(pch)); |
pszToken = lscp_strtok(NULL, pszSeps, &(pch)); |
|
if (pszToken == NULL) |
|
|
break; |
|
|
pBufferFill[iStream].stream_usage = atol(pszToken); |
|
|
iStream++; |
|
1209 |
} |
} |
1210 |
pszToken = lscp_strtok(NULL, pszSeps, &(pch)); |
} // Reset the usage, whatever it was before. |
1211 |
} |
else while (iStream < pClient->iStreamCount) |
1212 |
} // Reset the usage, whatever it was before. |
pBufferFill[iStream++].stream_usage = 0; |
1213 |
else while (iStream < pClient->iStreamCount) |
} |
1214 |
pBufferFill[iStream++].stream_usage = 0; |
|
1215 |
|
// Unlock this section down. |
1216 |
|
lscp_mutex_unlock(pClient->mutex); |
1217 |
|
|
1218 |
return pBufferFill; |
return pBufferFill; |
1219 |
} |
} |
1240 |
|
|
1241 |
|
|
1242 |
/** |
/** |
1243 |
|
* Setting audio output device: |
1244 |
|
* SET CHANNEL AUDIO_OUTPUT_DEVICE <sampler-channel> <device-id> |
1245 |
|
* |
1246 |
|
* @param pClient Pointer to client instance structure. |
1247 |
|
* @param iSamplerChannel Sampler channel number. |
1248 |
|
* @param iAudioDevice Audio output device number identifier. |
1249 |
|
*/ |
1250 |
|
lscp_status_t lscp_set_channel_audio_device ( lscp_client_t *pClient, int iSamplerChannel, int iAudioDevice ) |
1251 |
|
{ |
1252 |
|
char szQuery[LSCP_BUFSIZ]; |
1253 |
|
|
1254 |
|
if (iSamplerChannel < 0 || iAudioDevice < 0) |
1255 |
|
return LSCP_FAILED; |
1256 |
|
|
1257 |
|
sprintf(szQuery, "SET CHANNEL AUDIO_OUTPUT_DEVICE %d %d\r\n", iSamplerChannel, iAudioDevice); |
1258 |
|
return lscp_client_query(pClient, szQuery); |
1259 |
|
} |
1260 |
|
|
1261 |
|
|
1262 |
|
/** |
1263 |
* Setting audio output channel: |
* Setting audio output channel: |
1264 |
* SET CHANNEL AUDIO_OUTPUT_CHANNEL <sampler-channel> <audio-output-chan> <audio-input-chan> |
* SET CHANNEL AUDIO_OUTPUT_CHANNEL <sampler-channel> <audio-output-chan> <audio-input-chan> |
1265 |
* |
* |
1277 |
if (iSamplerChannel < 0 || iAudioOut < 0 || iAudioIn < 0) |
if (iSamplerChannel < 0 || iAudioOut < 0 || iAudioIn < 0) |
1278 |
return LSCP_FAILED; |
return LSCP_FAILED; |
1279 |
|
|
1280 |
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); |
1281 |
return lscp_client_query(pClient, szQuery); |
return lscp_client_query(pClient, szQuery); |
1282 |
} |
} |
1283 |
|
|
1305 |
|
|
1306 |
|
|
1307 |
/** |
/** |
1308 |
|
* Setting MIDI input device: |
1309 |
|
* SET CHANNEL MIDI_INPUT_DEVICE <sampler-channel> <device-id> |
1310 |
|
* |
1311 |
|
* @param pClient Pointer to client instance structure. |
1312 |
|
* @param iSamplerChannel Sampler channel number. |
1313 |
|
* @param iMidiDevice MIDI input device number identifier. |
1314 |
|
*/ |
1315 |
|
lscp_status_t lscp_set_channel_midi_device ( lscp_client_t *pClient, int iSamplerChannel, int iMidiDevice ) |
1316 |
|
{ |
1317 |
|
char szQuery[LSCP_BUFSIZ]; |
1318 |
|
|
1319 |
|
if (iSamplerChannel < 0 || iMidiDevice < 0) |
1320 |
|
return LSCP_FAILED; |
1321 |
|
|
1322 |
|
sprintf(szQuery, "SET CHANNEL MIDI_INPUT_DEVICE %d %d\r\n", iSamplerChannel, iMidiDevice); |
1323 |
|
return lscp_client_query(pClient, szQuery); |
1324 |
|
} |
1325 |
|
|
1326 |
|
|
1327 |
|
/** |
1328 |
* Setting MIDI input port: |
* Setting MIDI input port: |
1329 |
* SET CHANNEL MIDI_INPUT_PORT <sampler-channel> <midi-input-port> |
* SET CHANNEL MIDI_INPUT_PORT <sampler-channel> <midi-input-port> |
1330 |
* |
* |
1417 |
} |
} |
1418 |
|
|
1419 |
|
|
1420 |
|
/** |
1421 |
|
* Resetting the sampler: |
1422 |
|
* RESET |
1423 |
|
* |
1424 |
|
* @param pClient Pointer to client instance structure. |
1425 |
|
* |
1426 |
|
* @returns LSCP_OK on success, LSCP_FAILED otherwise. |
1427 |
|
*/ |
1428 |
|
lscp_status_t lscp_reset_sampler ( lscp_client_t *pClient ) |
1429 |
|
{ |
1430 |
|
return lscp_client_query(pClient, "RESET\r\n"); |
1431 |
|
} |
1432 |
|
|
1433 |
|
|
1434 |
// end of client.c |
// end of client.c |