Changeset 437
- Timestamp:
- 03/13/07 11:22:17 (16 years ago)
- Files:
-
- branches/streaming-rework/tests/test-freebob.cpp (modified) (21 diffs)
- branches/streaming-rework/tests/test-mixer.cpp (modified) (3 diffs)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
branches/streaming-rework/tests/test-freebob.cpp
r436 r437 134 134 arguments->verbose = strtol( arg, &tail, 0 ); 135 135 if ( errno ) { 136 fprintf( stderr,"Could not parse 'verbose' argument\n" );136 debugError( "Could not parse 'verbose' argument\n" ); 137 137 return ARGP_ERR_UNKNOWN; 138 138 } … … 143 143 arguments->port = strtol( arg, &tail, 0 ); 144 144 if ( errno ) { 145 fprintf( stderr,"Could not parse 'port' argument\n" );145 debugError( "Could not parse 'port' argument\n" ); 146 146 return ARGP_ERR_UNKNOWN; 147 147 } 148 148 } else { 149 149 if ( errno ) { 150 fprintf( stderr,"Could not parse 'port' argumen\n" );150 debugError( "Could not parse 'port' argumen\n" ); 151 151 return ARGP_ERR_UNKNOWN; 152 152 } … … 157 157 arguments->node_id = strtol( arg, &tail, 0 ); 158 158 if ( errno ) { 159 fprintf( stderr,"Could not parse 'node' argument\n" );159 debugError( "Could not parse 'node' argument\n" ); 160 160 return ARGP_ERR_UNKNOWN; 161 161 } … … 163 163 } else { 164 164 if ( errno ) { 165 fprintf( stderr,"Could not parse 'node' argumen\n" );165 debugError( "Could not parse 'node' argumen\n" ); 166 166 return ARGP_ERR_UNKNOWN; 167 167 } … … 197 197 // Default values. 198 198 arguments.silent = 0; 199 arguments.verbose = 0;199 arguments.verbose = DEBUG_LEVEL_NORMAL; 200 200 arguments.port = 0; 201 201 arguments.node_id = 0; … … 207 207 // be reflected in `arguments'. 208 208 if ( argp_parse ( &argp, argc, argv, 0, 0, &arguments ) ) { 209 fprintf( stderr,"Could not parse command line\n" );209 debugError( "Could not parse command line\n" ); 210 210 return -1; 211 211 } 212 212 213 printf("verbose level = %d\n", arguments.verbose); 214 215 printf( "Using freebob library version: %s\n\n", freebob_get_version() ); 213 setDebugLevel(arguments.verbose); 214 215 debugOutput(DEBUG_LEVEL_NORMAL, "verbose level = %d\n", arguments.verbose); 216 217 debugOutput(DEBUG_LEVEL_NORMAL, "Using freebob library version: %s\n\n", freebob_get_version() ); 216 218 217 219 if ( strcmp( arguments.args[0], "Discover" ) == 0 ) { 218 220 DeviceManager *m_deviceManager = new DeviceManager(); 219 221 if ( !m_deviceManager ) { 220 fprintf( stderr,"Could not allocate device manager\n" );222 debugError( "Could not allocate device manager\n" ); 221 223 return -1; 222 224 } 223 225 if ( !m_deviceManager->initialize( arguments.port ) ) { 224 fprintf( stderr,"Could not initialize device manager\n" );226 debugError( "Could not initialize device manager\n" ); 225 227 delete m_deviceManager; 226 228 return -1; 227 229 } 228 if ( arguments.verbose ) { 229 m_deviceManager->setVerboseLevel(arguments.verbose); 230 } 230 231 m_deviceManager->setVerboseLevel(arguments.verbose); 231 232 if ( !m_deviceManager->discover() ) { 232 fprintf( stderr,"Could not discover devices\n" );233 debugError( "Could not discover devices\n" ); 233 234 delete m_deviceManager; 234 235 return -1; 235 236 } 237 238 int devices_on_bus = m_deviceManager->getNbDevices(); 239 debugOutput(DEBUG_LEVEL_NORMAL, "port = %d, devices_on_bus = %d\n", arguments.port, devices_on_bus); 240 241 for(int i=0;i<devices_on_bus;i++) { 242 int node_id=m_deviceManager->getDeviceNodeId(i); 243 debugOutput(DEBUG_LEVEL_NORMAL, " device = %d, node = %d\n", i, node_id); 244 IAvDevice* avDevice = m_deviceManager->getAvDevice( node_id ); 245 if ( avDevice ) { 246 avDevice->showDevice(); 247 } 248 } 249 236 250 delete m_deviceManager; 237 251 return 0; … … 240 254 int samplerate = strtol( arguments.args[1], &tail, 0 ); 241 255 if ( errno ) { 242 fprintf( stderr,"Could not parse samplerate argument\n" );256 debugError( "Could not parse samplerate argument\n" ); 243 257 return -1; 244 258 } … … 246 260 DeviceManager *m_deviceManager = new DeviceManager(); 247 261 if ( !m_deviceManager ) { 248 fprintf( stderr,"Could not allocate device manager\n" );262 debugError( "Could not allocate device manager\n" ); 249 263 return -1; 250 264 } 251 265 if ( !m_deviceManager->initialize( arguments.port ) ) { 252 fprintf( stderr,"Could not initialize device manager\n" );266 debugError( "Could not initialize device manager\n" ); 253 267 delete m_deviceManager; 254 268 return -1; 255 269 } 256 if ( arguments.verbose ) { 257 m_deviceManager->setVerboseLevel(arguments.verbose); 258 } 270 271 m_deviceManager->setVerboseLevel(arguments.verbose); 259 272 if ( !m_deviceManager->discover() ) { 260 fprintf( stderr,"Could not discover devices\n" );273 debugError( "Could not discover devices\n" ); 261 274 delete m_deviceManager; 262 275 return -1; … … 266 279 IAvDevice* avDevice = m_deviceManager->getAvDevice( arguments.node_id ); 267 280 if ( avDevice ) { 268 if ( avDevice->setSampl ingFrequency( parseSampleRate( samplerate ) ) ) {281 if ( avDevice->setSampleRate( parseSampleRate( samplerate ) ) ) { 269 282 m_deviceManager->discover(); 270 283 } else { 271 fprintf( stderr,"Could not set samplerate\n" );284 debugError( "Could not set samplerate\n" ); 272 285 } 273 286 } … … 276 289 277 290 int devices_on_bus = m_deviceManager->getNbDevices(); 278 printf(" port = %d, devices_on_bus = %d\n", arguments.port, devices_on_bus);291 debugOutput(DEBUG_LEVEL_NORMAL, " port = %d, devices_on_bus = %d\n", arguments.port, devices_on_bus); 279 292 280 293 for(i=0;i<devices_on_bus;i++) { 281 294 int node_id=m_deviceManager->getDeviceNodeId(i); 282 printf(" set samplerate for device = %d, node = %d\n", i, node_id);295 debugOutput(DEBUG_LEVEL_NORMAL, " set samplerate for device = %d, node = %d\n", i, node_id); 283 296 IAvDevice* avDevice = m_deviceManager->getAvDevice( node_id ); 284 297 if ( avDevice ) { 285 if ( !avDevice->setSampl ingFrequency( parseSampleRate( samplerate ) ) ) {286 fprintf( stderr,"Could not set samplerate\n" );298 if ( !avDevice->setSampleRate( parseSampleRate( samplerate ) ) ) { 299 debugError( "Could not set samplerate\n" ); 287 300 } 288 301 } … … 310 323 DeviceManager *m_deviceManager = new DeviceManager(); 311 324 if ( !m_deviceManager ) { 312 fprintf( stderr,"Could not allocate device manager\n" );325 debugError( "Could not allocate device manager\n" ); 313 326 return -1; 314 327 } 315 328 if ( !m_deviceManager->initialize( arguments.port ) ) { 316 fprintf( stderr,"Could not initialize device manager\n" );329 debugError( "Could not initialize device manager\n" ); 317 330 delete m_deviceManager; 318 331 return -1; 319 332 } 320 if ( arguments.verbose ) { 321 m_deviceManager->setVerboseLevel(arguments.verbose); 322 } 333 334 m_deviceManager->setVerboseLevel(arguments.verbose); 323 335 if ( !m_deviceManager->discover() ) { 324 fprintf( stderr,"Could not discover devices\n" );336 debugError( "Could not discover devices\n" ); 325 337 delete m_deviceManager; 326 338 return -1; 327 339 } 328 340 329 printf("server started\n");330 printf("press ctrl-c to stop it & continue\n");341 debugOutput(DEBUG_LEVEL_NORMAL, "server started\n"); 342 debugOutput(DEBUG_LEVEL_NORMAL, "press ctrl-c to stop it & continue\n"); 331 343 332 344 signal (SIGINT, sighandler); … … 340 352 signal (SIGINT, SIG_DFL); 341 353 342 printf("server stopped\n");354 debugOutput(DEBUG_LEVEL_NORMAL, "server stopped\n"); 343 355 delete m_deviceManager; 344 356 return 0; 345 357 346 358 } else { 347 printf("unknown operation\n" );359 debugOutput(DEBUG_LEVEL_NORMAL, "unknown operation\n" ); 348 360 } 349 361 … … 353 365 vector<string> my_paths; 354 366 355 printf("listing path: %s\n", path);367 debugOutput(DEBUG_LEVEL_NORMAL, "listing path: %s\n", path); 356 368 357 369 osc_paths.clear(); … … 359 371 360 372 if (lo_send(t, path, "s", "list") == -1) { 361 printf(" OSC error %d: %s\n", lo_address_errno(t), lo_address_errstr(t));373 debugOutput(DEBUG_LEVEL_NORMAL, " OSC error %d: %s\n", lo_address_errno(t), lo_address_errstr(t)); 362 374 } 363 375 364 376 if (lo_server_recv_noblock(s, 1000) == 0) { 365 printf("timeout\n");377 debugOutput(DEBUG_LEVEL_NORMAL, "timeout\n"); 366 378 return; 367 379 } … … 385 397 void list_osc_params(lo_server s, lo_address t, const char *path) { 386 398 vector<string> my_paths; 387 printf("params for: %s\n", path);399 debugOutput(DEBUG_LEVEL_NORMAL, "params for: %s\n", path); 388 400 389 401 osc_params.clear(); … … 391 403 392 404 if (lo_send(t, path, "s", "params") == -1) { 393 printf(" OSC error %d: %s\n", lo_address_errno(t), lo_address_errstr(t));405 debugOutput(DEBUG_LEVEL_NORMAL, " OSC error %d: %s\n", lo_address_errno(t), lo_address_errstr(t)); 394 406 } 395 407 396 408 if (lo_server_recv_noblock(s, 1000) == 0) { 397 printf("timeout\n");409 debugOutput(DEBUG_LEVEL_NORMAL, "timeout\n"); 398 410 return; 399 411 } … … 408 420 { 409 421 string value=osc_param_get_value(s, t, path, (*it).c_str()); 410 printf(" %20s = %s\n", (*it).c_str(), value.c_str());422 debugOutput(DEBUG_LEVEL_NORMAL, " %20s = %s\n", (*it).c_str(), value.c_str()); 411 423 } 412 424 … … 417 429 418 430 if (lo_send(t, path, "ss", "get", param) == -1) { 419 printf(" OSC error %d: %s\n", lo_address_errno(t), lo_address_errstr(t));431 debugOutput(DEBUG_LEVEL_NORMAL, " OSC error %d: %s\n", lo_address_errno(t), lo_address_errstr(t)); 420 432 } 421 433 … … 430 442 void osc_error_handler(int num, const char *msg, const char *path) 431 443 { 432 printf("liblo server error %d in path %s: %s\n", num, path, msg);444 debugOutput(DEBUG_LEVEL_NORMAL, "liblo server error %d in path %s: %s\n", num, path, msg); 433 445 } 434 446 … … 443 455 break; 444 456 default: 445 printf("unexpected data type in response message\n");457 debugOutput(DEBUG_LEVEL_NORMAL, "unexpected data type in response message\n"); 446 458 } 447 459 } … … 459 471 break; 460 472 default: 461 printf("unexpected data type in response message\n");473 debugOutput(DEBUG_LEVEL_NORMAL, "unexpected data type in response message\n"); 462 474 } 463 475 } branches/streaming-rework/tests/test-mixer.cpp
r436 r437 70 70 { 71 71 72 if (argc < 2) {73 printf("usage: NODE_ID FB_ID\n");72 if (argc < 3) { 73 printf("usage: PORT NODE_ID FB_ID\n"); 74 74 exit(0); 75 75 } … … 77 77 int errno = 0; 78 78 char* tail; 79 int node_id = strtol( argv[1], &tail, 0 ); 80 int fb_id = strtol( argv[2], &tail, 0 ); 79 int port = strtol( argv[1], &tail, 0 ); 80 int node_id = strtol( argv[2], &tail, 0 ); 81 int fb_id = strtol( argv[3], &tail, 0 ); 81 82 82 83 if (errno) { … … 85 86 } 86 87 Ieee1394Service ieee1394service; 87 if ( !ieee1394service.initialize( 0) ) {88 if ( !ieee1394service.initialize( port ) ) { 88 89 fprintf( stderr, "could not set port on ieee1394service\n" ); 89 90 return -1;