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 |
|
|
44 |
fd_set fds; // File descriptor list for select(). |
fd_set fds; // File descriptor list for select(). |
45 |
int fd, fdmax; // Maximum file descriptor number. |
int fd, fdmax; // Maximum file descriptor number. |
46 |
struct timeval tv; // For specifying a timeout value. |
struct timeval tv; // For specifying a timeout value. |
47 |
int iSelect; // Holds select return status. |
int iSelect; // Holds select return status. |
48 |
int iTimeout; |
int iTimeout; |
49 |
|
|
50 |
char achBuffer[LSCP_BUFSIZ]; |
char achBuffer[LSCP_BUFSIZ]; |
51 |
int cchBuffer; |
int cchBuffer; |
52 |
const char *pszSeps = ":\r\n"; |
const char *pszSeps = ":\r\n"; |
114 |
lscp_socket_perror("_lscp_client_evt_proc: select"); |
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. |
// Finally, always signal the event. |
119 |
lscp_cond_signal(pClient->cond); |
lscp_cond_signal(pClient->cond); |
120 |
} |
} |
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 |
} |
} |
198 |
|
|
199 |
// Wait on response. |
// Wait on response. |
200 |
lscp_cond_wait(pClient->cond, pClient->mutex); |
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; |
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_free(&(pClient->channel_info)); |
lscp_channel_info_free(&(pClient->channel_info)); |
402 |
lscp_engine_info_free(&(pClient->engine_info)); |
lscp_engine_info_free(&(pClient->engine_info)); |
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)) |
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 |
|
|
846 |
*/ |
*/ |
847 |
int lscp_get_available_engines ( lscp_client_t *pClient ) |
int lscp_get_available_engines ( lscp_client_t *pClient ) |
848 |
{ |
{ |
849 |
int iAvailableEngines = -1; |
int iAvailableEngines = -1; |
850 |
|
|
851 |
// Lock this section up. |
// Lock this section up. |
852 |
lscp_mutex_lock(pClient->mutex); |
lscp_mutex_lock(pClient->mutex); |
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 |
|
|
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 |
|
|