50 |
|
|
51 |
//////////////////////////////////////////////////////////////////////// |
//////////////////////////////////////////////////////////////////////// |
52 |
|
|
53 |
void client_test_int ( int i ) |
int client_test_int ( int i ) |
54 |
{ |
{ |
55 |
printf("%d\n", i); |
printf("%d\n", i); |
56 |
|
return (i >= 0 ? 0 : 1); |
57 |
} |
} |
58 |
|
|
59 |
void client_test_status ( lscp_status_t s ) |
int client_test_status ( lscp_status_t s ) |
60 |
{ |
{ |
61 |
const char *pszStatus; |
const char *pszStatus; |
62 |
|
|
63 |
switch (s) { |
switch (s) { |
64 |
case LSCP_OK: pszStatus = "OK"; break; |
case LSCP_OK: pszStatus = "OK"; break; |
65 |
case LSCP_FAILED: pszStatus = "FAILED"; break; |
case LSCP_FAILED: pszStatus = "FAILED"; break; |
69 |
case LSCP_QUIT: pszStatus = "QUIT"; break; |
case LSCP_QUIT: pszStatus = "QUIT"; break; |
70 |
default: pszStatus = "NONE"; break; |
default: pszStatus = "NONE"; break; |
71 |
} |
} |
|
|
|
72 |
printf("%s\n", pszStatus); |
printf("%s\n", pszStatus); |
73 |
|
return (s == LSCP_OK ? 0 : 1); |
74 |
} |
} |
75 |
|
|
76 |
|
|
77 |
void client_test_isplit ( int *piSplit ) |
int client_test_isplit ( int *piSplit ) |
78 |
{ |
{ |
79 |
int i; |
int i; |
80 |
|
|
85 |
printf(" %d", piSplit[i]); |
printf(" %d", piSplit[i]); |
86 |
} |
} |
87 |
printf(" }\n"); |
printf(" }\n"); |
88 |
|
return 0; |
89 |
} |
} |
90 |
|
|
91 |
void client_test_szsplit ( char **ppszSplit ) |
int client_test_szsplit ( char **ppszSplit ) |
92 |
{ |
{ |
93 |
int i; |
int i; |
94 |
|
|
99 |
printf(" %s", ppszSplit[i]); |
printf(" %s", ppszSplit[i]); |
100 |
} |
} |
101 |
printf(" }\n"); |
printf(" }\n"); |
102 |
|
return 0; |
103 |
} |
} |
104 |
|
|
105 |
void client_test_params ( lscp_param_t *pParams ) |
int client_test_params ( lscp_param_t *pParams ) |
106 |
{ |
{ |
107 |
int i; |
int i; |
108 |
|
|
113 |
printf(" %s='%s'", pParams[i].key, pParams[i].value); |
printf(" %s='%s'", pParams[i].key, pParams[i].value); |
114 |
} |
} |
115 |
printf(" }\n"); |
printf(" }\n"); |
116 |
|
return 0; |
117 |
} |
} |
118 |
|
|
119 |
void client_test_param_info ( lscp_param_info_t *pParamInfo ) |
int client_test_param_info ( lscp_param_info_t *pParamInfo ) |
120 |
{ |
{ |
121 |
const char *pszType; |
const char *pszType; |
122 |
|
|
123 |
if (pParamInfo == NULL) { |
if (pParamInfo == NULL) { |
124 |
printf("(nil)\n"); |
printf("(nil)\n"); |
125 |
return; |
return 1; |
126 |
} |
} |
127 |
switch (pParamInfo->type) { |
switch (pParamInfo->type) { |
128 |
case LSCP_TYPE_BOOL: pszType = "BOOL"; break; |
case LSCP_TYPE_BOOL: pszType = "BOOL"; break; |
143 |
printf(" param_info.range_max = %s\n", pParamInfo->range_max); |
printf(" param_info.range_max = %s\n", pParamInfo->range_max); |
144 |
printf(" param_info.possibilities = "); client_test_szsplit(pParamInfo->possibilities); |
printf(" param_info.possibilities = "); client_test_szsplit(pParamInfo->possibilities); |
145 |
printf(" }\n"); |
printf(" }\n"); |
146 |
|
return 0; |
147 |
} |
} |
148 |
|
|
149 |
void client_test_driver_info ( lscp_driver_info_t *pDriverInfo ) |
int client_test_driver_info ( lscp_driver_info_t *pDriverInfo ) |
150 |
{ |
{ |
151 |
if (pDriverInfo == NULL) { |
if (pDriverInfo == NULL) { |
152 |
printf("(nil)\n"); |
printf("(nil)\n"); |
153 |
return; |
return 1; |
154 |
} |
} |
155 |
printf("{\n"); |
printf("{\n"); |
156 |
printf(" driver_info.description = %s\n", pDriverInfo->description); |
printf(" driver_info.description = %s\n", pDriverInfo->description); |
157 |
printf(" driver_info.version = %s\n", pDriverInfo->version); |
printf(" driver_info.version = %s\n", pDriverInfo->version); |
158 |
printf(" driver_info.parameters = "); client_test_szsplit(pDriverInfo->parameters); |
printf(" driver_info.parameters = "); client_test_szsplit(pDriverInfo->parameters); |
159 |
printf(" }\n"); |
printf(" }\n"); |
160 |
|
return 0; |
161 |
} |
} |
162 |
|
|
163 |
void client_test_device_info ( lscp_device_info_t *pDeviceInfo ) |
int client_test_device_info ( lscp_device_info_t *pDeviceInfo ) |
164 |
{ |
{ |
165 |
if (pDeviceInfo == NULL) { |
if (pDeviceInfo == NULL) { |
166 |
printf("(nil)\n"); |
printf("(nil)\n"); |
167 |
return; |
return 1; |
168 |
} |
} |
169 |
printf("{\n"); |
printf("{\n"); |
170 |
printf(" device_info.driver = %s\n", pDeviceInfo->driver); |
printf(" device_info.driver = %s\n", pDeviceInfo->driver); |
171 |
printf(" device_info.params = "); client_test_params(pDeviceInfo->params); |
printf(" device_info.params = "); client_test_params(pDeviceInfo->params); |
172 |
printf(" }\n"); |
printf(" }\n"); |
173 |
|
return 0; |
174 |
} |
} |
175 |
|
|
176 |
void client_test_device_port_info ( lscp_device_port_info_t *pDevicePortInfo ) |
int client_test_device_port_info ( lscp_device_port_info_t *pDevicePortInfo ) |
177 |
{ |
{ |
178 |
if (pDevicePortInfo == NULL) { |
if (pDevicePortInfo == NULL) { |
179 |
printf("(nil)\n"); |
printf("(nil)\n"); |
180 |
return; |
return 1; |
181 |
} |
} |
182 |
printf("{\n"); |
printf("{\n"); |
183 |
printf(" device_port_info.name = %s\n", pDevicePortInfo->name); |
printf(" device_port_info.name = %s\n", pDevicePortInfo->name); |
184 |
printf(" device_port_info.params = "); client_test_params(pDevicePortInfo->params); |
printf(" device_port_info.params = "); client_test_params(pDevicePortInfo->params); |
185 |
printf(" }\n"); |
printf(" }\n"); |
186 |
|
return 0; |
187 |
} |
} |
188 |
|
|
189 |
void client_test_engine_info ( lscp_engine_info_t *pEngineInfo ) |
int client_test_engine_info ( lscp_engine_info_t *pEngineInfo ) |
190 |
{ |
{ |
191 |
if (pEngineInfo == NULL) { |
if (pEngineInfo == NULL) { |
192 |
printf("(nil)\n"); |
printf("(nil)\n"); |
193 |
return; |
return 1; |
194 |
} |
} |
195 |
printf("{\n"); |
printf("{\n"); |
196 |
printf(" engine_info.description = %s\n", pEngineInfo->description); |
printf(" engine_info.description = %s\n", pEngineInfo->description); |
197 |
printf(" engine_info.version = %s\n", pEngineInfo->version); |
printf(" engine_info.version = %s\n", pEngineInfo->version); |
198 |
printf(" }\n"); |
printf(" }\n"); |
199 |
|
return 0; |
200 |
} |
} |
201 |
|
|
202 |
void client_test_channel_info ( lscp_channel_info_t *pChannelInfo ) |
int client_test_channel_info ( lscp_channel_info_t *pChannelInfo ) |
203 |
{ |
{ |
204 |
if (pChannelInfo == NULL) { |
if (pChannelInfo == NULL) { |
205 |
printf("(nil)\n"); |
printf("(nil)\n"); |
206 |
return; |
return 1; |
207 |
} |
} |
208 |
printf("{\n"); |
printf("{\n"); |
209 |
printf(" channel_info.engine_name = %s\n", pChannelInfo->engine_name); |
printf(" channel_info.engine_name = %s\n", pChannelInfo->engine_name); |
218 |
printf(" channel_info.midi_channel = %d\n", pChannelInfo->midi_channel); |
printf(" channel_info.midi_channel = %d\n", pChannelInfo->midi_channel); |
219 |
printf(" channel_info.volume = %g\n", pChannelInfo->volume); |
printf(" channel_info.volume = %g\n", pChannelInfo->volume); |
220 |
printf(" }\n"); |
printf(" }\n"); |
221 |
|
return 0; |
222 |
} |
} |
223 |
|
|
224 |
void client_test_buffer_fill ( lscp_buffer_fill_t *pBufferFill ) |
int client_test_buffer_fill ( lscp_buffer_fill_t *pBufferFill ) |
225 |
{ |
{ |
226 |
|
if (pBufferFill == NULL) { |
227 |
|
printf("(nil)\n"); |
228 |
|
return 1; |
229 |
|
} |
230 |
printf("{ <%p> }\n", pBufferFill); |
printf("{ <%p> }\n", pBufferFill); |
231 |
|
return 0; |
232 |
} |
} |
233 |
|
|
234 |
//////////////////////////////////////////////////////////////////////// |
//////////////////////////////////////////////////////////////////////// |
235 |
|
|
236 |
static int g_teststep = 0; |
static int g_test_step = 0; |
237 |
|
static int g_test_count = 0; |
238 |
|
static int g_test_fails = 0; |
239 |
|
|
240 |
|
|
241 |
void client_test_start ( clock_t *pclk ) { *pclk = clock(); } |
void client_test_start ( clock_t *pclk ) { *pclk = clock(); } |
242 |
float client_test_elapsed ( clock_t *pclk ) { return (float) ((long) clock() - *pclk) / (float) CLOCKS_PER_SEC; } |
float client_test_elapsed ( clock_t *pclk ) { return (float) ((long) clock() - *pclk) / (float) CLOCKS_PER_SEC; } |
252 |
typedef lscp_channel_info_t * channel_info; |
typedef lscp_channel_info_t * channel_info; |
253 |
typedef lscp_buffer_fill_t * buffer_fill; |
typedef lscp_buffer_fill_t * buffer_fill; |
254 |
|
|
255 |
#define CLIENT_TEST(p, t, x) { clock_t c; void *v; \ |
#define CLIENT_TEST(p, t, x) { clock_t c; void *v; g_test_count++; \ |
256 |
printf("\n" #x ":\n"); client_test_start(&c); v = (void *) (x); \ |
printf("\n" #x ":\n"); client_test_start(&c); v = (void *) (x); \ |
257 |
printf(" elapsed=%gs errno=%d result='%s...' ret=", \ |
printf(" elapsed=%gs errno=%d result='%s...' ret=", \ |
258 |
client_test_elapsed(&c), \ |
client_test_elapsed(&c), \ |
259 |
lscp_client_get_errno(p), \ |
lscp_client_get_errno(p), \ |
260 |
lscp_client_get_result(p)); \ |
lscp_client_get_result(p)); \ |
261 |
client_test_##t((t)(v)); \ |
if (client_test_##t((t)(v))) { g_test_fails++; getchar(); } \ |
262 |
if (g_teststep) getchar(); } |
else if (g_test_step) getchar(); } |
263 |
|
|
264 |
|
|
265 |
void client_test ( lscp_client_t *pClient ) |
void client_test ( lscp_client_t *pClient ) |
270 |
int iAudioDevice, iMidiDevice; |
int iAudioDevice, iMidiDevice; |
271 |
int iSamplerChannel; |
int iSamplerChannel; |
272 |
|
|
273 |
|
g_test_count = 0; |
274 |
|
g_test_fails = 0; |
275 |
|
|
276 |
CLIENT_TEST(pClient, szsplit, ppszAudioDrivers = lscp_get_available_audio_drivers(pClient)); |
CLIENT_TEST(pClient, szsplit, ppszAudioDrivers = lscp_get_available_audio_drivers(pClient)); |
277 |
if (ppszAudioDrivers == NULL) { |
if (ppszAudioDrivers == NULL) { |
278 |
fprintf(stderr, "client_test: No audio drivers available.\n"); |
fprintf(stderr, "client_test: No audio drivers available.\n"); |
342 |
} |
} |
343 |
CLIENT_TEST(pClient, status, lscp_destroy_audio_device(pClient, iAudioDevice)); |
CLIENT_TEST(pClient, status, lscp_destroy_audio_device(pClient, iAudioDevice)); |
344 |
} |
} |
345 |
|
printf("\n"); |
346 |
|
printf(" Total: %d tests, %d failed.\n\n", g_test_count, g_test_fails); |
347 |
} |
} |
348 |
|
|
349 |
//////////////////////////////////////////////////////////////////////// |
//////////////////////////////////////////////////////////////////////// |
352 |
{ |
{ |
353 |
printf("\n %s %s (Build: %s)\n", lscp_client_package(), lscp_client_version(), lscp_client_build()); |
printf("\n %s %s (Build: %s)\n", lscp_client_package(), lscp_client_version(), lscp_client_build()); |
354 |
|
|
355 |
fputs("\n Available client commands: help, test, exit, quit, subscribe, unsubscribe", stdout); |
fputs("\n Available commands: help, test[step], exit, quit, subscribe, unsubscribe", stdout); |
356 |
fputs("\n (all else are sent verbatim to server)\n\n", stdout); |
fputs("\n (all else are sent verbatim to server)\n\n", stdout); |
357 |
|
|
358 |
} |
} |
406 |
if (strcmp(szLine, "test") == 0) |
if (strcmp(szLine, "test") == 0) |
407 |
client_test(pClient); |
client_test(pClient); |
408 |
else |
else |
409 |
if (strcmp(szLine, "teststep") == 0) { |
if (strcmp(szLine, "teststep") == 0 || strcmp(szLine, "test step") == 0) { |
410 |
g_teststep = 1; |
g_test_step = 1; |
411 |
client_test(pClient); |
client_test(pClient); |
412 |
g_teststep = 0; |
g_test_step = 0; |
413 |
} |
} |
414 |
else |
else |
415 |
if (cchLine > 0 && strcmp(szLine, "help") != 0) { |
if (cchLine > 0 && strcmp(szLine, "help") != 0) { |