373 |
pClient->engines = NULL; |
pClient->engines = NULL; |
374 |
// Free result error stuff. |
// Free result error stuff. |
375 |
lscp_client_set_result(pClient, NULL, 0); |
lscp_client_set_result(pClient, NULL, 0); |
376 |
// Frre stream usage stuff. |
// Free stream usage stuff. |
377 |
if (pClient->buffer_fill) |
if (pClient->buffer_fill) |
378 |
free(pClient->buffer_fill); |
free(pClient->buffer_fill); |
379 |
pClient->buffer_fill = NULL; |
pClient->buffer_fill = NULL; |
991 |
* Current number of active disk streams: |
* Current number of active disk streams: |
992 |
* GET CHANNEL STREAM_COUNT <sampler-channel> |
* GET CHANNEL STREAM_COUNT <sampler-channel> |
993 |
* |
* |
994 |
|
* @param pClient Pointer to client instance structure. |
995 |
|
* @param iSamplerChannel Sampler channel number. |
996 |
|
* |
997 |
* @returns The number of active disk streams on success, -1 otherwise. |
* @returns The number of active disk streams on success, -1 otherwise. |
998 |
*/ |
*/ |
999 |
int lscp_get_channel_stream_count ( lscp_client_t *pClient, int iSamplerChannel ) |
int lscp_get_channel_stream_count ( lscp_client_t *pClient, int iSamplerChannel ) |
1018 |
} |
} |
1019 |
|
|
1020 |
|
|
1021 |
|
/** |
1022 |
|
* Current least usage of active disk streams. |
1023 |
|
* |
1024 |
|
* @param pClient Pointer to client instance structure. |
1025 |
|
* @param iSamplerChannel Sampler channel number. |
1026 |
|
* |
1027 |
|
* @returns The usage percentage of the least filled active disk stream |
1028 |
|
* on success, -1 otherwise. |
1029 |
|
*/ |
1030 |
|
int lscp_get_channel_stream_usage ( lscp_client_t *pClient, int iSamplerChannel ) |
1031 |
|
{ |
1032 |
|
char szQuery[LSCP_BUFSIZ]; |
1033 |
|
int iStreamUsage = -1; |
1034 |
|
const char *pszResult; |
1035 |
|
const char *pszSeps = "[]%,"; |
1036 |
|
char *pszToken; |
1037 |
|
char *pch; |
1038 |
|
int iStream; |
1039 |
|
int iPercent; |
1040 |
|
|
1041 |
|
if (iSamplerChannel < 0) |
1042 |
|
return iStreamUsage; |
1043 |
|
|
1044 |
|
// Lock this section up. |
1045 |
|
lscp_mutex_lock(pClient->mutex); |
1046 |
|
|
1047 |
|
iStream = 0; |
1048 |
|
sprintf(szQuery, "GET CHANNEL BUFFER_FILL PERCENTAGE %d\r\n", iSamplerChannel); |
1049 |
|
if (lscp_client_call(pClient, szQuery) == LSCP_OK) { |
1050 |
|
pszResult = lscp_client_get_result(pClient); |
1051 |
|
pszToken = lscp_strtok((char *) pszResult, pszSeps, &(pch)); |
1052 |
|
while (pszToken) { |
1053 |
|
if (*pszToken) { |
1054 |
|
// Skip stream id. |
1055 |
|
pszToken = lscp_strtok(NULL, pszSeps, &(pch)); |
1056 |
|
if (pszToken == NULL) |
1057 |
|
break; |
1058 |
|
// Get least buffer fill percentage. |
1059 |
|
iPercent = atol(pszToken); |
1060 |
|
if (iStreamUsage > iPercent || iStream == 0) |
1061 |
|
iStreamUsage = iPercent; |
1062 |
|
iStream++; |
1063 |
|
} |
1064 |
|
pszToken = lscp_strtok(NULL, pszSeps, &(pch)); |
1065 |
|
} |
1066 |
|
} |
1067 |
|
|
1068 |
|
// Unlock this section down. |
1069 |
|
lscp_mutex_unlock(pClient->mutex); |
1070 |
|
|
1071 |
|
return iStreamUsage; |
1072 |
|
} |
1073 |
|
|
1074 |
|
|
1075 |
/** |
/** |
1076 |
* Current fill state of disk stream buffers: |
* Current fill state of disk stream buffers: |
1077 |
* GET CHANNEL BUFFER_FILL {BYTES|PERCENTAGE} <sampler-channel> |
* GET CHANNEL BUFFER_FILL {BYTES|PERCENTAGE} <sampler-channel> |